Save calibration data and show preliminary GUI (#1078)

* Serialize all calibration data

* Run lint

* typing nit

* fix code

* move these tables around some

* Add cool formatting

* add request to get snapshots by resolution and camera

* re-enable all resolutions

* add wip so i can change computers (SQUASH ME AND KILL ME AHHHH)

* Get everything working but viewing snapshots

* Update RequestHandler.java

* Update CameraCalibrationInfoCard.vue

* Update CameraCalibrationInfoCard.vue

* add observation viewer

* round

* fix illiegal import

* Swap to PNG and serialize insolution

* move import/export buttons TO THE TOP

* Update WebsocketDataTypes.ts

* Add snapshotname to observation

* Refactor to serialize snapshot image itself

* Run lint

* Use new base64 image data in info card

* Update SettingTypes.ts

* Create calibration json -> mrcal converter script

* Update calibrationUtils.py

* Fix calibrate NPEs in teest

* Run lint

* Always run cornersubpix

* Update CameraCalibrationInfoCard.vue

Update CameraCalibrationInfoCard.vue

* Update OpenCVHelp.java

* Update OpenCVHelp.java

* Replace test mode camera JSONs

* Run wpiformat

* Revert intrinsics but keep other data

* Remove misc comments

* Rename JsonMat->JsonImageMat and add calobject_warp

* Update Server.java

* Rename cameraExtrinsics to distCoeffs

* fix typing issues

* use util methods

* Formatting fixes

* fix styling

* move to devTools

* remove unneeded or unused imports

* Remove fixed-right css

If its really that big of a deal, we can add it back later, kind of a drag to fix rn.

* Create util method

* Remove extra legacy calibration things

---------

Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
This commit is contained in:
Matt
2024-01-03 14:32:04 -07:00
committed by GitHub
parent e685334baa
commit 7f09f9e4f5
43 changed files with 1247 additions and 396 deletions

View File

@@ -1,3 +1,26 @@
export interface Quaternion {
X: number;
Y: number;
Z: number;
W: number;
}
export interface Translation3d {
x: number;
y: number;
z: number;
}
export interface Rotation3d {
quaternion: Quaternion;
}
export interface Pose3d {
translation: Translation3d;
rotation: Rotation3d;
}
// TODO update backend to serialize this using correct layout
export interface Transform3d {
x: number;
y: number;
@@ -11,13 +34,6 @@ export interface Transform3d {
angle_z: number;
}
export interface Quaternion {
X: number;
Y: number;
Z: number;
W: number;
}
export interface AprilTagFieldLayout {
field: {
length: number;
@@ -25,16 +41,7 @@ export interface AprilTagFieldLayout {
};
tags: {
ID: number;
pose: {
translation: {
x: number;
y: number;
z: number;
};
rotation: {
quaternion: Quaternion;
};
};
pose: Pose3d;
}[];
}

View File

@@ -1,4 +1,5 @@
import { type ActivePipelineSettings, DefaultAprilTagPipelineSettings } from "@/types/PipelineTypes";
import type { Pose3d } from "@/types/PhotonTrackingTypes";
export interface GeneralSettings {
version?: string;
@@ -77,16 +78,59 @@ export interface VideoFormat {
diagonalFOV?: number;
horizontalFOV?: number;
verticalFOV?: number;
standardDeviation?: number;
mean?: number;
}
export enum CvType {
CV_8U = 0,
CV_8S = 1,
CV_16U = 2,
CV_16S = 3,
CV_32S = 4,
CV_32F = 5,
CV_64F = 6,
CV_16F = 7
}
export interface JsonMatOfDouble {
rows: number;
cols: number;
type: CvType;
data: number[];
}
export interface JsonImageMat {
rows: number;
cols: number;
type: CvType;
data: string; // base64 encoded
}
export interface CvPoint3 {
x: number;
y: number;
z: number;
}
export interface CvPoint {
x: number;
y: number;
}
export interface BoardObservation {
locationInObjectSpace: CvPoint3[];
locationInImageSpace: CvPoint[];
reprojectionErrors: CvPoint[];
optimisedCameraToObject: Pose3d;
includeObservationInCalibration: boolean;
snapshotName: string;
snapshotData: JsonImageMat;
}
export interface CameraCalibrationResult {
resolution: Resolution;
distCoeffs: number[];
standardDeviation: number;
perViewErrors: number[] | null;
intrinsics: number[];
cameraIntrinsics: JsonMatOfDouble;
distCoeffs: JsonMatOfDouble;
observations: BoardObservation[];
}
export interface ConfigurableCameraSettings {
@@ -95,6 +139,7 @@ export interface ConfigurableCameraSettings {
export interface CameraSettings {
nickname: string;
uniqueName: string;
fov: {
value: number;
@@ -117,6 +162,7 @@ export interface CameraSettings {
export const PlaceholderCameraSettings: CameraSettings = {
nickname: "Placeholder Camera",
uniqueName: "Placeholder Name",
fov: {
value: 70,
managedByVendor: true
@@ -142,7 +188,45 @@ export const PlaceholderCameraSettings: CameraSettings = {
pixelFormat: "RGB"
}
],
completeCalibrations: [],
completeCalibrations: [
{
resolution: { width: 1920, height: 1080 },
cameraIntrinsics: {
rows: 1,
cols: 1,
type: 1,
data: [1, 2, 3, 4, 5, 6, 7, 8, 9]
},
distCoeffs: {
rows: 1,
cols: 1,
type: 1,
data: [10, 11, 12, 13]
},
observations: [
{
locationInImageSpace: [
{ x: 100, y: 100 },
{ x: 210, y: 100 },
{ x: 320, y: 101 }
],
locationInObjectSpace: [{ x: 0, y: 0, z: 0 }],
optimisedCameraToObject: {
translation: { x: 1, y: 2, z: 3 },
rotation: { quaternion: { W: 1, X: 0, Y: 0, Z: 0 } }
},
reprojectionErrors: [
{ x: 1, y: 1 },
{ x: 2, y: 1 },
{ x: 3, y: 1 }
],
includeObservationInCalibration: false,
snapshotName: "img0.png",
snapshotData: { rows: 480, cols: 640, type: CvType.CV_8U, data: "" }
}
]
}
],
pipelineNicknames: ["Placeholder Pipeline"],
lastPipelineIndex: 0,
currentPipelineIndex: 0,

View File

@@ -1,4 +1,11 @@
import type { GeneralSettings, LightingSettings, LogLevel, MetricData, NetworkSettings } from "@/types/SettingTypes";
import type {
CameraCalibrationResult,
GeneralSettings,
LightingSettings,
LogLevel,
MetricData,
NetworkSettings
} from "@/types/SettingTypes";
import type { ActivePipelineSettings } from "@/types/PipelineTypes";
import type { AprilTagFieldLayout, PipelineResult } from "@/types/PhotonTrackingTypes";
@@ -20,16 +27,6 @@ export interface WebsocketNumberPair {
second: number;
}
export interface WebsocketCompleteCalib {
distCoeffs: number[];
height: number;
width: number;
standardDeviation: number;
// perViewErrors not set in test mode
perViewErrors: number[] | null;
intrinsics: number[];
}
export type WebsocketVideoFormat = Record<
number,
{
@@ -47,7 +44,7 @@ export type WebsocketVideoFormat = Record<
>;
export interface WebsocketCameraSettingsUpdate {
calibrations: WebsocketCompleteCalib[];
calibrations: CameraCalibrationResult[];
currentPipelineIndex: number;
currentPipelineSettings: ActivePipelineSettings;
fov: number;
@@ -55,6 +52,7 @@ export interface WebsocketCameraSettingsUpdate {
isFovConfigurable: boolean;
isCSICamera: boolean;
nickname: string;
uniqueName: string;
outputStreamPort: number;
pipelineNicknames: string[];
videoFormatList: WebsocketVideoFormat;