Astra SDK 2.0.7 - Persee - Android - BodyFrame from StreamReader.FrameListener

I am hoping someone can lead me in the right direction for getting Body data from the Orbec Persee on Android.

Update 2:
…or, this is a prelude to a bug report - Advanced

I have created a new project with only the relevant pattern I am attempting to use. Basically, everything seems to work smoothly until the native code attempts to build my joints when my body comes into view.

Here is the error I am receiving.

E/art: JNI ERROR (app bug): attempt to pass an instance of com.orbbec.astra.Matrix3 as argument 3 to void com.orbbec.astra.Joint.(int, int, com.orbbec.astra.Vector2D, com.orbbec.astra.Vector3D, com.orbbec.astra.Matrix3)
A/libc: Fatal signal 11 (SIGSEGV), code 1, …

Update:
Looking at the Unity example (which I managed to get working on the Persee via Unity2017.3.0f3), a similar context can be found in the Unity SDK SkeletonRenderer script.

            for (int i = 0; i < joints.Length; i++)
            {
                joints[i] = (GameObject)Instantiate(JointPrefab, Vector3.zero, Quaternion.identity);
                // Joint.<init>(int, int, com.orbbec.astra.Vector2D, com.orbbec.astra.Vector3D, com.orbbec.astra.Matrix3)
            }

Minimal Example:

public class MainActivity extends Activity {

    private Executor ex;

    /**
     * OnCreate
     * 
     * Create a thread executor as to not block UI thread
     *
     * @param savedInstanceState
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Executor class
        ex = new Executor(){
            @Override
            public void execute(@NonNull Runnable r) {
                new Thread (r).start();
            }
        };
        // Execute the Runnable object
        ex.execute(new UpdateRunnable());
    }

    /**
     * "Main" Runnable code (to be run inside of Astra initialized Thread)
     */
    private class UpdateRunnable implements Runnable {
        @Override
        public void run() {

            // Astra.initialize
            final AstraAndroidContext aac = new AstraAndroidContext(getApplicationContext());
            aac.initialize();
            aac.openAllDevices();

            // Set up Astra Stream Reader(s)
            /*
                I have tried a several combinations of StreamReader variables
                    - a single StreamReader, device/default as arg, no arg, different sensor NUMs...
            */
            //StreamSet.open();
            final StreamReader depthStreamReader = StreamSet.open("device/sensor0").createReader();
            final StreamReader bodyStreamReader = StreamSet.open("device/sensor0").createReader();

            // Get Astra Streams
            final DepthStream depthStream = DepthStream.get(depthStreamReader);
            final BodyStream bodyStream = BodyStream.get(bodyStreamReader);

            // Start Astra Streams
            depthStream.start();
            bodyStream.start();

            // Set Astra Stream Listener(s)
            /**
             * StreamReader.FrameListener (anonymous)
             *
             * Listening for frames using AstraSDK, attempting to track body
             */
            final StreamReader.FrameListener frameListener = new StreamReader.FrameListener() {

                @Override
                public void onFrameReady(StreamReader streamReader, ReaderFrame readerFrame) {
                    Log.d("frame", "frame ready");

                    BodyFrame bf = BodyFrame.get(readerFrame);
                    Iterable<Body> bodies = bf.getBodies(); // fails when there are bodies to get
                    if (bodies != null) {
                        Log.d("getting somewhere? ", "" + bodies.iterator().hasNext());
                    }
                }
            };
            // Listener set
            bodyStreamReader.addFrameListener(frameListener);

            /*
                The following loop continues until I step into frame.  Once enough of my body is in the
                frame, the program exits with the following message tail:

                ...
                D/getting somewhere?: false
                D/frame: frame ready
                D/getting somewhere?: false
                D/frame: frame ready
                E/art: JNI ERROR (app bug): attempt to pass an instance of com.orbbec.astra.Matrix3 as argument 3 to void com.orbbec.astra.Joint.<init>(int, int, com.orbbec.astra.Vector2D, com.orbbec.astra.Vector3D, com.orbbec.astra.Matrix3)
                A/libc: Fatal signal 11 (SIGSEGV), code 1

                (In place of the error, I was expecting: D/getting somewhere?: true)
             */
            while (true){
                Astra.update();
            }
        }
    }
}

Any help would be greatly appreciated.

Thank You,

  • Dustin
1 Like

@dcharles Can you provide a working example? This would be great :slight_smile:

I have a working example published on Github: GitHub - Michael-List/Orbbec_Astra_Example_Android: Orbbec Astra example for Android