Skip to content

Commit

Permalink
Adding settings remake implementation, innomaker camera support.
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Jul 26, 2024
1 parent 353b6d2 commit dbdd691
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 4 deletions.
1 change: 1 addition & 0 deletions photon-client/src/types/SettingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface CameraCalibrationResult {
export enum ValidQuirks {
AWBGain = "AWBGain",
AdjustableFocus = "AdjustableFocus",
InnoOV9281Controls = "InnoOV9281Controls",
ArduOV9281Controls = "ArduOV9281Controls",
ArduOV2311Controls = "ArduOV2311Controls",
ArduOV9782Controls = "ArduOV9782Controls",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ public enum CameraQuirk {
/** Camera is an arducam. This means it shares VID/PID with other arducams (ew) */
ArduCamCamera,
/**
* Camera is an arducam ov9281 which has a funky exposure issue where it is defined in v4l as
* Camera is an arducam USB ov9281 which has a funky exposure issue where it is defined in v4l as
* 1-5000 instead of 1-75
*/
ArduOV9281Controls,
/** Dummy quirk to tell OV2311 from OV9281 */
ArduOV2311Controls,
ArduOV9782Controls,
/**
* Camera is innomaker USB OV9281 which also has incorrect v4l exposure times Real range is more
* like 0-500
*/
InnoOV9281Controls,
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public boolean isVendorCamera() {
return false;
}

@Override
public void remakeSettables() {
// Nothing to do, settables for this type of VisionSource should never be remade.
return;
}

@Override
public boolean hasLEDs() {
return false; // Assume USB cameras do not have photonvision-controlled LEDs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public VisionSourceSettables getSettables() {
return settables;
}

@Override
public void remakeSettables() {
// Nothing to do, settables for this type of VisionSource should never be remade.
return;
}

/**
* On the OV5649 the actual FPS we want to request from the GPU can be higher than the FPS that we
* can do after processing. On the IMX219 these FPSes match pretty closely, except for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public class QuirkyCamera {
"OV9782",
"OV9782",
CameraQuirk.ArduCamCamera,
CameraQuirk.ArduOV9782Controls));
CameraQuirk.ArduOV9782Controls),
// Innomaker OV9281
new QuirkyCamera(
0x0c45, 0x636d, "USB Camera", "USB Camera", CameraQuirk.InnoOV9281Controls));

public static final QuirkyCamera DefaultCamera = new QuirkyCamera(0, 0, "");
public static final QuirkyCamera ZeroCopyPiCamera =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public TestSource(CameraConfiguration config) {
QuirkyCamera.getQuirkyCamera(config.usbVID, config.usbVID, config.baseName);
}

@Override
public void remakeSettables() {
// Nothing to do, settables for this type of VisionSource should never be remade.
return;
}

@Override
public FrameProvider getFrameProvider() {
return new FrameProvider() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.camera.USBCameras;

import edu.wpi.first.cscore.UsbCamera;
import org.photonvision.common.configuration.CameraConfiguration;

public class InnoOV9281CameraSettables extends GenericUSBCameraSettables {
public InnoOV9281CameraSettables(CameraConfiguration configuration, UsbCamera camera) {
super(configuration, camera);
}

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

// Property limits are incorrect
this.minExposure = 1;
this.maxExposure = 500;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public USBCameraSource(CameraConfiguration config) {
} else {
// Functional camera, set up the frame provider and configure defaults
usbFrameProvider = new USBFrameProvider(cvSink, settables);
settables.setUpExposureProperties();
settables.setAllCamDefaults();
}
}
Expand Down Expand Up @@ -128,18 +127,33 @@ private GenericUSBCameraSettables createSettables(CameraConfiguration config, Us
settables = new ArduOV2311CameraSettables(config, camera);
} else if (quirks.hasQuirk(CameraQuirk.ArduOV9281Controls)) {
logger.debug("Using Arducam OV9281 Settables");
settables = new ArduOV9281CameraSettables(config, camera);
settables = new InnoOV9281CameraSettables(config, camera);
} else if (quirks.hasQuirk(CameraQuirk.ArduOV9782Controls)) {
logger.debug("Using Arducam OV9782 Settables");
settables = new ArduOV9782CameraSettables(config, camera);
} else if (quirks.hasQuirk(CameraQuirk.InnoOV9281Controls)) {
settables = new InnoOV9281CameraSettables(config, camera);
} else {
logger.debug("Using Generic USB Cam Settables");
settables = new GenericUSBCameraSettables(config, camera);
}

settables.setUpExposureProperties();

return settables;
}

/**
* Must be called after createSettables Using the current config/camera and modified quirks, make
* a new settables
*/
public void remakeSettables() {
var oldConfig = this.cameraConfiguration;
var oldCamera = this.camera;

this.settables = createSettables(oldConfig, oldCamera);
}

private void printCameraProperaties() {
VideoProperty[] cameraProperties = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public void addCalibrationToConfig(CameraCalibrationCoefficients newCalibration)
*/
public void changeCameraQuirks(HashMap<CameraQuirk, Boolean> quirksToChange) {
visionSource.getCameraConfiguration().cameraQuirks.updateQuirks(quirksToChange);
visionSource.remakeSettables();
saveAndBroadcastAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public CameraConfiguration getCameraConfiguration() {
public abstract boolean isVendorCamera();

public abstract boolean hasLEDs();

public abstract void remakeSettables();
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public boolean isVendorCamera() {
public boolean hasLEDs() {
return false;
}

@Override
public void remakeSettables() {
return;
}
}

private static class TestSettables extends VisionSourceSettables {
Expand Down

0 comments on commit dbdd691

Please sign in to comment.