StructDroid simple scanner app for android

I wrote a small app for android to test how the scanner can be accessed

I need some feedback if it works on other devices as my Motorola Xoom as well. Anyone who wants to give it a try, the information can be found here StructDroid

Currently it only captures single scans and only with the first camera that is found.

Scans are stored in the external storage under the StructureScanner folder. Each scan is stored as an individual zip file with a raw file cotaining the 16bit depthvalues and a jpg containing the image

The google play store link does not work yet, but the apk can be downloaded directly

2 Likes

Cool! Tested with my HTC One (4.4.3), the sensor lights illuminate all apparently normal, USB connection seems fine, but as soon as I click on the iris symbol it closes with the message “Unfortunately, StructDroid has stopped.”

W/Binder ( 5791): Caught a RuntimeException from the binder stub implementation.
W/Binder ( 5791): java.lang.NullPointerException
W/Binder ( 5791): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java)
W/Binder ( 5791): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java)
W/Binder ( 5791): at android.os.Binder.execTransact(Binder.java)
W/Binder ( 5791): at dalvik.system.NativeStart.run(Native Method)

Can you send me a longer version of the logcat output. I’ve put in a lot of log messages to see where it is crashing.
I am connecting the adb via tcp to have the USB port available for the scanner and be able to see the log messages at the same time.

Thanks

Hi there,

Tested on my Samsung Galaxy S3 (4.4.4) rooted and it looks good. No crash and the result is as expected. On the other hand, on my SM-T330NU (4.4.2) non rooted, it crashes. The Sensor is detected and the application try to start when plugged in but it’s not successful. I think it crashes on USB access. I don’t have access to the logcat yet so I cannot copy/paste the error, sorry.

I was wondering, is there a way to grab a copy of the source code? I would like to explore the usage of the StructureIO Sensor with Android. I managed to write an application with native code to retrieve data from the sensor but I would like to push it further and get some inspiration from yours.

It seems to look like the “rooted” part is currently mandatory. I don’t fully understand why, since I removed all code that depends on SuperUser commands but I have a Samsung Galaxy Note 10.1 with Android 4.4 and it does not work either.

I will try to make the sourcecode available, but currently it is a loose coupling of hacks to get it working and that would not do anyone a favor.

The steps I took to get it working were:

  1. Based on the SimpleRead sample in OpenNI I created the native code to open/scan/close the scanner.

  2. I added a function to the OpenNI class that allows me to set a different path where the code that loads the dynamic
    libraries tries to find the PS1080.dll.

  3. This function is used within java when the app loads to set the library path relative to the installed APK. With that I don’t need to copy the libraries to a certain directory

  4. When the java class is instantiated it loads the dlls in the following order
    “usb”, “OniFile”, “PS1080”, “PSLink”, “OpenNI2”, “AndroidRead”
    Some of them are probably not necessary, since they are loaded dynamically upon intialization of OpenNI itself

  5. Before accessing the USB through the native code I am opening the scanner in the Java application and leave it opened until the app is closed. Without that part I had to modify the permissions on the scanner device in /dev/bus/usb to allow the user to access the usb

Well that’s about it.

If it really is not possible to use the libusb without rooting the device then the only solution I can see is to reimplement the USB communication completely in JAVA. Which probably no one wants to do :smile:

Thank you for this very useful reply! It’s really appreciated.
I was actually wondering how to tell OpenNI where to load the dynamic libraries within Java so I don’t have to manually copy/paste them in a given directory but points 2 and 3 give me a good overview on how to proceed.
I’ll keep exploring on this subject based on your directions. Thank you.

Ok, I put the patch together. You can find it here: http://pastebin.com/yxDCM7r1
Just apply it to a clean checkout of the OpenNI2 source

after building the android package you will have a library called libAndroidRead.so, the java class that is the counterpart to the native code can be found in Samples/AndroidRead/java/com/zero997/structurescanner/StructureScanner.java

If you include the code in your android project you can use it as follows:

call activate() in onResume of your main activity and deactivate() in the onPause

How to scan. Call safe_open() and then safe_scan(). You can call safe_open() as many times as you want it will only open the scanner once.

You can call isActive() to see if the scanner has been initialized (if not it is probably not connected)

safe_scan() will return an int[] array with the depth values (currently hardcoded to 640x480)

But be warned, the code is messy, and not ready for production.

1 Like

BTW: I just discovered that the app works on my non-rooted Wacom Cintiq Companion Hybrid with Android 4.2 if I use the debug version (installed via adb). This makes me hoepful that there is a solution for non-rooted device as well.

If you want to try it please install the debug APK from the StructDroid post.

Hi, Long time lurker.

I tried the Android app on my Galaxy S5 (rooted) version 4.4.2, but it did not work (crashed each time). It did start the app/detect the struct sensor when I plugged in via an OTG cable, so that part works.

I tried multiple reboots of the phone. Did not fix the issue. Un-installed.

Then I installed the DEBUG (0.1) version pushed by ADB, and it worked. i did 4 successive depth scans of my room, and the image (semi off set) applied as an overlay to my phone’s camera.

I then checked the saved location and I had 4 zip files (of different sizes) so all indications at this point it works (when installed by ADB).

Let me know if you want more information.

I do @lasinir. I played with it and had the same results, but don’t have time to do any real troubleshooting at this moment since I neck high in iOS. Loved to know what you did. My ultimate goal is to use the Nvidia Tegra K1 and their upcoming Tegra X1. I think the Cuda cores could be useful especially if the X1 is indeed an even lower powered version of their Maxwell chip chip which really performs, even at the 850M level on my laptop with Skanect.

The Wacom tablet is a Tegra 4 with Android 4.2, and the debug version of the app works without a rooted android.

I think I found a way to make it work on non rooted devices without the need to install a debug APK.

The latest version on the link in the Original post was now tested on a non rooted Android 4.2

okay. I un-installed the debug version…

I then installed the version from google play.

And then tried it. It worked. (no crashes) on my Galaxy S5.

Nice.

Keep up the good work. Now just to catch up to the iDevice version.

Hi Michael,

Thanks for sharing your progress.

I can confirm that the debug version of your .APK runs smoothly on non-rooted Galaxy Nexus 4.2.2.

Also tried on non-rooted Galaxy Note 10.1 2014 tablet and instant crash (as you mentioned, just thought I’d try).

Also tried on rooted Galaxy S3 4.2.2 (t999) where I had the NDK compiled OpenNI drivers in /system/lib/ and the app caused my camera to fail, I had to restart the device to get it to work again. Wasn’t able to get a depth image.

I am also in the process of getting the sensor to work on Android without too many hacks, I will keep you updated.

Hi Michael,
I downloaded the app from google play store yesterday and tested it on my Sony Xperia Z tablet (non rooted).
It did crash the first time I hit the iris icon. But I figured I give it another try. I started the app again and it never
crashed after. Didn’t use the data yet cause I just had enough time for a quick try. I just thought I let you know.

I’ve got a development update here

The Play Store update should be available sometime later today. If you installed it manually you can already download it from the development blog.

This update does not add new features but it fixes the problem with the Samsung Galaxy Note 10.1 (Android 4.1.2) and probably a few other devices as well.