Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions photon-client/src/components/dashboard/tabs/InputTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ const interactiveCols = computed(() =>
(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ cameraWhiteBalanceTemp: args }, false)
"
/>
<pv-slider
v-model="useCameraSettingsStore().currentPipelineSettings.cameraSaturation"
label="Saturation Temperature"
:min="useCameraSettingsStore().minSaturation"
:max="useCameraSettingsStore().maxSaturation"
:slider-cols="interactiveCols"
@update:modelValue="
(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ cameraSaturation: args }, false)
"
/>
<pv-switch
v-model="useCameraSettingsStore().currentPipelineSettings.blockForFrames"
:disabled="!useCameraSettingsStore().currentCameraSettings.matchedCameraInfo.PVUsbCameraInfo"
Expand Down
8 changes: 8 additions & 0 deletions photon-client/src/stores/settings/CameraSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
maxExposureRaw(): number {
return this.currentCameraSettings.maxExposureRaw;
},
minSaturation(): number {
return this.currentCameraSettings.minSaturation;
},
maxSaturation(): number {
return this.currentCameraSettings.maxSaturation;
},
minWhiteBalanceTemp(): number {
return this.currentCameraSettings.minWhiteBalanceTemp;
},
Expand Down Expand Up @@ -137,6 +143,8 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
isCSICamera: d.isCSICamera,
minExposureRaw: d.minExposureRaw,
maxExposureRaw: d.maxExposureRaw,
minSaturation: d.minSaturation,
maxSaturation: d.maxSaturation,
pipelineNicknames: d.pipelineNicknames,
currentPipelineIndex: d.currentPipelineIndex,
pipelineSettings: d.currentPipelineSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public static class FileSourceSettables extends VisionSourceSettables {
@Override
public void setExposureRaw(double exposureRaw) {}

@Override
public void setSaturation(double saturation) {}

public void setAutoExposure(boolean cameraAutoExposure) {}

@Override
Expand Down Expand Up @@ -151,6 +154,16 @@ public double getMaxExposureRaw() {
return 100f;
}

@Override
public double getMinSaturation() {
return 1f;
}

@Override
public double getMaxSaturation() {
return 100f;
}

@Override
public void setAutoWhiteBalance(boolean autowb) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ public class GenericUSBCameraSettables extends VisionSourceSettables {
protected VideoProperty autoExposureProp = null;
protected VideoProperty wbTempProp = null;

protected VideoProperty saturationProp = null;

protected double minExposure = 1;
protected double maxExposure = 80000;

protected double minSaturation = 1;
protected double maxSaturation = 80000; // TODO is this sane?

protected double minWhiteBalanceTemp = 1;
protected double maxWhiteBalanceTemp = 4000;
protected int lastWhiteBalanceTemp = 4000;
Expand Down Expand Up @@ -107,6 +112,19 @@ protected void setUpExposureProperties() {
}
}

protected void setUpSaturationProperty() {
var satProp = findProperty("V4L2_CID_SATURATION", "saturation");

if (satProp.isEmpty()) {
logger.warn("Could not find saturation property");
return;
} else {
saturationProp = satProp.get();
this.minSaturation = saturationProp.getMin();
this.maxSaturation = saturationProp.getMax();
}
}

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
Expand Down Expand Up @@ -221,6 +239,38 @@ public double getMaxExposureRaw() {
return maxExposure;
}

@Override
public double getMinSaturation() {
return minSaturation;
}

@Override
public double getMaxSaturation() {
return maxSaturation;
}

@Override
public void setSaturation(double saturation) {
if (saturation >= 0.0) {
try {
int propVal = (int) MathUtil.clamp(saturation, minSaturation, maxSaturation);

logger.debug(
"Setting property "
+ saturationProp.getName()
+ " to "
+ propVal
+ " (user requested "
+ saturation
+ ")");

saturationProp.set(propVal);
} catch (VideoException e) {
logger.error("Failed to set camera saturation!", e);
}
}
}

@Override
public void setExposureRaw(double exposureRaw) {
if (exposureRaw >= 0.0) {
Expand Down Expand Up @@ -406,6 +456,7 @@ public void onCameraConnected() {
// modes
setUpExposureProperties();
setUpWhiteBalanceProperties();
setUpSaturationProperty();
cacheVideoModes();

setAllCamDefaults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public void setAutoExposure(boolean cameraAutoExposure) {
}
}

@Override
public void setSaturation(double saturation) {
// TODO need to implement this on JNI side as well
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can leave this todo/issue open, and only support USB cameras?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised I have photon bench access so I can test this now. I will test this on like Tuesday or Wednesday

}

@Override
public void setExposureRaw(double exposureRaw) {
logger.debug("Setting exposure to " + exposureRaw);
Expand Down Expand Up @@ -255,6 +260,16 @@ public LibCameraJNI.SensorModel getModel() {
return sensorModel;
}

@Override
public double getMinSaturation() {
return 0;
}

@Override
public double getMaxSaturation() {
return 0;
}

@Override
public double getMinExposureRaw() {
return this.minExposure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public void onCameraConnected() {
cameraPropertiesCached = true;
}

public abstract void setSaturation(double saturation);

public abstract double getMinSaturation();

public abstract double getMaxSaturation();

public abstract void setExposureRaw(double exposureRaw);

public abstract double getMinExposureRaw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ public double getMaxExposureRaw() {
return 1234;
}

@Override
public void setSaturation(double saturation) {}

@Override
public double getMinSaturation() {
return 1;
}

@Override
public double getMaxSaturation() {
return 1234;
}

@Override
public void setAutoWhiteBalance(boolean autowb) {}

Expand Down
Loading