mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Add support for removing calib coefficients (#2150)
## Description Adds the ability to remove old calibrations. This might be helpful if you have a bad calibration. closes #1262 ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --------- Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,7 @@ import org.apache.commons.io.FileUtils;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfInt;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.configuration.NetworkConfig;
|
||||
@@ -997,6 +998,46 @@ public class RequestHandler {
|
||||
ctx.status(204);
|
||||
}
|
||||
|
||||
private record CalibrationRemoveRequest(int width, int height, String cameraUniqueName) {}
|
||||
|
||||
public static void onCalibrationRemoveRequest(Context ctx) {
|
||||
try {
|
||||
CalibrationRemoveRequest request =
|
||||
kObjectMapper.readValue(ctx.body(), CalibrationRemoveRequest.class);
|
||||
|
||||
logger.info(
|
||||
"Attempting to remove calibration for camera: "
|
||||
+ request.cameraUniqueName
|
||||
+ " with a resolution of "
|
||||
+ request.width
|
||||
+ "x"
|
||||
+ request.height);
|
||||
|
||||
VisionSourceManager.getInstance()
|
||||
.vmm
|
||||
.getModule(request.cameraUniqueName)
|
||||
.removeCalibrationFromConfig(new Size(request.width, request.height));
|
||||
|
||||
ctx.status(200);
|
||||
ctx.result(
|
||||
"Successfully removed calibration for resolution: "
|
||||
+ request.width
|
||||
+ "x"
|
||||
+ request.height);
|
||||
logger.info(
|
||||
"Successfully removed calibration for resolution: "
|
||||
+ request.width
|
||||
+ "x"
|
||||
+ request.height);
|
||||
} catch (JsonProcessingException e) {
|
||||
ctx.status(400).result("Invalid JSON format");
|
||||
logger.error("Failed to process calibration removed request", e);
|
||||
} catch (Exception e) {
|
||||
ctx.status(500).result("Failed to removed calibration");
|
||||
logger.error("Unexpected error while attempting to remove calibration", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onCalibrationSnapshotRequest(Context ctx) {
|
||||
String cameraUniqueName = ctx.queryParam("cameraUniqueName");
|
||||
var width = Integer.parseInt(ctx.queryParam("width"));
|
||||
|
||||
Reference in New Issue
Block a user