Add GetNextFrame timeout to CvSink and MjpegServer.

MjpegServer uses the timeout to generate keep-alives to any clients
(which helps detect disconnects and avoid stale client threads).

CvSink GrabFrame now defaults to a timeout, but the timeout can be
changed by the user, or the old no-timeout version is now available
as GrabFrameNoTimeout.
This commit is contained in:
Peter Johnson
2017-02-17 01:17:12 -08:00
parent 5e9575de66
commit 61e34621cc
14 changed files with 126 additions and 5 deletions

View File

@@ -39,10 +39,28 @@ public class CvSink extends VideoSink {
}
/// Wait for the next frame and get the image.
/// Times out (returning 0) after 0.225 seconds.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
public long grabFrame(Mat image) {
return grabFrame(image, 0.225);
}
/// Wait for the next frame and get the image.
/// Times out (returning 0) after timeout seconds.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
public long grabFrame(Mat image, double timeout) {
return CameraServerJNI.grabSinkFrameTimeout(m_handle, image.nativeObj, timeout);
}
/// Wait for the next frame and get the image. May block forever.
/// The provided image will have three 3-bit channels stored in BGR order.
/// @return Frame time, or 0 on error (call GetError() to obtain the error
/// message);
public long grabFrameNoTimeout(Mat image) {
return CameraServerJNI.grabSinkFrame(m_handle, image.nativeObj);
}