use of boofcv.abst.geo.calibration.ImageResults in project BoofCV by lessthanoptimal.
the class GenericCalibrationZhang99 method optimizedParam_noisy.
void optimizedParam_noisy(double noiseMagnitude) {
for (CameraConfig config : createCamera(rand)) {
CalibInputs inputs = createInputs(config.model, 3, rand);
Zhang99Camera zhangCamera = createGenerator(config, inputs.layout);
// Add noise to the initial pinhole camera estimate
DMatrixRMaj K = cameraToK(config);
K.data[0] += (rand.nextDouble() - 0.5) * noiseMagnitude;
K.data[4] += (rand.nextDouble() - 0.5) * noiseMagnitude;
var alg = new CalibrationPlanarGridZhang99(inputs.layout, zhangCamera);
alg.convertIntoBundleStructure(inputs.worldToViews, K, inputs.homographies, inputs.observations);
assertTrue(alg.performBundleAdjustment());
// verify results using errors
List<ImageResults> errors = alg.computeErrors();
for (int i = 0; i < errors.size(); i++) {
assertEquals(0, errors.get(i).meanError, 0.01);
}
}
}
use of boofcv.abst.geo.calibration.ImageResults in project BoofCV by lessthanoptimal.
the class CalibrateMonocularPlanarApp method showStatsToUser.
/**
* Format statistics on results and add to a text panel
*/
private void showStatsToUser() {
results.safe(() -> {
double averageError = 0.0;
double maxError = 0.0;
for (int i = 0; i < results.usedImages.size(); i++) {
String image = results.imagePaths.get(results.usedImages.get(i));
ImageResults r = results.getResults(image);
averageError += r.meanError;
maxError = Math.max(maxError, r.maxError);
}
averageError /= results.usedImages.size();
String text = String.format("Reprojection Errors (px):\n\nmean=%.3f max=%.3f\n\n", averageError, maxError);
text += String.format("%-10s | %8s\n", "image", "max (px)");
for (int i = 0; i < results.usedImages.size(); i++) {
String image = results.imagePaths.get(results.usedImages.get(i));
ImageResults r = results.getResults(image);
text += String.format("%-12s %8.3f\n", new File(image).getName(), r.maxError);
}
String _text = text;
SwingUtilities.invokeLater(() -> {
configurePanel.textAreaStats.setText(_text);
// show the top where summary stats are
configurePanel.textAreaStats.setCaretPosition(0);
});
});
}
use of boofcv.abst.geo.calibration.ImageResults in project BoofCV by lessthanoptimal.
the class CalibrateMonocularPlanarApp method changeSelectedGUI.
/**
* Change which image is being displayed. Request from GUI
*/
private void changeSelectedGUI(int index) {
if (index < 0 || index >= results.imagePaths.size())
return;
BoofSwingUtil.checkGuiThread();
// Change the item selected in the list
imageListPanel.setSelected(index);
String path = results.select(() -> results.imagePaths.get(index));
BufferedImage image = UtilImageIO.loadImage(path);
if (image == null) {
System.err.println("Could not load image: " + path);
return;
}
configurePanel.setImageSize(image.getWidth(), image.getHeight());
getCalibrationPanel().setBufferedImageNoChange(image);
CalibrationObservation imageObservations = getObservationsForSelected();
ImageResults imageResults = getResultsForSelected();
if (imageObservations == null || imageResults == null)
return;
getCalibrationPanel().setResults(imageObservations, imageResults, results.allUsedObservations);
getCalibrationPanel().repaint();
}
use of boofcv.abst.geo.calibration.ImageResults in project BoofCV by lessthanoptimal.
the class CalibrateStereoPlanarApp method showStatsToUser.
/**
* Format statistics on results and add to a text panel
*/
private void showStatsToUser() {
BoofSwingUtil.checkGuiThread();
algorithms.lock();
results.lock();
try {
double averageError = 0.0;
double maxError = 0.0;
List<ImageResults> errors = algorithms.calibrator.computeErrors();
if (errors.isEmpty())
return;
for (int i = 0; i < errors.size(); i++) {
ImageResults r = errors.get(i);
averageError += r.meanError;
maxError = Math.max(maxError, r.maxError);
}
averageError /= errors.size();
String text = String.format("Reprojection Errors (px):\n\nmean=%.3f max=%.3f\n\n", averageError, maxError);
text += String.format("%-10s | %8s\n", "image", "max (px)");
for (int imageIdx = 0, i = 0; imageIdx < results.names.size(); imageIdx++) {
if (!results.used.get(imageIdx))
continue;
String imageName = results.names.get(imageIdx);
ImageResults r = errors.get(i);
text += String.format("%-12s %8.3f\n", imageName, r.maxError);
// print right image now
r = errors.get(i + 1);
text += String.format("%-12s %8.3f\n", "", r.maxError);
i += 2;
}
String _text = text;
SwingUtilities.invokeLater(() -> {
configurePanel.textAreaStats.setText(_text);
// show the top where summary stats are
configurePanel.textAreaStats.setCaretPosition(0);
});
} finally {
algorithms.unlock();
results.unlock();
}
}
use of boofcv.abst.geo.calibration.ImageResults in project BoofCV by lessthanoptimal.
the class StereoPlanarPanel method updateResultsGUI.
private synchronized void updateResultsGUI() {
if (leftResults != null && rightResults != null && selectedImage < leftResults.size()) {
ImageResults r = leftResults.get(selectedImage);
String textMean = String.format("%5.1e", r.meanError);
String textMax = String.format("%5.1e", r.maxError);
meanErrorLeft.setText(textMean);
maxErrorLeft.setText(textMax);
r = rightResults.get(selectedImage);
textMean = String.format("%5.1e", r.meanError);
textMax = String.format("%5.1e", r.maxError);
meanErrorRight.setText(textMean);
maxErrorRight.setText(textMax);
}
}
Aggregations