use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.
the class DisplayPinholeCalibrationPanel method drawFeatures.
private void drawFeatures(Graphics2D g2, double scale) {
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
CalibrationObservation set = features;
Point2D_F32 adj = new Point2D_F32();
if (showOrder) {
List<Point2D_F64> adjusted;
if (showUndistorted) {
adjusted = new ArrayList<>();
for (PointIndex2D_F64 p : set.points) {
remove_p_to_p.compute((float) p.x, (float) p.y, adj);
adjusted.add(new Point2D_F64(adj.x, adj.y));
}
} else {
adjusted = (List) set.points;
}
renderOrder(g2, scale, adjusted);
}
if (showPoints) {
g2.setColor(Color.BLACK);
g2.setStroke(new BasicStroke(3));
for (PointIndex2D_F64 p : set.points) {
if (showUndistorted) {
remove_p_to_p.compute((float) p.x, (float) p.y, adj);
} else {
adj.set((float) p.x, (float) p.y);
}
VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
}
g2.setStroke(new BasicStroke(1));
g2.setColor(Color.RED);
for (PointIndex2D_F64 p : set.points) {
if (showUndistorted) {
remove_p_to_p.compute((float) p.x, (float) p.y, adj);
} else {
adj.set((float) p.x, (float) p.y);
}
VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
}
}
if (showAll) {
for (CalibrationObservation l : allFeatures) {
for (PointIndex2D_F64 p : l.points) {
if (showUndistorted) {
remove_p_to_p.compute((float) p.x, (float) p.y, adj);
} else {
adj.set((float) p.x, (float) p.y);
}
VisualizeFeatures.drawPoint(g2, adj.x * scale, adj.y * scale, 2, Color.BLUE, false);
}
}
}
if (showNumbers) {
if (showUndistorted)
drawNumbers(g2, set, remove_p_to_p, scale);
else
drawNumbers(g2, set, null, scale);
}
if (showErrors && results != null) {
for (int i = 0; i < set.size(); i++) {
PointIndex2D_F64 p = set.get(i);
if (showUndistorted) {
remove_p_to_p.compute((float) p.x, (float) p.y, adj);
} else {
adj.set((float) p.x, (float) p.y);
}
double r = scale * errorScale * results.pointError[i];
if (r < 1)
continue;
g2.setStroke(new BasicStroke(4));
g2.setColor(Color.BLACK);
VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
g2.setStroke(new BasicStroke(2.5f));
g2.setColor(Color.ORANGE);
VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
}
}
}
use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.
the class CalibrationObservation method setTo.
public void setTo(CalibrationObservation obs) {
reset();
this.width = obs.width;
this.height = obs.height;
for (int i = 0; i < obs.size(); i++) {
PointIndex2D_F64 p = obs.points.get(i);
points.add(p.copy());
}
}
use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method dataNotRecycled.
/**
* Make sure new instances of calibration points are returned each time
*/
@Test
public void dataNotRecycled() {
for (Object layout : targetConfigs) {
DetectorFiducialCalibration detector = createDetector(layout);
GrayF32 original = renderEasy(layout, null);
assertTrue(detector.process(original));
CalibrationObservation found0 = detector.getDetectedPoints();
assertTrue(detector.process(original));
CalibrationObservation found1 = detector.getDetectedPoints();
assertEquals(found0.size(), found1.size());
assertTrue(found0 != found1);
for (int i = 0; i < found0.size(); i++) {
PointIndex2D_F64 p0 = found0.get(i);
for (int j = 0; j < found1.size(); j++) {
PointIndex2D_F64 p1 = found1.get(j);
assertFalse(p0 == p1);
}
}
}
}
use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.
the class ExampleDetectCalibrationPoints method main.
public static void main(String[] args) {
// load the test image
// String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
BufferedImage orig = UtilImageIO.loadImage(directory + "/left01.jpg");
GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
// To select different types of detectors add or remove comments below
DetectorFiducialCalibration detector;
// For chessboard targets, tune RADIUS parameter for your images
// detector = FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// process the image and check for failure condition
if (!detector.process(input))
throw new RuntimeException("Target detection failed!");
// Ordered observations of calibration points on the target
CalibrationObservation set = detector.getDetectedPoints();
// render and display the results
Graphics2D g2 = orig.createGraphics();
for (PointIndex2D_F64 p : set.points) VisualizeFeatures.drawPoint(g2, p.x, p.y, 3, Color.RED, true);
ShowImages.showWindow(orig, "Calibration Points", true);
}
use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.
the class CalibrationFiducialDetector method getCenter.
/**
* Returns the detection point average location. This will NOT be the same as the geometric center.
*
* @param which Fiducial's index
* @param location (output) Storage for the transform. modified.
*/
@Override
public void getCenter(int which, Point2D_F64 location) {
CalibrationObservation view = detector.getDetectedPoints();
location.set(0, 0);
for (int i = 0; i < view.size(); i++) {
PointIndex2D_F64 p = view.get(i);
location.x += p.x;
location.y += p.y;
}
location.x /= view.size();
location.y /= view.size();
}
Aggregations