Skip to content

Commit

Permalink
Renames, improved camera-specific settables
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Jul 19, 2024
1 parent 4a15f27 commit e5c9cdf
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public enum CameraQuirk {
/** Camera settable for controllable image gain */
Gain,
/** Only certain discrete exposure settings work */
LifeCam,
LifeCamControls,
/** Auto-Exposure property uses 1/0, rather than 3/1 */
OneZeroAutoExposure,
PsEyeControls,
/** Cap at 100FPS for high-bandwidth cameras */
FPSCap100,
/** Separate red/blue gain controls available */
Expand All @@ -42,5 +42,5 @@ public enum CameraQuirk {
*/
ArduOV9281,
/** Dummy quirk to tell OV2311 from OV9281 */
ArduOV2311,
ArduOV2311Controls,
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ public class QuirkyCamera {
// Mac Facetime Camera shared into Windows in Bootcamp
new QuirkyCamera(-1, -1, "FaceTime HD Camera", CameraQuirk.CompletelyBroken),
// Microsoft Lifecam
new QuirkyCamera(-1, -1, "LifeCam HD-3000", CameraQuirk.LifeCam),
new QuirkyCamera(-1, -1, "LifeCam HD-3000", CameraQuirk.LifeCamControls),
// Microsoft Lifecam
new QuirkyCamera(-1, -1, "LifeCam Cinema (TM)", CameraQuirk.LifeCam),
new QuirkyCamera(-1, -1, "LifeCam Cinema (TM)", CameraQuirk.LifeCamControls),
// PS3Eye
new QuirkyCamera(
0x1415,
0x2000,
CameraQuirk.Gain,
CameraQuirk.FPSCap100,
CameraQuirk.OneZeroAutoExposure),
CameraQuirk.PsEyeControls),
// Logitech C925-e
new QuirkyCamera(0x85B, 0x46D, CameraQuirk.AdjustableFocus),
// Generic arducam. Since OV2311 can't be differentiated
Expand All @@ -67,7 +67,7 @@ public class QuirkyCamera {
"OV2311",
"OV2311",
CameraQuirk.ArduCamCamera,
CameraQuirk.ArduOV2311,
CameraQuirk.ArduOV2311Controls,
CameraQuirk.StickyFPS),
// Arducam OV9281
new QuirkyCamera(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.photonvision.vision.camera.USBCameras;

import edu.wpi.first.cscore.UsbCamera;


import org.photonvision.common.configuration.CameraConfiguration;

public class ArduOV2311CameraSettables extends GenericUSBCameraSettables {

public ArduOV2311CameraSettables(CameraConfiguration configuration, UsbCamera camera) {
super(configuration, camera);
}

@Override
protected void setUpExposureProperties() {
super.setUpExposureProperties();

// Property limits are incorrect
this.minExposure = 1;
this.maxExposure = 75;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class GenericUSBCameraSettables extends VisionSourceSettables {
protected double minExposure = 1;
protected double maxExposure = 80000;

protected int PROP_AUTO_EXPOSURE_ENABLED = 3;
protected int PROP_AUTO_EXPOSURE_DISABLED = 1;
protected static final int PROP_AUTO_EXPOSURE_ENABLED = 3;
protected static final int PROP_AUTO_EXPOSURE_DISABLED = 1;

protected UsbCamera camera;
protected CameraConfiguration configuration;
Expand All @@ -53,16 +53,6 @@ public GenericUSBCameraSettables(CameraConfiguration configuration, UsbCamera ca
}
}

if (configuration.cameraQuirks.hasQuirk(CameraQuirk.ArduOV2311)) {
// Property limits are incorrect
this.minExposure = 1;
this.maxExposure = 75;
}

if (configuration.cameraQuirks.hasQuirk(CameraQuirk.OneZeroAutoExposure)) {
PROP_AUTO_EXPOSURE_ENABLED = 0;
PROP_AUTO_EXPOSURE_DISABLED = 1;
}
}

protected void setUpExposureProperties() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.photonvision.vision.camera.USBCameras;

import edu.wpi.first.cscore.UsbCamera;


import org.photonvision.common.configuration.CameraConfiguration;

public class PsEyeCameraSettables extends GenericUSBCameraSettables {

public PsEyeCameraSettables(CameraConfiguration configuration, UsbCamera camera) {
super(configuration, camera);
}

public void setAutoExposure(boolean cameraAutoExposure) {
logger.debug("Setting auto exposure to " + cameraAutoExposure);

// PS Eye uses inverted 1=Disabled, 0=Enabled for auto exposure
if (!cameraAutoExposure) {
autoExposureProp.set(1);

// Most cameras leave exposure time absolute at the last value
// from their auto exposure algorithm.
// Set it back to the exposure slider value
setExposureRaw(this.lastExposureRaw);

} else {
autoExposureProp.set(0);
}
}

public void setAllCamDefaults() {
// Common settings for all cameras to attempt to get their image
// as close as possible to what we want for image processing
softSet("raw_hue", 0);
softSet("raw_contrast", 32);
softSet("raw_saturation", 100);
softSet("raw_hue", -10);
softSet("raw_sharpness", 0);
softSet("white_balance_automatic", 0);
softSet("gain_automatic", 0);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,20 @@ private GenericUSBCameraSettables createSettables(CameraConfiguration config, Us

GenericUSBCameraSettables settables;

if (quirks.hasQuirk(CameraQuirk.LifeCam)) {
if (quirks.hasQuirk(CameraQuirk.LifeCamControls)) {
if(RuntimeDetector.isWindows()){
logger.debug("Using Microsoft Lifecam 3000 Windows-Specific Settables");
settables = new LifeCam3kWindowsCameraSettables(config, camera);
} else {
logger.debug("Using Microsoft Lifecam 3000 Settables");
settables = new LifeCam3kCameraSettables(config, camera);
}

}else if (quirks.hasQuirk(CameraQuirk.PsEyeControls)){
logger.debug("Using PlayStation Eye Camera Settables");
settables = new PsEyeCameraSettables(config, camera);
}else if (quirks.hasQuirk(CameraQuirk.ArduOV2311Controls)){
logger.debug("Using Arducam OV2311 Settables");
settables = new ArduOV2311CameraSettables(config, camera);
} else {
logger.debug("Using Generic USB Cam Settables");
settables = new GenericUSBCameraSettables(config, camera);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ps3EyeTest() {
HashMap<CameraQuirk, Boolean> ps3EyeQuirks = new HashMap<>();
ps3EyeQuirks.put(CameraQuirk.Gain, true);
ps3EyeQuirks.put(CameraQuirk.FPSCap100, true);
ps3EyeQuirks.put(CameraQuirk.OneZeroAutoExposure, true);
ps3EyeQuirks.put(CameraQuirk.PsEyeControls, true);
for (var q : CameraQuirk.values()) {
ps3EyeQuirks.putIfAbsent(q, false);
}
Expand Down

0 comments on commit e5c9cdf

Please sign in to comment.