Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Jul 19, 2024
1 parent e5c9cdf commit 99942fd
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ public class QuirkyCamera {
new QuirkyCamera(-1, -1, "LifeCam Cinema (TM)", CameraQuirk.LifeCamControls),
// PS3Eye
new QuirkyCamera(
0x1415,
0x2000,
CameraQuirk.Gain,
CameraQuirk.FPSCap100,
CameraQuirk.PsEyeControls),
0x1415, 0x2000, CameraQuirk.Gain, CameraQuirk.FPSCap100, CameraQuirk.PsEyeControls),
// Logitech C925-e
new QuirkyCamera(0x85B, 0x46D, CameraQuirk.AdjustableFocus),
// Generic arducam. Since OV2311 can't be differentiated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/*
* 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 ArduOV2311CameraSettables extends GenericUSBCameraSettables {

public ArduOV2311CameraSettables(CameraConfiguration configuration, UsbCamera camera) {
super(configuration, camera);
}
Expand All @@ -19,5 +33,4 @@ protected void setUpExposureProperties() {
this.minExposure = 1;
this.maxExposure = 75;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* 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;
Expand Down Expand Up @@ -52,7 +69,6 @@ public GenericUSBCameraSettables(CameraConfiguration configuration, UsbCamera ca
setVideoMode(videoModes.get(0)); // fixes double FPS set
}
}

}

protected void setUpExposureProperties() {
Expand Down Expand Up @@ -144,7 +160,6 @@ public void setExposureRaw(double exposureRaw) {

this.lastExposureRaw = exposureRaw;


} catch (VideoException e) {
logger.error("Failed to set camera exposure!", e);
}
Expand Down Expand Up @@ -285,6 +300,4 @@ protected Optional<VideoProperty> findProperty(String... options) {

return Optional.ofNullable(retProp);
}


}
Original file line number Diff line number Diff line change
@@ -1,25 +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 edu.wpi.first.cscore.VideoException;


import org.photonvision.common.configuration.CameraConfiguration;
import org.photonvision.common.util.math.MathUtils;

public class LifeCam3kCameraSettables extends GenericUSBCameraSettables {

private static int[] allowableExposures = {
5, 10, 20, 39, 78, 156, 312, 625
};
private static int[] allowableExposures = {5, 10, 20, 39, 78, 156, 312, 625};

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

@Override
protected void setUpExposureProperties() {

autoExposureProp = findProperty("exposure_auto", "auto_exposure").get();
exposureAbsProp = findProperty("raw_exposure_time_absolute", "raw_exposure_absolute").get();

Expand All @@ -31,7 +42,6 @@ protected void setUpExposureProperties() {
public void setExposureRaw(double exposureRaw) {
if (exposureRaw >= 0.0) {
try {

int propVal = (int) MathUtils.limit(exposureRaw, minExposure, maxExposure);

propVal = MathUtils.quantize(propVal, allowableExposures);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* 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;
Expand All @@ -6,16 +23,14 @@
import org.photonvision.common.util.math.MathUtils;

public class LifeCam3kWindowsCameraSettables extends GenericUSBCameraSettables {

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

@Override
protected void setUpExposureProperties() {

autoExposureProp = null; // Not Used
exposureAbsProp = null; //Not Used
exposureAbsProp = null; // Not Used

// We'll fallback on cscore's implementation for windows lifecam
this.minExposure = 0;
Expand All @@ -26,10 +41,9 @@ protected void setUpExposureProperties() {
public void setExposureRaw(double exposureRaw) {
if (exposureRaw >= 0.0) {
try {

int propVal = (int) MathUtils.limit(exposureRaw, minExposure, maxExposure);

//exposureAbsProp.set(propVal);
// exposureAbsProp.set(propVal);
camera.setExposureManual(propVal);

this.lastExposureRaw = exposureRaw;
Expand All @@ -54,7 +68,7 @@ public void setAutoExposure(boolean cameraAutoExposure) {
// Most cameras leave exposure time absolute at the last value from their AE
// algorithm.
// Set it back to the exposure slider value
camera.setExposureManual( (int) this.lastExposureRaw);
camera.setExposureManual((int) this.lastExposureRaw);
} else {
camera.setExposureAuto();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/*
* 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 PsEyeCameraSettables extends GenericUSBCameraSettables {

public PsEyeCameraSettables(CameraConfiguration configuration, UsbCamera camera) {
super(configuration, camera);
}
Expand All @@ -18,7 +32,7 @@ public void setAutoExposure(boolean cameraAutoExposure) {
if (!cameraAutoExposure) {
autoExposureProp.set(1);

// Most cameras leave exposure time absolute at the last value
// 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);
Expand All @@ -31,14 +45,12 @@ public void setAutoExposure(boolean cameraAutoExposure) {
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);
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 @@ -108,23 +108,22 @@ public USBCameraSource(CameraConfiguration config) {
* @return
*/
private GenericUSBCameraSettables createSettables(CameraConfiguration config, UsbCamera camera) {

var quirks = getCameraConfiguration().cameraQuirks;

GenericUSBCameraSettables settables;

if (quirks.hasQuirk(CameraQuirk.LifeCamControls)) {
if(RuntimeDetector.isWindows()){
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)){
} else if (quirks.hasQuirk(CameraQuirk.PsEyeControls)) {
logger.debug("Using PlayStation Eye Camera Settables");
settables = new PsEyeCameraSettables(config, camera);
}else if (quirks.hasQuirk(CameraQuirk.ArduOV2311Controls)){
} else if (quirks.hasQuirk(CameraQuirk.ArduOV2311Controls)) {
logger.debug("Using Arducam OV2311 Settables");
settables = new ArduOV2311CameraSettables(config, camera);
} else {
Expand Down

0 comments on commit 99942fd

Please sign in to comment.