Added method to set camera gain for PS3Eye

This commit is contained in:
Banks Troutman
2019-11-26 01:45:35 -05:00
parent 29b52d485b
commit 4bebc3d063
2 changed files with 23 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ public interface CameraCapture extends ImageCapture {
void setExposure(int exposure);
/**
* Set the exposure of the camera
* Set the brightness of the camera
* @param brightness the new brightness to set the camera to
*/
void setBrightness(int brightness);
@@ -23,4 +23,11 @@ public interface CameraCapture extends ImageCapture {
* @param mode the wanted mode
*/
void setVideoMode(VideoMode mode);
/**
* Set the gain of the camera
* NOTE - Not all cameras support this.
* @param gain the new gain to set the camera to
*/
void setGain(int gain);
}

View File

@@ -42,7 +42,7 @@ public class USBCameraCapture implements CameraCapture {
try {
baseCamera.setExposureManual(exposure);
} catch (VideoException e) {
System.err.println("Current camera does not support exposure change");
System.err.println("Failed to change camera exposure!");
}
}
@@ -51,7 +51,7 @@ public class USBCameraCapture implements CameraCapture {
try {
baseCamera.setBrightness(brightness);
} catch (VideoException e) {
System.err.println("Current camera does not support brightness change");
System.err.println("Failed to change camera brightness!");
}
}
@@ -61,7 +61,19 @@ public class USBCameraCapture implements CameraCapture {
baseCamera.setVideoMode(mode);
properties.updateVideoMode(mode);
} catch (VideoException e) {
System.err.println("Current camera does not support resolution change");
System.err.println("Failed to change camera video mode!");
}
}
@Override
public void setGain(int gain) {
if (properties.isPS3Eye) {
try {
baseCamera.getProperty("gain_automatic").set(0);
baseCamera.getProperty("gain").set(gain);
} catch (Exception e) {
System.err.println("Failed to change camera gain!");
}
}
}
}