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

Question:

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->calib.intrinsics_d.projectionParamsSimple.py;

    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)
            continue;
        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 {
            continue;
        }
    }

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!


Answer:

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];

...you 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.


Related:


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


android,c++,android-ndk,jni,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...

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


android,c++,android-ndk,exiv2
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...

Readelf reports program is a shared library instead of executable


c++,makefile,android-ndk,clang
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...

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


android,c++,opengl-es,android-ndk,assimp
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...

Project Tango Point Cloud strange crash, and dense depth map


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...

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


android,graphics,android-ndk,android-gui,surfaceflinger
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();...

Problems compiling NDK project with Android Studio 1.3 preview


android,android-studio,gradle,stl,android-ndk
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...

Android Studio NDK return jint


android,android-ndk,jni,jint
I have successfully followed this tutorial https://www.youtube.com/watch?v=kFtxo7rr2HQ 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;...

Android Studio 1.3 Preview NDK support


android-studio,android-ndk
Yesterday Google announced that native code debugging is now possible with this version of Android Studio. https://plus.google.com/+AndroidDevelopers/posts/2Gk6yrZKV4X 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...

Is using largeheap in Android manifest a good practice?


android,android-ndk
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...

Native Code: cannot use typeid with -fno-rtti


c++,osx,gcc,android-ndk,vtk
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...

Using .so files in Android Studio


android,android-studio,android-ndk,shared-libraries
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...

Remote debugging of pure C program with GDB


android,c,android-ndk,gdb,gdbserver
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...

Multiple apk versionCode distinction


android,android-ndk,multiple-apk
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...

Android armeabi devices with API level 15+


android-ndk
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?...

Automatically copy .so files from NDK library project?


android-studio,gradle,android-ndk
Using Android Studio 1.2.1.1 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...

Color Image in the Google Tango Leibniz API


android,c,camera,yuv,google-project-tango
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...

adb screencap output is different than on the device


android,opengl-es,android-ndk,adb
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...

double* android ndk crash


c++,pointers,android-ndk
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...

OpenGL framebuffer android without GL_OES_packed_depth_stencil (on Nexus 7 2012)


android,c++,android-ndk,opengl-es-2.0,framebuffer
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 =...

Error for cv::FileStorage in JNI


android,c++,opencv,android-ndk,file-storage
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...

Set Android NDK globally in Android Studio


android,android-ndk
The current version (1.2.1.1) 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 local.properties file for Gradle to detect the NDK, whereas the sdk path is auto-populated. Is there...

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


android,android-ndk
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

Qt does not detect Android NDK


android,c++,qt,android-ndk,android-sdk-tools
I want to develop Android apps with Qt. I have Extracted the Android SDK and NDK to C:\. This is the NDK I downloaded: https://squeak-android-vm.googlecode.com/files/android-ndk-1.6_r1-windows.zip 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...

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


android-studio,sdk,android-ndk
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: https://www.youtube.com/watch?v=okLKfxfbz40 . My...

tess-two reciving int but waiting for long


java,android,c++,android-ndk,tess-two
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...

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


java,android,android-studio,gradle,android-ndk
Folder structure app ---main ---java ----jni -----Android.mk -----Application.mk ----- hello-jni.c ---res in build.gradle apply plugin: 'com.android.application' 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...

Tango won't update to Nash


google-project-tango
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


android,unity3d,google-project-tango
I have tried to use the Project Tango unity examples found here; https://github.com/googlesamples/tango-examples-unity with no success. I have never used Unity before, and have successfully completed the Codelab: Motion Tracking example fromt he developer resources: https://developers.google.com/project-tango/apis/unity/unity-codelab-motion-tracking. I downloaded the example files mentioned at the top, open one of the projects...

dlopen failed: cannot locate symbol “cblas_sdsdot” referenced by “libgsl.so”


android,c++,linux,android-ndk,gsl
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 libgsl.so: symbolic link to `libgsl.so.0.14.0' so i did again for libgsl.so.0.14.0 and got this libgsl.so.0.14.0: ELF 32-bit LSB shared...

Debug native code in Android Studio


android,debugging,android-studio,android-ndk
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

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


android,c++,android-ndk
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...

Compile and use boost for Android NDK R10e


android,c++,boost,android-ndk
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:...

NDK application Signature Check


java,android,security,android-ndk,digital-signature
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...

Android NDK socket creation null pointer


android,c,sockets,nullpointerexception,android-ndk
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...

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


c++,android-ndk,cross-platform,clang,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,...

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


android,android-ndk
//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 can I link cpufeatures lib for a native android library?


android,c++,gcc,android-ndk,linker
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...

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


c++,android-ndk,android-sqlite
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...

can't include shared library in android studio


java,android,android-ndk
I'm having a hard time with including my own sqlite library (libsqliteX.so) 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 Application.mk to build also x86 and armeabi-v7a versions of it) and got...

Faster alternative for getPixel and getPixel in Android Bitmap?


android,performance,android-ndk,android-bitmap,renderscript
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...

On Android Studio 1.3, NDK support not working


android,android-studio,android-ndk
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?

Android ndk example native-audio error


android-studio,android-ndk,opensl
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...

Infinite rebuild loop in Eclipse CDT


android,eclipse,android-ndk,cdt,toolchain
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...

Android : Loading pre-built library - Circular dependency dropped


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

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


debugging,android-ndk,floating-point,arm
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,...

How to make android NDK work in windows?


android-ndk,windows-7-x64
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...

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


android,android-studio,android-ndk,cocos2d-x,cocos2d-android
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/add-application.mk","position":{"startLine":199},"original":""} FAILED Execution failed for task ':myApp:compileDebugNdk'. Building works ok. I have Android Studio 1.1.0 and a Mac...

How to write the Android.mk script?


android,android-ndk,android.mk
jni/ Android.mk -> libmyso.so folder1/ Android.mk -> libso1.so folder2/ Android.mk -> libso2.so How to compile the libso1.so and libso2.so into the libmyso.so? Thus, I can only load libmyso.so in the java code, and needn't load libso1.so and libso2.so respectively....