From 62112cd2fd8e03ca144c47b985d23b7f67304863 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 1 Feb 2024 21:42:54 -0500 Subject: [PATCH] Reduce initial connection bandwidth (#1200) Reduces bandwidth requirements by being much lazier about how much calibration data is sent to the UI. --- .../cameras/CameraCalibrationCard.vue | 9 +- .../cameras/CameraCalibrationInfoCard.vue | 94 +++++++------------ .../stores/settings/CameraSettingsStore.ts | 17 ++++ photon-client/src/types/SettingTypes.ts | 7 +- .../configuration/PhotonConfiguration.java | 11 +-- .../dataflow/websocket/UIDataPublisher.java | 13 ++- .../vision/calibration/BoardObservation.java | 31 +++++- .../CameraCalibrationCoefficients.java | 16 +++- .../vision/calibration/JsonImageMat.java | 13 +++ .../vision/calibration/JsonMatOfDouble.java | 2 +- .../UICameraCalibrationCoefficients.java | 59 ++++++++++++ .../vision/processes/VisionModule.java | 6 +- .../server/DataSocketHandler.java | 9 +- .../photonvision/server/RequestHandler.java | 74 +++++++++++++++ .../java/org/photonvision/server/Server.java | 2 + 15 files changed, 275 insertions(+), 88 deletions(-) create mode 100644 photon-core/src/main/java/org/photonvision/vision/calibration/UICameraCalibrationCoefficients.java diff --git a/photon-client/src/components/cameras/CameraCalibrationCard.vue b/photon-client/src/components/cameras/CameraCalibrationCard.vue index ba6ca5470..29b4d2b88 100644 --- a/photon-client/src/components/cameras/CameraCalibrationCard.vue +++ b/photon-client/src/components/cameras/CameraCalibrationCard.vue @@ -25,15 +25,8 @@ const getUniqueVideoFormatsByResolution = (): VideoFormat[] => { const calib = useCameraSettingsStore().getCalibrationCoeffs(format.resolution); if (calib !== undefined) { - // Is this the right formula for RMS error? who knows! not me! - const perViewSumSquareReprojectionError = calib.observations.flatMap((it) => - it.reprojectionErrors.flatMap((it2) => [it2.x, it2.y]) - ); // For each error, square it, sum the squares, and divide by total points N - format.mean = Math.sqrt( - perViewSumSquareReprojectionError.map((it) => Math.pow(it, 2)).reduce((a, b) => a + b, 0) / - perViewSumSquareReprojectionError.length - ); + format.mean = calib.meanErrors.reduce((a, b) => a + b) / calib.meanErrors.length; format.horizontalFOV = 2 * Math.atan2(format.resolution.width / 2, calib.cameraIntrinsics.data[0]) * (180 / Math.PI); diff --git a/photon-client/src/components/cameras/CameraCalibrationInfoCard.vue b/photon-client/src/components/cameras/CameraCalibrationInfoCard.vue index 3ebc29960..39498333e 100644 --- a/photon-client/src/components/cameras/CameraCalibrationInfoCard.vue +++ b/photon-client/src/components/cameras/CameraCalibrationInfoCard.vue @@ -1,51 +1,19 @@