Skip to content

Commit

Permalink
Merge branch 'test' into develop
Browse files Browse the repository at this point in the history
* test:
  Testing setting camera width and height before and after open to see if it helps with #395.

# Conflicts:
#	src/main/java/org/openpnp/machine/reference/camera/OpenCvCamera.java
  • Loading branch information
vonnieda committed Dec 30, 2016
2 parents d8fba85 + 188395c commit dda2d89
Showing 1 changed file with 24 additions and 1 deletion.
Expand Up @@ -136,6 +136,21 @@ private void initCamera() {
fg.set(pv.property.getPropertyId(), pv.value);
}
}
/**
* Based on comments in https://github.com/openpnp/openpnp/issues/395 some cameras
* may only handle resolution changes before opening while others handle it after
* so we do both to try to cover both cases.
*/
if (preferredWidth != 0) {
Logger.debug("Setting camera {} width to {}", this, preferredWidth);
fg.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, preferredWidth);
Logger.debug("Camera {} reports width {}", this, fg.get(Highgui.CV_CAP_PROP_FRAME_WIDTH));
}
if (preferredHeight != 0) {
Logger.debug("Setting camera {} height to {}", this, preferredHeight);
fg.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, preferredHeight);
Logger.debug("Camera {} reports height {}", this, fg.get(Highgui.CV_CAP_PROP_FRAME_HEIGHT));
}

fg.open(deviceIndex);

Expand All @@ -145,12 +160,20 @@ private void initCamera() {
fg.set(pv.property.getPropertyId(), pv.value);
}
}

/**
* Based on comments in https://github.com/openpnp/openpnp/issues/395 some cameras
* may only handle resolution changes before opening while others handle it after
* so we do both to try to cover both cases.
*/
if (preferredWidth != 0) {
Logger.debug("Setting camera {} width to {}", this, preferredWidth);
fg.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, preferredWidth);
Logger.debug("Camera {} reports width {}", this, fg.get(Highgui.CV_CAP_PROP_FRAME_WIDTH));
}
if (preferredHeight != 0) {
Logger.debug("Setting camera {} height to {}", this, preferredHeight);
fg.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, preferredHeight);
Logger.debug("Camera {} reports height {}", this, fg.get(Highgui.CV_CAP_PROP_FRAME_HEIGHT));
}
}
catch (Exception e) {
Expand Down

0 comments on commit dda2d89

Please sign in to comment.