use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.
the class AssistedCalibration method handleDetermineSize.
private void handleDetermineSize(boolean detected) {
String message = "Determine Scale: Hold target in view and center";
if (detected) {
double stationaryTime = actions.getStationaryTime();
CalibrationObservation points = detector.getDetectedPoints();
view.getQuadFocus(points, focusQuad);
double top = focusQuad.get(0).distance(focusQuad.get(1));
double right = focusQuad.get(1).distance(focusQuad.get(2));
double bottom = focusQuad.get(2).distance(focusQuad.get(3));
double left = focusQuad.get(3).distance(focusQuad.get(0));
double ratioHorizontal = Math.min(top, bottom) / Math.max(top, bottom);
double ratioVertical = Math.min(left, right) / Math.max(left, right);
boolean skewed = false;
if (ratioHorizontal <= CENTER_SKEW || ratioVertical <= CENTER_SKEW) {
actions.resetStationary();
skewed = true;
ratioHorizontal *= 100.0;
ratioVertical *= 100.0;
message = String.format("Straighten out. H %3d V %3d", (int) ratioHorizontal, (int) ratioVertical);
} else {
if (stationaryTime > STILL_THRESHOLD) {
actions.resetStationary();
saver.setTemplate(input, focusQuad);
gui.getInfoPanel().updateTemplate(saver.getTemplate());
actions.resetStationary();
state = State.REMOVE_DOTS;
canonicalWidth = Math.max(top, bottom);
padding = (int) (view.getBufferWidth(canonicalWidth) * 1.1);
selectMagnetLocations();
}
if (stationaryTime > DISPLAY_TIME) {
message = String.format("Hold still: %6.1f", stationaryTime);
}
}
int r = 6;
int w = 2 * r + 1;
if (skewed) {
g2.setColor(Color.BLUE);
for (int i = 0; i < points.size(); i++) {
Point2D_F64 p = points.points.get(i);
ellipse.setFrame(p.x - r, p.y - r, w, w);
g2.draw(ellipse);
}
} else {
renderCalibrationPoints(stationaryTime, points.points);
}
}
gui.setMessage(message);
}
use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method checkPointIndexIncreasingOrder.
/**
* Observations points should always be in increasing order
*/
@Test
public void checkPointIndexIncreasingOrder() {
for (Object layout : targetConfigs) {
DetectorFiducialCalibration detector = createDetector(layout);
GrayF32 original = renderEasy(layout, null);
assertTrue(detector.process(original));
CalibrationObservation found = detector.getDetectedPoints();
assertEquals(detector.getLayout().size(), found.size());
for (int i = 0; i < found.size(); i++) {
assertEquals(i, found.get(i).index);
}
}
}
use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.
the class AssistedCalibration method handleFillScreen.
private void handleFillScreen(boolean detected) {
String message = "Tint the screen!";
drawPadding();
if (detected) {
gui.getInfoPanel().updateView(saver.getCurrentView());
gui.getInfoPanel().updateFocusScore(saver.getFocusScore());
double stationaryTime = actions.getStationaryTime();
CalibrationObservation points = detector.getDetectedPoints();
view.getSidesCollision(points, sidesCollision);
view.getQuadFocus(points, focusQuad);
saver.process(input, focusQuad);
boolean resetImageSelector = true;
if (pictureTaken) {
if (stationaryTime >= STILL_THRESHOLD) {
message = "Move somewhere else";
} else {
pictureTaken = false;
}
} else if (stationaryTime >= STILL_THRESHOLD) {
saver.save();
pictureTaken = true;
message = "Move somewhere else";
captureFiducialPoints();
} else if (stationaryTime > DISPLAY_TIME) {
resetImageSelector = false;
message = String.format("Hold still: %6.1f", stationaryTime);
}
// save the images if the fiducial is being held still prior to capture
if (resetImageSelector) {
saver.clearHistory();
} else {
saver.process(input, focusQuad);
}
renderCalibrationPoints(stationaryTime, points.points);
}
renderFillPolygons();
gui.setMessage(message);
}
use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.
the class TestCalibrateMonoPlanar method createFakeObservations.
private CalibrationObservation createFakeObservations(int which) {
Se3_F64 t2c = targetToCamera.get(which);
CalibrationObservation set = new CalibrationObservation(intrinsic.width, intrinsic.height);
for (int i = 0; i < layout.size(); i++) {
Point2D_F64 p2 = layout.get(i);
// location of calibration point on the target
Point3D_F64 p3 = new Point3D_F64(p2.x, p2.y, 0);
Point3D_F64 a = SePointOps_F64.transform(t2c, p3, null);
Point2D_F64 pixel = new Point2D_F64();
normToPixel.compute(a.x / a.z, a.y / a.z, pixel);
if (pixel.x < 0 || pixel.x >= intrinsic.width - 1 || pixel.y < 0 || pixel.y >= intrinsic.height - 1)
throw new RuntimeException("Adjust test setup, bad observation");
set.add(pixel, i);
}
return set;
}
use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.
the class TestCalibrateStereoPlanar method createFakeObservations.
private CalibrationObservation createFakeObservations(int which, boolean left) {
Se3_F64 t2l = targetToLeft.get(which);
Se3_F64 t2c;
if (left) {
t2c = t2l;
} else {
t2c = new Se3_F64();
t2l.concat(leftToRight, t2c);
}
CalibrationObservation set = new CalibrationObservation(intrinsic.width, intrinsic.height);
for (int i = 0; i < layout.size(); i++) {
Point2D_F64 p2 = layout.get(i);
// location of calibration point on the target
Point3D_F64 p3 = new Point3D_F64(p2.x, p2.y, 0);
Point3D_F64 a = SePointOps_F64.transform(t2c, p3, null);
Point2D_F64 pixel = new Point2D_F64();
normToPixel.compute(a.x / a.z, a.y / a.z, pixel);
if (pixel.x < 0 || pixel.x >= intrinsic.width - 1 || pixel.y < 0 || pixel.y >= intrinsic.height - 1)
throw new RuntimeException("Adjust test setup, bad observation");
set.add(pixel, i);
}
return set;
}
Aggregations