mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-26 01:51:40 +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:
@@ -24,6 +24,7 @@ import edu.wpi.first.cscore.UsbCameraInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.opencv.core.Size;
|
||||
import org.photonvision.common.dataflow.websocket.UICameraConfiguration;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
@@ -189,6 +190,23 @@ public class CameraConfiguration {
|
||||
calibrations.add(calibration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a calibration from our list.
|
||||
*
|
||||
* @param calibration The calibration to remove
|
||||
*/
|
||||
public void removeCalibration(Size unrotatedImageSize) {
|
||||
logger.info("deleting calibration " + unrotatedImageSize);
|
||||
calibrations.stream()
|
||||
.filter(it -> it.unrotatedImageSize.equals(unrotatedImageSize))
|
||||
.findAny()
|
||||
.ifPresent(
|
||||
(it) -> {
|
||||
it.release();
|
||||
calibrations.remove(it);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* cscore will auto-reconnect to the camera path we give it. v4l does not guarantee that if i swap
|
||||
* cameras around, the same /dev/videoN ID will be assigned to that camera. So instead default to
|
||||
|
||||
@@ -680,6 +680,16 @@ public class VisionModule {
|
||||
saveAndBroadcastAll();
|
||||
}
|
||||
|
||||
public void removeCalibrationFromConfig(Size unrotatedImageSize) {
|
||||
if (unrotatedImageSize != null) {
|
||||
visionSource.getSettables().removeCalibration(unrotatedImageSize);
|
||||
} else {
|
||||
logger.error("Got null size?");
|
||||
}
|
||||
|
||||
saveAndBroadcastAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/remove quirks from the camera we're controlling
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.photonvision.vision.processes;
|
||||
|
||||
import edu.wpi.first.cscore.VideoMode;
|
||||
import java.util.HashMap;
|
||||
import org.opencv.core.Size;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
@@ -120,6 +121,11 @@ public abstract class VisionSourceSettables {
|
||||
calculateFrameStaticProps();
|
||||
}
|
||||
|
||||
public void removeCalibration(Size unrotatedImageSize) {
|
||||
configuration.removeCalibration(unrotatedImageSize);
|
||||
calculateFrameStaticProps();
|
||||
}
|
||||
|
||||
protected void calculateFrameStaticProps() {
|
||||
var videoMode = getCurrentVideoMode();
|
||||
this.frameStaticProperties =
|
||||
|
||||
Reference in New Issue
Block a user