Skip to content

Commit

Permalink
Adds support for OV9782's quirks (#1284)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Cameron (3539) <[email protected]>
  • Loading branch information
3 people authored Jul 1, 2024
1 parent e7e59ed commit 173b6d9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
15 changes: 15 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

sphinx:
builder: html
configuration: source/conf.py
fail_on_warning: true

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
install:
- requirements: requirements.txt
12 changes: 11 additions & 1 deletion photon-client/src/components/cameras/CameraSettingsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ const arducamSelectWrapper = computed<number>({
get: () => {
if (tempSettingsStruct.value.quirksToChange.ArduOV9281) return 1;
else if (tempSettingsStruct.value.quirksToChange.ArduOV2311) return 2;
else if (tempSettingsStruct.value.quirksToChange.ArduOV9782) return 3;
else return 0;
},
set: (v) => {
switch (v) {
case 1:
tempSettingsStruct.value.quirksToChange.ArduOV9281 = true;
tempSettingsStruct.value.quirksToChange.ArduOV2311 = false;
tempSettingsStruct.value.quirksToChange.ArduOV9782 = false;
break;
case 2:
tempSettingsStruct.value.quirksToChange.ArduOV9281 = false;
tempSettingsStruct.value.quirksToChange.ArduOV2311 = true;
tempSettingsStruct.value.quirksToChange.ArduOV9782 = false;
break;
case 3:
tempSettingsStruct.value.quirksToChange.ArduOV9281 = false;
tempSettingsStruct.value.quirksToChange.ArduOV2311 = false;
tempSettingsStruct.value.quirksToChange.ArduOV9782 = true;
break;
default:
tempSettingsStruct.value.quirksToChange.ArduOV9281 = false;
tempSettingsStruct.value.quirksToChange.ArduOV2311 = false;
tempSettingsStruct.value.quirksToChange.ArduOV9782 = false;
break;
}
}
Expand Down Expand Up @@ -129,7 +138,8 @@ watchEffect(() => {
:items="[
{ name: 'None', value: 0, disabled: true },
{ name: 'OV9281', value: 1 },
{ name: 'OV2311', value: 2 }
{ name: 'OV2311', value: 2 },
{ name: 'OV9782', value: 3 }
]"
:select-cols="8"
/>
Expand Down
2 changes: 2 additions & 0 deletions photon-client/src/types/SettingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export enum ValidQuirks {
AdjustableFocus = "AdjustableFocus",
ArduOV9281 = "ArduOV9281",
ArduOV2311 = "ArduOV2311",
ArduOV9782 = "ArduOV9782",
ArduCamCamera = "ArduCamCamera",
CompletelyBroken = "CompletelyBroken",
FPSCap100 = "FPSCap100",
Expand Down Expand Up @@ -279,6 +280,7 @@ export const PlaceholderCameraSettings: CameraSettings = {
AdjustableFocus: false,
ArduOV9281: false,
ArduOV2311: false,
ArduOV9782: false,
ArduCamCamera: false,
CompletelyBroken: false,
FPSCap100: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public USBCameraSource(CameraConfiguration config) {
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(
Expand Down Expand Up @@ -190,9 +199,18 @@ public void setAutoExposure(boolean cameraAutoExposure) {
// 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
}
Expand Down Expand Up @@ -273,6 +291,9 @@ public void setExposure(double exposure) {
} 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);
Expand Down

0 comments on commit 173b6d9

Please sign in to comment.