Skip to content

Commit 4e95fe8

Browse files
committed
Added WIP CameraQuirk for YOLOTag use. Auto Exposure appears to work but need to tune the manual exposure set
1 parent b82ffed commit 4e95fe8

4 files changed

Lines changed: 100 additions & 2 deletions

File tree

photon-core/src/main/java/org/photonvision/vision/camera/CameraQuirk.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ public enum CameraQuirk {
5858
ArduOV9782,
5959
/** Camera has odd exposure range, and supports gain control */
6060
See3Cam_24CUG,
61+
/** 'New Cam' */
62+
NewCam
6163
}

photon-core/src/main/java/org/photonvision/vision/camera/QuirkyCamera.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ public class QuirkyCamera {
8787
CameraQuirk.ArduOV9782Controls),
8888
// Innomaker OV9281
8989
new QuirkyCamera(
90-
0x0c45, 0x636d, "USB Camera", "Innomaker OV9281", CameraQuirk.InnoOV9281Controls));
90+
0x0c45, 0x636d, "USB Camera", "Innomaker OV9281", CameraQuirk.InnoOV9281Controls),
91+
// 'New Cam'
92+
new QuirkyCamera(
93+
0x1BCF,
94+
0x28C5,
95+
CameraQuirk.NewCam));
9196

9297
public static final QuirkyCamera DefaultCamera = new QuirkyCamera(0, 0, "");
9398
public static final QuirkyCamera ZeroCopyPiCamera =
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (C) Photon Vision.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.photonvision.vision.camera.USBCameras;
19+
20+
import edu.wpi.first.cscore.UsbCamera;
21+
import org.photonvision.common.configuration.CameraConfiguration;
22+
23+
public class NewCamSettables extends GenericUSBCameraSettables {
24+
public NewCamSettables(CameraConfiguration configuration, UsbCamera camera) {
25+
super(configuration, camera);
26+
}
27+
28+
// @Override
29+
// protected void setUpExposureProperties() {
30+
// super.setUpExposureProperties();
31+
32+
// if (exposureAbsProp != null) {
33+
// logger.debug("Exposure property: name=" + exposureAbsProp.getName()
34+
// + " min=" + exposureAbsProp.getMin()
35+
// + " max=" + exposureAbsProp.getMax());
36+
// } else {
37+
// logger.warn("No exposure property found!");
38+
// }
39+
// if (autoExposureProp != null) {
40+
// logger.debug("Auto-exposure property: name=" + autoExposureProp.getName()
41+
// + " min=" + autoExposureProp.getMin()
42+
// + " max=" + autoExposureProp.getMax());
43+
// }
44+
45+
// this.minExposure = 1;
46+
// this.maxExposure = 300;
47+
// }
48+
49+
@Override
50+
protected void setUpExposureProperties() {
51+
autoExposureProp = findProperty("exposure_auto", "auto_exposure").get();
52+
exposureAbsProp = findProperty("raw_exposure_time_absolute", "raw_exposure_absolute").get();
53+
54+
this.minExposure = exposureAbsProp.getMin();
55+
this.maxExposure = exposureAbsProp.getMax();
56+
}
57+
58+
@Override
59+
public void setAllCamDefaults() {
60+
super.setAllCamDefaults();
61+
logger.info("Setting All Cam Defaults :: NewCam");
62+
softSet("focus_automatic_continuous", 0);
63+
softSet("focus_absolute", 0);
64+
65+
softSet("power_line_frequency", 2); // Assume 60Hz USA
66+
softSet("exposure_metering_mode", 0);
67+
softSet("exposure_dynamic_framerate", 0);
68+
}
69+
70+
@Override
71+
public void setAutoExposureImpl(boolean cameraAutoExposure) {
72+
logger.info("Setting Auto Exposure :: NewCam");
73+
// softSet("focus_automatic_continuous", 0);
74+
super.setAutoExposureImpl(cameraAutoExposure);
75+
// softSet("focus_absolute", 0);
76+
}
77+
78+
@Override
79+
public void setExposureRaw(double exposureRaw) {
80+
logger.info("NewCamSettables.setExposureRaw called with " + exposureRaw);
81+
// softSet("focus_automatic_continuous", 0);
82+
super.setExposureRaw(exposureRaw);
83+
// softSet("focus_automatic_continuous", 0);
84+
// softSet("focus_absolute", 0);
85+
}
86+
}

photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/USBCameraSource.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ protected GenericUSBCameraSettables createSettables(
150150
settables = new InnoOV9281CameraSettables(config, camera);
151151
} else if (quirks.hasQuirk(CameraQuirk.See3Cam_24CUG)) {
152152
settables = new See3Cam24CUGSettables(config, camera);
153-
} else {
153+
}
154+
else if (quirks.hasQuirk(CameraQuirk.NewCam)) {
155+
logger.debug("Using 'New Camera' configuration");
156+
settables = new NewCamSettables(config, camera);
157+
}
158+
else {
154159
logger.debug("Using Generic USB Cam Settables");
155160
settables = new GenericUSBCameraSettables(config, camera);
156161
}

0 commit comments

Comments
 (0)