Skip to content

Commit

Permalink
Allow 90-deg rotation of USB cameras on Pi (#1103)
Browse files Browse the repository at this point in the history
UI would say that every camera on a Pi device was a CSI camera basically. It would not let you rotate usb cameras 90 degrees or 270 degrees because it thought that they were CSI cameras. Fixes: #1098
  • Loading branch information
BytingBulldogs3539 authored Jan 2, 2024
1 parent 96de176 commit 2a1792e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion photon-client/src/components/dashboard/tabs/InputTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const cameraRotations = computed(() =>
["Normal", "90° CW", "180°", "90° CCW"].map((v, i) => ({
name: v,
value: i,
disabled: useSettingsStore().gpuAccelerationEnabled ? [1, 3].includes(i) : false
disabled: useCameraSettingsStore().isCSICamera ? [1, 3].includes(i) : false
}))
);
Expand Down
4 changes: 4 additions & 0 deletions photon-client/src/stores/settings/CameraSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
},
isCalibrationMode(): boolean {
return this.currentCameraSettings.currentPipelineIndex == WebsocketPipelineType.Calib3d;
},
isCSICamera(): boolean {
return this.currentCameraSettings.isCSICamera;
}
},
actions: {
Expand Down Expand Up @@ -99,6 +102,7 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
perViewErrors: calib.perViewErrors,
intrinsics: calib.intrinsics
})),
isCSICamera: d.isCSICamera,
pipelineNicknames: d.pipelineNicknames,
currentPipelineIndex: d.currentPipelineIndex,
pipelineSettings: d.currentPipelineSettings
Expand Down
4 changes: 3 additions & 1 deletion photon-client/src/types/SettingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface CameraSettings {
currentPipelineIndex: number;
pipelineNicknames: string[];
pipelineSettings: ActivePipelineSettings;
isCSICamera: boolean;
}

export const PlaceholderCameraSettings: CameraSettings = {
Expand Down Expand Up @@ -145,7 +146,8 @@ export const PlaceholderCameraSettings: CameraSettings = {
pipelineNicknames: ["Placeholder Pipeline"],
lastPipelineIndex: 0,
currentPipelineIndex: 0,
pipelineSettings: DefaultAprilTagPipelineSettings
pipelineSettings: DefaultAprilTagPipelineSettings,
isCSICamera: false
};

export enum CalibrationBoardTypes {
Expand Down
1 change: 1 addition & 0 deletions photon-client/src/types/WebsocketDataTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface WebsocketCameraSettingsUpdate {
fov: number;
inputStreamPort: number;
isFovConfigurable: boolean;
isCSICamera: boolean;
nickname: string;
outputStreamPort: number;
pipelineNicknames: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@ public static class UICameraConfiguration {
public int inputStreamPort;
public List<HashMap<String, Object>> calibrations;
public boolean isFovConfigurable = true;
public boolean isCSICamera;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.photonvision.common.util.SerializationUtils;
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
import org.photonvision.vision.camera.CameraQuirk;
import org.photonvision.vision.camera.CameraType;
import org.photonvision.vision.camera.LibcameraGpuSource;
import org.photonvision.vision.camera.QuirkyCamera;
import org.photonvision.vision.camera.USBCameraSource;
Expand Down Expand Up @@ -498,6 +499,7 @@ public PhotonConfiguration.UICameraConfiguration toUICameraConfig() {
var ret = new PhotonConfiguration.UICameraConfiguration();

ret.fov = visionSource.getSettables().getFOV();
ret.isCSICamera = visionSource.getCameraConfiguration().cameraType == CameraType.ZeroCopyPicam;
ret.nickname = visionSource.getSettables().getConfiguration().nickname;
ret.currentPipelineSettings =
SerializationUtils.objectToHashMap(pipelineManager.getCurrentPipelineSettings());
Expand Down

0 comments on commit 2a1792e

Please sign in to comment.