Skip to content

Commit

Permalink
* Work around OpenKinect2FrameGrabber failing when provided with a…
Browse files Browse the repository at this point in the history
… pipeline on some system (pull bytedeco#1886)
  • Loading branch information
regice202 authored Sep 10, 2022
1 parent 32f5fed commit 93fc4f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/bytedeco/javacv/OpenKinect2FrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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);

Expand Down

0 comments on commit 93fc4f7

Please sign in to comment.