Skip to content

Commit

Permalink
* Throw appropriate exception in FrameGrabber.start() (issue #315)
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Feb 1, 2016
1 parent 94d7973 commit 6917026
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

* Fix swallowed `InterruptedException` ([issue #315](https://github.com/bytedeco/javacv/issues/315))
* Clean up `IPCameraFrameGrabber` ([pull #323](https://github.com/bytedeco/javacv/pull/323)
* Fix swallowed `InterruptedException` and throw appropriate exception in `FrameGrabber.start()` ([issue #315](https://github.com/bytedeco/javacv/issues/315))
* Fix `IPCameraFrameGrabber.stop()` not checking for null ([pull #300](https://github.com/bytedeco/javacv/pull/300)
* Upgrade dependencies for OpenCV 3.1.0, FFmpeg 2.8.4
* Let users call `FFmpegFrameFilter.push(null)` to indicate EOF, as required by some filters like "palettegen" ([issue #287](https://github.com/bytedeco/javacv/issues/287))
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/bytedeco/javacv/DC1394FrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ public void start(boolean tryReset, boolean try1394b) throws Exception {
} catch (InterruptedException ex) {
// reset interrupt to be nice
Thread.currentThread().interrupt();
return;
}
if (!resetDone) {
throw new Exception("dc1394_reset_bus() Error: Could not reset bus and try to start again.");
}
} else {
throw e;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/bytedeco/javacv/OpenCVFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,22 @@ public void start() throws Exception {
}
cvSetCaptureProperty(capture, CV_CAP_PROP_CONVERT_RGB, imageMode == ImageMode.COLOR ? 1 : 0);

IplImage frame = null;
try {
// Before cvRetrieveFrame() starts returning something else then null
// QTKit sometimes requires some "warm-up" time for some reason...
// The first frame on Linux is sometimes null as well,
// so it's probably a good idea to run this for all platforms... ?
int count = 0;
while (count++ < 100 && cvGrabFrame(capture) != 0 && cvRetrieveFrame(capture) == null) {
while (count++ < 100 && cvGrabFrame(capture) != 0 && (frame = cvRetrieveFrame(capture)) == null) {
Thread.sleep(100);
}
} catch (InterruptedException ex) {
// reset interrupt to be nice
Thread.currentThread().interrupt();
return;
}
if (frame == null) {
throw new Exception("cvRetrieveFrame() Error: Could not retrieve frame in start().");
}

if (!triggerMode) {
Expand Down

0 comments on commit 6917026

Please sign in to comment.