Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Jan 10, 2025
1 parent 44669b8 commit 731eea8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public boolean checkCameraConnected() {
return connected;
}

final double CSCORE_DEFAULT_FRAME_TIMEOUT = 1.0 / 4.0;

@Override
public CapturedFrame getInputMat() {
if (!cameraPropertiesCached && camera.isConnected()) {
Expand All @@ -93,7 +95,7 @@ public CapturedFrame getInputMat() {
// Hal::initialize was called
// TODO - under the hood, this incurs an extra copy. We should avoid this, if we
// can.
long captureTimeNs = cvSink.grabFrame(mat.getMat()) * 1000;
long captureTimeNs = cvSink.grabFrame(mat.getMat(), CSCORE_DEFAULT_FRAME_TIMEOUT) * 1000;

if (captureTimeNs == 0) {
var error = cvSink.getError();
Expand All @@ -102,7 +104,6 @@ public CapturedFrame getInputMat() {

return new CapturedFrame(mat, settables.getFrameStaticProperties(), captureTimeNs);
} else {
logger.info("asdf");
// We allocate memory so we don't fill a Mat in use by another thread (memory model is easier)
// TODO - consider a frame pool
// TODO - getCurrentVideoMode is a JNI call for us, but profiling indicates it's fast
Expand All @@ -119,7 +120,7 @@ public CapturedFrame getInputMat() {
// Hal::initialize was called
long captureTimeUs =
CscoreExtras.grabRawSinkFrameTimeoutLastTime(
cvSink.getHandle(), frame.getNativeObj(), 0.225, lastTime);
cvSink.getHandle(), frame.getNativeObj(), CSCORE_DEFAULT_FRAME_TIMEOUT, lastTime);
lastTime = captureTimeUs;

CVMat ret;
Expand Down
4 changes: 2 additions & 2 deletions photon-targeting/src/test/java/jni/CscoreExtrasTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public void testCaptureImage() {
// hard-coded 3 channel
cameraMode.width * 3,
PixelFormat.kBGR);

final double CSCORE_DEFAULT_FRAME_TIMEOUT = 1.0 / 4.0;
long time =
CscoreExtras.grabRawSinkFrameTimeoutLastTime(
cvSink.getHandle(), frame.getNativeObj(), 0.225, lastTime);
cvSink.getHandle(), frame.getNativeObj(), CSCORE_DEFAULT_FRAME_TIMEOUT, lastTime);

if (time != 0) {
var mat = new Mat(CscoreExtras.wrapRawFrame(frame.getNativeObj()));
Expand Down

0 comments on commit 731eea8

Please sign in to comment.