diff --git a/photon-client/src/components/cameras/CameraCalibrationCard.vue b/photon-client/src/components/cameras/CameraCalibrationCard.vue index 59198a2213..9da83358a5 100644 --- a/photon-client/src/components/cameras/CameraCalibrationCard.vue +++ b/photon-client/src/components/cameras/CameraCalibrationCard.vue @@ -161,38 +161,7 @@ const downloadCalibBoard = () => { doc.save(`calibrationTarget-${CalibrationBoardTypes[boardType.value]}.pdf`); }; -const importCalibrationFromCalibDB = ref(); -const openCalibUploadPrompt = () => { - importCalibrationFromCalibDB.value.click(); -}; -const readImportedCalibrationFromCalibDB = () => { - const files = importCalibrationFromCalibDB.value.files; - if (files.length === 0) return; - - files[0].text().then((text) => { - useCameraSettingsStore() - .importCalibDB({ payload: text, filename: files[0].name }) - .then((response) => { - useStateStore().showSnackbarMessage({ - message: response.data.text || response.data, - color: response.status === 200 ? "success" : "error" - }); - }) - .catch((err) => { - if (err.request) { - useStateStore().showSnackbarMessage({ - message: "Error while uploading calibration file! The backend didn't respond to the upload attempt.", - color: "error" - }); - } else { - useStateStore().showSnackbarMessage({ - message: "Error while uploading calibration file!", - color: "error" - }); - } - }); - }); -}; + const isCalibrating = ref(false); const startCalibration = () => { @@ -481,8 +450,8 @@ const setSelectedVideoFormat = (format: VideoFormat) => { - - + + { Generate Board - - - mdi-upload - Import From CalibDB - - - diff --git a/photon-client/src/stores/settings/CameraSettingsStore.ts b/photon-client/src/stores/settings/CameraSettingsStore.ts index f53eb1dbd2..bf21340aa3 100644 --- a/photon-client/src/stores/settings/CameraSettingsStore.ts +++ b/photon-client/src/stores/settings/CameraSettingsStore.ts @@ -356,22 +356,7 @@ export const useCameraSettingsStore = defineStore("cameraSettings", { endPnPCalibration(cameraIndex: number = useStateStore().currentCameraIndex) { return axios.post("/calibration/end", { index: cameraIndex }); }, - /** - * Import calibration data that was computed using CalibDB. - * - * @param data Data from the uploaded CalibDB config - * @param cameraIndex the index of the camera - */ - importCalibDB( - data: { payload: string; filename: string }, - cameraIndex: number = useStateStore().currentCameraIndex - ) { - const payload = { - ...data, - cameraIndex: cameraIndex - }; - return axios.post("/calibration/importFromCalibDB", payload, { headers: { "Content-Type": "text/plain" } }); - }, + importCalibrationFromData( data: { calibration: CameraCalibrationResult }, cameraIndex: number = useStateStore().currentCameraIndex diff --git a/photon-core/src/main/java/org/photonvision/vision/calibration/CameraCalibrationCoefficients.java b/photon-core/src/main/java/org/photonvision/vision/calibration/CameraCalibrationCoefficients.java index e6b64101d9..2f1960d43c 100644 --- a/photon-core/src/main/java/org/photonvision/vision/calibration/CameraCalibrationCoefficients.java +++ b/photon-core/src/main/java/org/photonvision/vision/calibration/CameraCalibrationCoefficients.java @@ -138,51 +138,6 @@ public void release() { distCoeffs.release(); } - public static CameraCalibrationCoefficients parseFromCalibdbJson(JsonNode json) { - // camera_matrix is a row major, array of arrays - var cam_matrix = json.get("camera_matrix"); - - double[] cam_arr = - new double[] { - cam_matrix.get(0).get(0).doubleValue(), - cam_matrix.get(0).get(1).doubleValue(), - cam_matrix.get(0).get(2).doubleValue(), - cam_matrix.get(1).get(0).doubleValue(), - cam_matrix.get(1).get(1).doubleValue(), - cam_matrix.get(1).get(2).doubleValue(), - cam_matrix.get(2).get(0).doubleValue(), - cam_matrix.get(2).get(1).doubleValue(), - cam_matrix.get(2).get(2).doubleValue() - }; - - var dist_coefs = json.get("distortion_coefficients"); - - double[] dist_array = - new double[] { - dist_coefs.get(0).doubleValue(), - dist_coefs.get(1).doubleValue(), - dist_coefs.get(2).doubleValue(), - dist_coefs.get(3).doubleValue(), - dist_coefs.get(4).doubleValue(), - }; - - var cam_jsonmat = new JsonMatOfDouble(3, 3, cam_arr); - var distortion_jsonmat = new JsonMatOfDouble(1, 5, dist_array); - - var width = json.get("img_size").get(0).doubleValue(); - var height = json.get("img_size").get(1).doubleValue(); - - return new CameraCalibrationCoefficients( - new Size(width, height), - cam_jsonmat, - distortion_jsonmat, - new double[0], - List.of(), - new Size(0, 0), - 0, - CameraLensModel.LENSMODEL_OPENCV); - } - @Override public String toString() { return "CameraCalibrationCoefficients [resolution=" diff --git a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java index 1e8cf51fb3..d691d86a82 100644 --- a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java +++ b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java @@ -481,37 +481,6 @@ public static void onCalibrationEndRequest(Context ctx) { } } - public static void onCalibDBCalibrationImportRequest(Context ctx) { - var data = ctx.bodyInputStream(); - - try { - var actualObj = kObjectMapper.readTree(data); - - int cameraIndex = actualObj.get("cameraIndex").asInt(); - var payload = kObjectMapper.readTree(actualObj.get("payload").asText()); - var coeffs = CameraCalibrationCoefficients.parseFromCalibdbJson(payload); - - var uploadCalibrationEvent = - new IncomingWebSocketEvent<>( - DataChangeDestination.DCD_ACTIVEMODULE, - "calibrationUploaded", - coeffs, - cameraIndex, - null); - DataChangeService.getInstance().publishEvent(uploadCalibrationEvent); - - ctx.status(200); - ctx.result("Calibration imported successfully from CalibDB data!"); - logger.info("Calibration imported successfully from CalibDB data!"); - } catch (IOException e) { - ctx.status(400); - ctx.result( - "The Provided CalibDB data is malformed and cannot be parsed for the required fields."); - logger.error( - "The Provided CalibDB data is malformed and cannot be parsed for the required fields.", - e); - } - } public static void onDataCalibrationImportRequest(Context ctx) { try { diff --git a/photon-server/src/main/java/org/photonvision/server/Server.java b/photon-server/src/main/java/org/photonvision/server/Server.java index 143e099c98..c63146b63b 100644 --- a/photon-server/src/main/java/org/photonvision/server/Server.java +++ b/photon-server/src/main/java/org/photonvision/server/Server.java @@ -137,8 +137,6 @@ private static void start(int port) { // Calibration app.post("/api/calibration/end", RequestHandler::onCalibrationEndRequest); - app.post( - "/api/calibration/importFromCalibDB", RequestHandler::onCalibDBCalibrationImportRequest); app.post("/api/calibration/importFromData", RequestHandler::onDataCalibrationImportRequest); app.start(port);