mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-23 01:21:40 +00:00
added calibration accuracy, calib message, calib advanced menu
This commit is contained in:
@@ -48,9 +48,21 @@
|
||||
<span>Snapshot Amount: {{snapshotAmount}}</span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div v-if="isCalibrating">
|
||||
<v-checkbox v-model="isAdvanced" label="Advanced Menu" dark/>
|
||||
<div v-if="isAdvanced">
|
||||
<CVslider name="Exposure" v-model="pipeline.exposure" :min="0" :max="100"
|
||||
@input="handleData('exposure')"/>
|
||||
<CVslider name="Brightness" v-model="pipeline.brightness" :min="0" :max="100"
|
||||
@input="handleData('brightness')"/>
|
||||
<CVslider name="Gain" v-if="pipeline.gain !== -1" v-model="pipeline.gain" :min="0" :max="100"
|
||||
@input="handleData('gain')"/>
|
||||
<CVselect name="FPS" v-model="pipeline.videoModeIndex" :list="stringFpsList" @input="changeFps"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<v-snackbar v-model="snack">
|
||||
<span>Calibration Failed</span>
|
||||
<v-snackbar v-model="snack" top :color="snackbar.color">
|
||||
<span>{{snackbar.text}}</span>
|
||||
</v-snackbar>
|
||||
</div>
|
||||
</template>
|
||||
@@ -58,12 +70,14 @@
|
||||
<script>
|
||||
import CVselect from '../../components/cv-select'
|
||||
import CVnumberinput from '../../components/cv-number-input'
|
||||
import CVslider from '../../components/cv-slider'
|
||||
|
||||
export default {
|
||||
name: 'CameraSettings',
|
||||
components: {
|
||||
CVselect,
|
||||
CVnumberinput
|
||||
CVnumberinput,
|
||||
CVslider
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -77,13 +91,24 @@
|
||||
text: "Cancel Calibration",
|
||||
color: "red"
|
||||
},
|
||||
snackbar: {
|
||||
color: "success",
|
||||
text: ""
|
||||
},
|
||||
squareSize: 1.0,
|
||||
snapshotAmount: 0,
|
||||
hasEnough: false,
|
||||
snack: false
|
||||
snack: false,
|
||||
isAdvanced: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleData(val) {
|
||||
this.handleInput(val, this.pipeline[val]);
|
||||
},
|
||||
changeFps(){
|
||||
this.handleInput('videoModeIndex', this.filteredFpsList[this.pipeline['videoModeIndex']]['actualIndex']);
|
||||
},
|
||||
sendCameraSettings() {
|
||||
const self = this;
|
||||
this.axios.post("http://" + this.$address + "/api/settings/camera", this.cameraSettings).then(
|
||||
@@ -129,9 +154,13 @@
|
||||
let connection_string = "/api/settings/endCalibration";
|
||||
let data = {};
|
||||
data['squareSize'] = this.squareSize;
|
||||
self.axios.post("http://" + this.$address + connection_string, data).then(
|
||||
function (response) {
|
||||
if (response.status === 500) {
|
||||
self.axios.post("http://" + this.$address + connection_string, data).then((response) => {
|
||||
if (response.status === 200) {
|
||||
self.snackbar = {
|
||||
color: "success",
|
||||
text: "calibration successful. \n" +
|
||||
"accuracy: " + response.data['accuracy'].toFixed(5)
|
||||
};
|
||||
self.snack = true;
|
||||
}
|
||||
self.isCalibrating = false;
|
||||
@@ -141,7 +170,19 @@
|
||||
self.cancellationModeButton.text = "Cancel Calibration";
|
||||
self.cancellationModeButton.color = "red";
|
||||
}
|
||||
);
|
||||
).catch(() => {
|
||||
self.snackbar = {
|
||||
color: "error",
|
||||
text: "calibration failed"
|
||||
};
|
||||
self.snack = true;
|
||||
self.isCalibrating = false;
|
||||
self.hasEnough = false;
|
||||
self.snapshotAmount = 0;
|
||||
self.calibrationModeButton.text = "Start Calibration";
|
||||
self.cancellationModeButton.text = "Cancel Calibration";
|
||||
self.cancellationModeButton.color = "red";
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -186,6 +227,25 @@
|
||||
return tmp_list;
|
||||
}
|
||||
},
|
||||
filteredFpsList() {
|
||||
let selectedRes = this.$store.state.resolutionList[this.resolutionIndex];
|
||||
let tmpList = [];
|
||||
for (let i in this.$store.state.resolutionList) {
|
||||
let res = JSON.parse(JSON.stringify(this.$store.state.resolutionList[i]));
|
||||
if (res.width === selectedRes.width && res.height === selectedRes.height) {
|
||||
res['actualIndex'] = parseInt(i);
|
||||
tmpList.push(res);
|
||||
}
|
||||
}
|
||||
return tmpList;
|
||||
},
|
||||
stringFpsList() {
|
||||
let tmp = [];
|
||||
for (let i of this.filteredFpsList) {
|
||||
tmp.push(i['fps']);
|
||||
}
|
||||
return tmp;
|
||||
},
|
||||
stringResolutionList: {
|
||||
get() {
|
||||
let tmp = [];
|
||||
@@ -203,7 +263,9 @@
|
||||
this.$store.commit('cameraSettings', value);
|
||||
}
|
||||
},
|
||||
|
||||
pipeline() {
|
||||
return this.$store.state.pipeline
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Calibrate3dPipeline extends CVPipeline<DriverVisionPipeline.DriverP
|
||||
private TermCriteria criteria = new TermCriteria(3, 30, 0.001); //(Imgproc.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
|
||||
|
||||
private int captureCount = 0;
|
||||
private double calibrationAccuracy = 0;
|
||||
private boolean wantsSnapshot = false;
|
||||
private double squareSizeInches;
|
||||
|
||||
@@ -129,7 +130,7 @@ public class Calibrate3dPipeline extends CVPipeline<DriverVisionPipeline.DriverP
|
||||
List<Mat> tvecs = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Calib3d.calibrateCamera(objpoints, imgpoints, imageSize, cameraMatrix, distortionCoeffs, rvecs, tvecs);
|
||||
calibrationAccuracy = Calib3d.calibrateCamera(objpoints, imgpoints, imageSize, cameraMatrix, distortionCoeffs, rvecs, tvecs);
|
||||
} catch(Exception e) {
|
||||
System.err.println("Camera calibration failed!");
|
||||
initPipeline(cameraCapture);
|
||||
@@ -162,4 +163,8 @@ public class Calibrate3dPipeline extends CVPipeline<DriverVisionPipeline.DriverP
|
||||
public int getSnapshotCount() {
|
||||
return captureCount + 1;
|
||||
}
|
||||
|
||||
public double getCalibrationAccuracy(){
|
||||
return calibrationAccuracy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,9 @@ public class RequestHandler {
|
||||
System.out.println("Finishing Cal");
|
||||
if (pipeManager.calib3dPipe.hasEnoughSnapshots()) {
|
||||
if (pipeManager.calib3dPipe.tryCalibration()) {
|
||||
HashMap<String, Double> tmp = new HashMap<String, Double>();
|
||||
tmp.put("accuracy", pipeManager.calib3dPipe.getCalibrationAccuracy());
|
||||
ctx.json(tmp);
|
||||
ctx.status(200);
|
||||
} else {
|
||||
System.err.println("CALFAIL");
|
||||
@@ -181,7 +184,7 @@ public class RequestHandler {
|
||||
}
|
||||
}
|
||||
pipeManager.setCalibrationMode(false);
|
||||
ctx.status(200);
|
||||
ctx.status(201);
|
||||
}
|
||||
|
||||
public static void onPnpModel(Context ctx) throws JsonProcessingException {
|
||||
@@ -202,7 +205,7 @@ public class RequestHandler {
|
||||
var settings = (StandardCVPipelineSettings) VisionManager.getCurrentUIVisionProcess().pipelineManager.getCurrentPipeline().settings;
|
||||
settings.targetCornerMat.fromList(pointsList);
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
ctx.status(500);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user