Add more video mode checking to camera streamer

seems to resolve spam-y errors saying `CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.7) /__w/1/s/opencv/modules/core/src/matrix_wrap.cpp:1658: error: (-215:Assertion failed) !fixedSize() in function 'release'`
This commit is contained in:
Matt
2020-03-07 15:51:30 -08:00
parent da6f0e8a81
commit 4ce32b5374

View File

@@ -86,6 +86,18 @@ public class CameraStreamer {
// Size newSize = new Size(newWidth, newHeight);
Imgproc.resize(streamBuffer, streamBuffer, this.size);
}
var sourceVideoMode = cvSource.getVideoMode();
var imageSize = streamBuffer.size();
if(sourceVideoMode.width != (int) imageSize.width || sourceVideoMode.height != (int) imageSize.height) {
synchronized (streamBufferLock) {
cvSource.setVideoMode(new VideoMode(sourceVideoMode.pixelFormat,
(int)imageSize.width,
(int) imageSize.height,
sourceVideoMode.fps));
}
}
cvSource.putFrame(streamBuffer);
}
}