diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4eedfc..0fa8f865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Work around `OpenKinect2FrameGrabber` failing when provided with a pipeline on some system ([pull #1886](https://github.com/bytedeco/javacv/pull/1886)) * Fix `FFmpegFrameRecorder.record()` incorrectly flushing the video codec on data frames ([issue #1858](https://github.com/bytedeco/javacv/issues/1858)) * Improve accuracy of `FFmpegFrameGrabber.setFrameNumber()` ([pull #1851](https://github.com/bytedeco/javacv/pull/1851)) * Add `FrameGrabber.resetStartTime()` to allow `grabAtFrameRate()` after operations such as seeking ([pull #1846](https://github.com/bytedeco/javacv/pull/1846)) diff --git a/src/main/java/org/bytedeco/javacv/OpenKinect2FrameGrabber.java b/src/main/java/org/bytedeco/javacv/OpenKinect2FrameGrabber.java index 5a9ecf00..47ac9868 100644 --- a/src/main/java/org/bytedeco/javacv/OpenKinect2FrameGrabber.java +++ b/src/main/java/org/bytedeco/javacv/OpenKinect2FrameGrabber.java @@ -99,7 +99,7 @@ public static void tryLoad() throws FrameGrabber.Exception { } Loader.load(org.bytedeco.libfreenect2.global.freenect2.class); - // Context is shared accross cameras. + // Context is shared accross cameras. freenect2Context = new Freenect2(); } catch (Throwable t) { throw loadingException = new FrameGrabber.Exception("Failed to load " + OpenKinect2FrameGrabber.class, t); @@ -153,6 +153,10 @@ protected void finalize() throws Throwable { @Override public void start() throws FrameGrabber.Exception { + startDevice(null); + } + + public void startDevice(PacketPipeline pipeline) throws FrameGrabber.Exception { if (freenect2Context == null) { try { OpenKinect2FrameGrabber.tryLoad(); @@ -168,14 +172,13 @@ public void start() throws FrameGrabber.Exception { throw new Exception("FATAL error: OpenKinect2: no device connected!"); } device = null; - PacketPipeline pipeline = null; - pipeline = new CpuPacketPipeline(); +// pipeline = new CpuPacketPipeline(); // pipeline = new libfreenect2::OpenGLPacketPipeline(); // pipeline = new libfreenect2::OpenCLPacketPipeline(deviceId); // pipeline = new libfreenect2::CudaPacketPipeline(deviceId); serial = freenect2Context.getDeviceSerialNumber(deviceNumber).getString(); - device = freenect2Context.openDevice(serial, pipeline); + device = (pipeline != null) ? freenect2Context.openDevice(serial, pipeline) : freenect2Context.openDevice(serial); frameListener = new SyncMultiFrameListener(frameTypes);