简体   繁体   English

无法从Kinect获取深度数据

[英]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. 我整日忙于试图从Kinect获取(原始)数据而没有成功。

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. 我一直试图将单元测试破解成一个程序,而我的Google-fu却让我失望了-使用Java / JNA / osX在网络上找不到任何其他Java示例。

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 看看这个项目: 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 getDepthFrame函数以可用的形式为您提供深度数据: 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; 如果您尝试使用最新版本的jna运行它,它将无法正常工作; the onFrameReceived function changed a bit. onFrameReceived函数发生了一些变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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