简体   繁体   中英

Trouble gaining the depth data from Kinect

I've been messing about all day trying to get the (raw) data from the Kinect with no success.

I've been trying to hack the unit tests into a program of sorts and my Google-fu is letting me down - I couldn't find any other Java examples anywhere on the web using Java/JNA/osX.

This is the test that I've been hacking at but just can't seem to get a method to extract the frame data.

 @Test
 public void testDepth() throws InterruptedException {
    assumeThat(dev, is(not(nullValue())));

    final Object lock = new Object();
    final long start = System.nanoTime();
    System.out.println(dev.getDepthMode());
    //dev.startDepth(new DepthHandler(){});
    dev.startDepth(new DepthHandler() {
        int frameCount = 0;

        @Override
        public void onFrameReceived(FrameMode mode, ByteBuffer frame, int timestamp) {

            //ByteBuffer frame1 = frame;
            frameCount++;
            byte[] b = new byte[frame.remaining()];
            System.out.println(frameCount);
            System.out.println(frame.capacity());
            //System.out.println(frame.);
            if (frameCount >= 300) {
                synchronized (lock) {
                    lock.notify();
                    System.out.format("Got %d depth frames in %4.2fs%n", frameCount,
                            (((double) System.nanoTime() - start) / 1000000000));
                }
            }
        }
    });
    synchronized (lock) {
        lock.wait(20000);
    }
}  

Any help is much appreciated.

Take a look at this project: https://github.com/murphydactyl/JavaKinectFingerTracker

The getDepthFrame function gives you the Depth data in a usable form: https://github.com/murphydactyl/JavaKinectFingerTracker/blob/9ed9fcb7836276f7ac9c2bf25569c68417158df5/kinectdigitizer/KinectFrameGrabber.java

If you try to run it with the newest version of the jna it won't work; the onFrameReceived function changed a bit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM