Adds support for OV9782's quirks (#1284)

The OV9782 camera has a specific exposure range, so a camera quirk for
it needs to exist. The default white balance is also pretty bad, so it
must be adjusted.

Closes #1204

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
This commit is contained in:
Gautam
2024-07-01 15:54:20 -07:00
committed by GitHub
parent e7e59ed2d4
commit 173b6d9ca8
6 changed files with 64 additions and 4 deletions

View File

@@ -41,4 +41,8 @@ public enum CameraQuirk {
ArduOV9281,
/** Dummy quirk to tell OV2311 from OV9281 */
ArduOV2311,
/*
* Camera is an arducam ov9782 which has specific exposure ranges and needs a specific white balance issue
*/
ArduOV9782
}

View File

@@ -74,6 +74,14 @@ public class QuirkyCamera {
"OV9281",
"OV9281",
CameraQuirk.ArduCamCamera,
CameraQuirk.ArduOV9281),
// Arducam OV
new QuirkyCamera(
0x0c45,
0x6366,
"OV9782",
"OV9782",
CameraQuirk.ArduCamCamera,
CameraQuirk.ArduOV9281));
public static final QuirkyCamera DefaultCamera = new QuirkyCamera(0, 0, "");

View File

@@ -69,6 +69,15 @@ public class USBCameraSource extends VisionSource {
logger.info("Quirky camera detected: " + getCameraConfiguration().cameraQuirks.baseName);
}
if (getCameraConfiguration().cameraQuirks.hasQuirk(CameraQuirk.ArduOV9782)) {
try {
// Set white balance temperature to 3500 for OV9782 camera
camera.getProperty("white_balance_temperature").set(3500);
} catch (VideoException e) {
logger.error("Failed to set white balance temperature for OV9782 camera!", e);
}
}
if (getCameraConfiguration().cameraQuirks.hasQuirk(CameraQuirk.CompletelyBroken)) {
// set some defaults, as these should never be used.
logger.info(
@@ -190,9 +199,18 @@ public class USBCameraSource extends VisionSource {
// Linux kernel bump changed names -- now called white_balance_automatic and
// white_balance_temperature
if (camera.getProperty("white_balance_automatic").getKind() != Kind.kNone) {
// 1=auto, 0=manual
camera.getProperty("white_balance_automatic").set(0);
camera.getProperty("white_balance_temperature").set(4000);
if (getCameraConfiguration().cameraQuirks.hasQuirk(CameraQuirk.ArduOV9782)) {
try {
// Set white balance temperature to 3500 for OV9782 camera
camera.getProperty("white_balance_temperature").set(3500);
} catch (VideoException e) {
logger.error("Failed to set white balance temperature for OV9782 camera!", e);
}
} else {
// 1=auto, 0=manual
camera.getProperty("white_balance_automatic").set(0);
camera.getProperty("white_balance_temperature").set(4000);
}
} else {
camera.setWhiteBalanceManual(4000); // Auto white-balance disabled, 4000K preset
}
@@ -273,6 +291,9 @@ public class USBCameraSource extends VisionSource {
} else if (getCameraConfiguration().cameraQuirks.hasQuirk(CameraQuirk.ArduOV2311)) {
propMin = 1;
propMax = 140;
} else if (getCameraConfiguration().cameraQuirks.hasQuirk(CameraQuirk.ArduOV9782)) {
propMin = 1;
propMax = 60;
}
var exposure_manual_val = MathUtils.map(Math.round(exposure), 0, 100, propMin, propMax);