android-ndk,google-project-tango , Project Tango Point Cloud strange crash, and dense depth map

Project Tango Point Cloud strange crash, and dense depth map


Tag: android-ndk,google-project-tango

I am trying to use Project Tango C API, but the application crashed with no error if number of point cloud are more than ~6.5k (after some testing) with the following code

    int width = mImageSource->getDepthImageSize().x;
    int height = mImageSource->getDepthImageSize().y;
    double fx = mImageSource->calib.intrinsics_d.projectionParamsSimple.fx;
    double fy = mImageSource->calib.intrinsics_d.projectionParamsSimple.fy;
    double cx = mImageSource->calib.intrinsics_d.projectionParamsSimple.px;
    double cy = mImageSource->;

    memset(inputRawDepthImage->GetData(MEMORYDEVICE_CPU), -1, sizeof(short)*width*height);
    for (int i = 0; i < XYZ_ij->xyz_count; i++) {
        float X = XYZ_ij->xyz[i*3][0];
        float Y = XYZ_ij->xyz[i*3][1];
        float Z = XYZ_ij->xyz[i*3][2];
        if (Z < EPSILON || (X < EPSILON && -X < EPSILON) || (Y < EPSILON && -Y < EPSILON) || X != X || Y != Y || Z != Z)
        int x_2d = (int)(fx*X/Z+cx);
        int y_2d = (int)(fy*Y/Z+cy);
        if (x_2d >=0 && x_2d < width && y_2d >= 0 && y_2d < height && (x_2d != 0 || x_2d != 0)) {
            inputRawDepthImage->GetData(MEMORYDEVICE_CPU)[x_2d + y_2d*width] = (short) (Z*1000);
        } else {

However, if I use for (int i = 0; i < XYZ_ij->xyz_count && i < 6500; i++) everything works fine. I am just wondering if there is an upper bound for access point cloud with C API or I did something wrong?

(width is 320, height is 180, and other intrinsics are loaded from Tango API)

In addition, Google mentioned to use nearest- neighbor filter to get dense depth map in bottom of this page, is there an interface in Tango API for this? Or would anyone suggest an open source implementation for it.

I am also wondering if there is anyway to "pull" colored image(1280x720) in onXYZijAvailable because I need a dense synchronized colored point cloud. Do I need to apply external matrix to align both coordinate frame, or I only need to subsample color image (assume their coordinate system are the same)?

Thank you for any advice!


In your code that looks up the depth sample coordinates...

for (int i = 0; i < XYZ_ij->xyz_count; i++) {
    float X = XYZ_ij->xyz[i*3][0];
    float Y = XYZ_ij->xyz[i*3][1];
    float Z = XYZ_ij->xyz[i*3][2]; should be using an index of i, not i*3. It is a 2D array so you don't have to manage the stride for the higher dimension yourself.

The SDK does not provide a call to fill in locations with no depth samples, probably because there are many approaches with different tradeoffs. The Wikipedia page on nearest neighbor search is a reasonable place to start. There is an interface to FLANN in OpenCV.

The SDK will only deliver the latest color image to you. If you want a prior image (e.g. with a timestamp close to your depth samples) you will have to manage that yourself. Because you can never get a color image at exactly the same timestamp with your depth samples (as the same camera is used in different modes for both), you theoretically should apply the extrinsic pose to align them. In practice if the motion is small over the 0.5 frame time or less between the timestamps, I think most people are going to ignore it.


re write-sql statement Insert OR REPLACE from java to c++ NDK Android

I need re write this sqlite Statements from java to c++, BEcouse of low performance: I red this arcticle: Improve INSERT-per-second performance of SQLite? But Iam totaly confused, becouse I cant find any sqlstatemenst of Insert or Update public synchronized void saveMatchValue(int photoRecOwner, int[] photoRecAssign, float[] value) { SQLiteDatabase database...

How can I link cpufeatures lib for a native android library?

I'm trying to link android's cpu_features to a native library. I'm using android's gcc compiler directly as a cross compiler. (NOT ndk-build). I've included the header ($NDK_PATH/sources/android/cpufeatures/cpu-features.h), but i don't see a prebuilt libcpufeatures.a file anywhere under the ndk folder. How can I build that library? Or where can it...

What is the difference between normal method call from native method call?

//my class class NDKSupport { // Loding library static { System.loadLibrary("NDKTest"); } // Stuff in NDKSupport public native String getMessageFromNDK(NDKSupport support); public String getMessage() { // doing some stuff over here return "SOME RESULT"; } } //Native code JNIEXPORT jstring JNICALL Java_com_afbb_ndkcheck_NDKSupport_getMessageFromNDK( JNIEnv* env, jobject thiz, jobject ndkSupport) { jclass...

How to upscale and render remote(RGB565) frame buffer on Android native?

I have ported remote frame buffer receive C code on Android 4.2.2 which receives frame buffer from host in RGB565 format. Able to render the received framebuffer following the standard android example frameworks/native/services/surfaceflinger/tests/resize/resize.cpp. Following is the code snippet used sp<Surface> surface = client->createSurface(String8("resize"), 800, 480, PIXEL_FORMAT_RGB_565, 0); SurfaceComposerClient::openGlobalTransaction(); surface->setLayer(100000); SurfaceComposerClient::closeGlobalTransaction();...

Qt does not detect Android NDK

I want to develop Android apps with Qt. I have Extracted the Android SDK and NDK to C:\. This is the NDK I downloaded: But Qt 5.2.1 does not detect the NDK and this error is shown: "C:\android-ndk-1.6_r1" does not seem to be an Android NDK top folder. Do...

Debug native code in Android Studio

Google I/O 2015 promised debugging native code in Android Studio. To do this, you need to install ndk-bundle through SDK manager and update Android Studio to the latest version (Canary branch). And what to do next? How setup? Here is a link to the source. Source

On Android Studio 1.3, NDK support not working

I have upgraded the Android Studio to 1.3, about which they say they have added Native development support. But I found no change regarding NDK. :/ Any help?

How do i call C/C++ code from Android using JNA?

I'm trying to integrate this specific library to my Android project, and the library is written in C/C++. I've miraculously gotten ndk-build to give me the needed .so file. However, looking at it, there's a sample in the project, and they use a mysterious .jar with the API bindings of...

dlopen failed: cannot locate symbol “cblas_sdsdot” referenced by “”

I cross compiled gsl for android using arm-linux-androideabi compiler following the answer provided in this question. I installed the library in /home/username/AndroidGSL. I checked the file command and it gave me symbolic link to `' so i did again for and got this ELF 32-bit LSB shared...

Android Studio 1.3 Preview NDK support

Yesterday Google announced that native code debugging is now possible with this version of Android Studio. I've updated to the newest build version "AI-141.1962279" and can't see any possibility of debugging native code. I've switched to build-tools 23.0-rc1, used gradle plugin 1.3.0-beta1 but cannot set breakpoints in native code...

Android armeabi devices with API level 15+

I'm developing an app for API level 15+ that has some jni code and i'm wondering if there are devices with armeabi ABI (ARMv5) and API level 15+ Can i include only armeabi-v7a and x86 libraries and skip the old armeabi?...

Readelf reports program is a shared library instead of executable

got this strange behaviour with standalone Android NDK r10e Toolchain (built with --toolchain=x86-clang3.6 switch). Environment variables for cross compilation have been set before running makefile, SYSROOT points to Android toolchain location, CXX equals i686-linux-android-clang++. Basically, I have a bunch of cpp files that I would like to compile to Android...

Remote debugging of pure C program with GDB

I am trying to remotely debug a pure C program on an Android device. The Android device (target) is connected via USB to a host machine. What I did was: Copied from the target the following files: /system/lib, /vendor/lib, /system/bin/app_process, and /system/bin/linker. Target: Copied gdbserver from NDK to the target...

ndk-build outputs ‘error adding symbols. File in wrong format’

I want to use exiv2 library written in C++ in my Android project. To do that I try to cross-compile the library using Android NDK. For cross-compiling I follow presented below steps: Add the ndk path to variable PATH $ PATH="/home/patrycja/android-packages/ndk:${PATH}" $ export PATH Install the standard toolchain for cross-compiling...

NDK application Signature Check

I have some security key in an application. I want to store it securly. I like to store it in a native shared library (maybe generated from some code). After that I want it to be returned by a method that will check the signature of the original APK. So...

java.lang.UnsatisfiedLinkError - NDK in android studio gradle?

Folder structure app ---main ---java ----jni ----- hello-jni.c ---res in build.gradle apply plugin: '' android { compileSdkVersion 21 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.example.hellojni" minSdkVersion 17 targetSdkVersion 21 sourceSets.main { jni.srcDirs = [] jniLibs.srcDir 'src/main/libs' } ndk { moduleName "hello-jni" cFlags "-std=c++11 -fexceptions" ldLibs "log" stl "gnustl_shared" abiFilter...

Faster alternative for getPixel and getPixel in Android Bitmap?

I'm using the methods getPixel and setPixel for my Bitmap and it's so slow (getPixels too). I want to process every pixel of the Bitmap and then create another Bitmap. How can I get access to pixels by RenderScript or using C++? I think they are faster but I don't...

tess-two reciving int but waiting for long

I tried to rebuild an android app wich contains tess-two as library. When using as is, I get this error java.lang.NoSuchFieldError: no field with name='mNativeData' signature='I' in class Lcom/googlecode/tesseract/android/TessBaseAPI; When reverting commit bc931c966f5a05745bd4be5833f551643589982d (private long mNativeData; changed to private int mNativeData;) It then works. It might be related to my...

Android ndk example native-audio error

I try to use the example code for OpenSl ES wich is included in NDK in Android Studio. It didn't work as you will see later on. So I need help to use the code in Android Studio. The Code was written for Eclipse but I used the import function...

Set Android NDK globally in Android Studio

The current version ( of Android Studio allows me to build sample apps using the NDK, but I have noticed that each time I load a new project, I must set ndk.dir=/path/to/ndk/install in my file for Gradle to detect the NDK, whereas the sdk path is auto-populated. Is there...

Native Code: cannot use typeid with -fno-rtti

I'm trying to build native code on android because I want to use VTK for my android tablet. However, I am facing some issues when it comes to building one of the vtk examples. I know this problem has been covered here for an objective c issue but I guess...

Problems compiling NDK project with Android Studio 1.3 preview

Decided to give the new NDK support in Android studio a shot but seem to be running into an issue: Error: 'std::function' has not been declared Had a few other linking issues with stl libraries before but those were fixed by adding stl "stlport_static" cFlags "-O2 --std=c++11 " to the...

NDK & Android Studio, compiling it crashes because of shared libraries

For code reusing I had to move some native code from the working directory to a shared library. This movement however causes a lot of troubles. If I try to compile it in the old place, everything just clicks, instead if I try to compile it with the same data...

Infinite rebuild loop in Eclipse CDT

My setup is a bit sketchy, I'll admit. This was working correctly with Eclipse Indigo but Luna keeps rebuilding my C++ Android project over and over. This happens when I select the "Build on resource save (Auto build)" which was rather convenient. Checking this option gets me into an infinite...

double* android ndk crash

I'm facing a peculiar problem with the android ndk. I'm trying to read a previously stored set of bytes in an unsigned char* readBytes (previous allocated and read from file). The data needs to be interpreted as double. unsigned char* svDataOffset=(unsigned char*)(readBytes+byteCounter); unsigned char* chars=(unsigned char*)(svDataOffset+2); //offset of 2 is...

can't include shared library in android studio

I'm having a hard time with including my own sqlite library ( in android studio: I followed this guide and loaded this and compiled it with latest android NDK (r10e) (i just added "APP_ABI := xxx" to the to build also x86 and armeabi-v7a versions of it) and got...

adb screencap output is different than on the device

I have a graphical glitch related to blending in my OpenGL application using Android NDK. The strange thing is that when I take a screenshot through adb screencap command, the problem completely disappears and the result looks okay. My question is: Is there a way to know what is happening...

Project Tango Point Cloud strange crash, and dense depth map

I am trying to use Project Tango C API, but the application crashed with no error if number of point cloud are more than ~6.5k (after some testing) with the following code int width = mImageSource->getDepthImageSize().x; int height = mImageSource->getDepthImageSize().y; double fx = mImageSource->calib.intrinsics_d.projectionParamsSimple.fx; double fy = mImageSource->calib.intrinsics_d.projectionParamsSimple.fy; double cx...

Color Image in the Google Tango Leibniz API

I am trying to capture the image data in the onFrameAvailable method from a Google Tango. I am using the Leibniz release. In the header file it is said that the buffer contains HAL_PIXEL_FORMAT_YV12 pixel data. In the release notes they say the buffer contains YUV420SP. But in the documentation...

Automatically copy .so files from NDK library project?

Using Android Studio with Gradle 1.2.3. I have an NDK library project A that produces a number of .so files in its own libs folder. Though, I cannot see the reference to this folder anywhere in the build.gradle file. When I reference library A from my app MyApp I...

Getting error: Execution failed for task : myApp:compileDebugNdk'

Hi I am trying to run an app created with Cocos2d-x 2.5 with Android Studio but I keep getting this error when running the project: :myApp:compileDebugNdk AGPBI: {"kind":"ERROR","text":"*** Android NDK: Aborting... . Stop.","sourcePath":"/mypath/ndk/android-ndk-r10d/build/core/","position":{"startLine":199},"original":""} FAILED Execution failed for task ':myApp:compileDebugNdk'. Building works ok. I have Android Studio 1.1.0 and a Mac...

Is using largeheap in Android manifest a good practice?

I am developing in NDK. It hangs in Galaxy S3. For testing I put android:largeheap = "true" in Manifest. Then there was no hanging issue. Is it a good practice to use largeHeap="true"? Is there any chance that Google rejects my build due to this tag and how can I...

Tango won't update to Nash

I am currently using Project Tango in UK. I tried to use system update to upgrade to Nash release, but it shows "your system is up to date". I am sure the device is currently in Libnitz. Is Google blocking OTA out of USA?

Using Project Tango Unity example projects

I have tried to use the Project Tango unity examples found here; with no success. I have never used Unity before, and have successfully completed the Codelab: Motion Tracking example fromt he developer resources: I downloaded the example files mentioned at the top, open one of the projects...

Android : Loading pre-built library - Circular dependency dropped

I am trying to import a module into my project. in module: LOCAL_PATH := $(call my-dir) include $(CEAR_VARS) LOCAL_MODULE := fromhere1 LOCAL_MODULE_FILENAME := fromhere1 LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/ include $(PREBUILT_SHARED_LIBRARY) is built by ndk-build in my project: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := native LOCAL_MODULE_FILENAME :=...

Android Studio NDK return jint

I have successfully followed this tutorial to learn about building NDK apps with Android Studio. That tutorial uses a public native String HelloJNI(); That string is set in the HelloJNI.c file #include "com_example_myapplication_MainActivity.h" /* Header for class com_example_myapplication_MainActivity */ /* * Class: com_example_myapplication_MainActivity * Method: HelloJNI * Signature: ()Ljava/lang/String;...

How to fix 'javah' error when using NDK with Android Studio?

I am trying to set up NDK so that I can add C/C++ code to my Android application within Android Studio 0.5.1. I am ultimately trying to get it compiled during gradle build, and to properly handle APKs generation. Much like the tutorial explains in this video: . My...

How to render a 3D file using Assimp library [closed]

I am working on an android project, in which I need to render 3D file. I have decided to use Assimp library after a lot of research. I have successfully compiled Assimp library.. But I am not able to render a file using it. There is not much documentation available...

Error for cv::FileStorage in JNI

I am getting errors while compiling my native.cpp file in Eclipse ADT/NDK. While compiling the following lines of code FileStorage storage(nativepath, FileStorage::WRITE); storage << "img" << mat; storage.release(); The errors are D:/androidworkspace/Augmented-Reality//obj/local/arm64-v8a/objs/ndksetup/native.o: In function Java_com_shahrukh_AugmentedReality_CAMShiftDetection_savemat(_JNIEnv*, _jobject*, long long, _jstring*)': D:\androidworkspace\Augmented-Reality/jni/native.cpp:14: undefined reference...

Android NDK socket creation null pointer

For adding TCP-socket-options, I need to use the C-sockets of Android NDK instead of Java sockets. The following function is called by a button-click-event. When creating such a socket, the syscall leads me to a null pointer (see log output at the end). As the log shows, the line above...

Multiple apk versionCode distinction

I have an application that supports both x86 and arm-v7 platforms. I should define different android:versionCode for different platform apks. Therefore I put for example 100 and 200 in value and upload an apk to Google Play. The issue in devices that support both platforms. If a device on x86...

fpscr register is not updated when enabling floating point exceptions on arm7, SIGFPE not generated

fpscr register is not updated and SIGFPE is not generated. This was tested on an NVidia Shield Tablet and a 1st gen Nexus 7. feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); The implementation calls code, which eventually executes this assembly: asm _volatile__("vmsr fpscr,%0" : :"ri" (fpscr)); ; disassembly follows ldr r3, [r11,...

OpenGL framebuffer android without GL_OES_packed_depth_stencil (on Nexus 7 2012)

How do I init the framebuffer with depth and stencil on a device which does not support GL_OES_packed_depth_stencil (In my case a Nexus 7 2012)? This does not work: glGenRenderbuffers(1, &depthStencil); glBindRenderbuffer(GL_RENDERBUFFER, depthStencil); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthStencil); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthStencil); GLenum status =...

Compile and use boost for Android NDK R10e

How do I compile and use Boost for the Android NDK? I've tried everything I've found online, from Boost for Android to compiling it myself with the bjam file. However, I do not succeed. When I try compiling it with bjam, I get the following error: error: toolset gcc initialization:...

Android NDK error bash: ../../build/intermediates/classes/debug/: Is a director

ubuntu kylin system NDK version r10e SDK version android-22 Details command: javah -d jni -classpath /home/king/ide/android-sdk-linux/platforms/android-22/android.jar;../../build/intermediates/classes/debug/ com.lengking.ndk.MainActivity error :bash: ../../build/intermediates/classes/debug/: Is a director I did not find the answer on the Web

How to make android NDK work in windows?

I have downloaded android-ndk-r10e & I have also setted path in environment variable as well as NDK path for eclipse. I was able to build and run HelloJni sample app from eclipse, but when I use console to build it says 'ndk' is not recognized as an internal or external...

Linking against third-party libraries when doing cross-platform build in Visual Studio 2015

I am trying to compile a Shared Object (.so) with Visual Studio 2015 RC. I am linking against the Opus Codec libs in my stdafx.h: #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\celt.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\opus.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\silk_common.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\silk_fixed.lib") #pragma comment(lib,...

Using .so files in Android Studio

I am new to Android. I have a basic hello-world native code function like this: #include <string.h> #include <jni.h> #include <cassert> #include <string> #include <iostream> #include <fromhere.h> using namespace std; /* This is a trivial JNI example. * The string returned can be used by java code*/ extern "C"{ JNIEXPORT...

How to write the script?

jni/ -> folder1/ -> folder2/ -> How to compile the and into the Thus, I can only load in the java code, and needn't load and respectively....