mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Removed CalibDB (#1396)
This commit is contained in:
@@ -161,39 +161,6 @@ 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 = () => {
|
||||
useCameraSettingsStore().startPnPCalibration({
|
||||
@@ -481,8 +448,8 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col :cols="6">
|
||||
<v-row justify="center">
|
||||
<v-col cols="12">
|
||||
<v-btn
|
||||
color="accent"
|
||||
small
|
||||
@@ -495,19 +462,6 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
|
||||
<span class="calib-btn-label">Generate Board</span>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-col :cols="6">
|
||||
<v-btn color="secondary" :disabled="isCalibrating" small style="width: 100%" @click="openCalibUploadPrompt">
|
||||
<v-icon left class="calib-btn-icon"> mdi-upload </v-icon>
|
||||
<span class="calib-btn-label">Import From CalibDB</span>
|
||||
</v-btn>
|
||||
<input
|
||||
ref="importCalibrationFromCalibDB"
|
||||
type="file"
|
||||
accept=".json"
|
||||
style="display: none"
|
||||
@change="readImportedCalibrationFromCalibDB"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.opencv.core.Mat;
|
||||
@@ -138,51 +137,6 @@ public class CameraCalibrationCoefficients implements Releasable {
|
||||
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="
|
||||
|
||||
@@ -481,38 +481,6 @@ public class RequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
var data = kObjectMapper.readTree(ctx.bodyInputStream());
|
||||
|
||||
@@ -137,8 +137,6 @@ public class Server {
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user