use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class DisplayFisheyeCalibrationPanel method renderOrder.
public static void renderOrder(Graphics2D g2, double scale, List<Point2D_F64> points) {
g2.setStroke(new BasicStroke(5));
Line2D.Double l = new Line2D.Double();
for (int i = 0, j = 1; j < points.size(); i = j, j++) {
Point2D_F64 p0 = points.get(i);
Point2D_F64 p1 = points.get(j);
double fraction = i / ((double) points.size() - 2);
// fraction = fraction * 0.8 + 0.1;
int red = (int) (0xFF * fraction) + (int) (0x00 * (1 - fraction));
int green = 0x00;
int blue = (int) (0x00 * fraction) + (int) (0xff * (1 - fraction));
int lineRGB = red << 16 | green << 8 | blue;
l.setLine(scale * p0.x, scale * p0.y, scale * p1.x, scale * p1.y);
g2.setColor(new Color(lineRGB));
g2.draw(l);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class DisplayPinholeCalibrationPanel method renderOrder.
public static void renderOrder(Graphics2D g2, double scale, List<Point2D_F64> points) {
g2.setStroke(new BasicStroke(5));
Line2D.Double l = new Line2D.Double();
for (int i = 0, j = 1; j < points.size(); i = j, j++) {
Point2D_F64 p0 = points.get(i);
Point2D_F64 p1 = points.get(j);
double fraction = i / ((double) points.size() - 2);
// fraction = fraction * 0.8 + 0.1;
int red = (int) (0xFF * fraction) + (int) (0x00 * (1 - fraction));
int green = 0x00;
int blue = (int) (0x00 * fraction) + (int) (0xff * (1 - fraction));
int lineRGB = red << 16 | green << 8 | blue;
l.setLine(scale * p0.x, scale * p0.y, scale * p1.x, scale * p1.y);
g2.setColor(new Color(lineRGB));
g2.draw(l);
}
}
use of georegression.struct.point.Point2D_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 georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class PlaneView2D method paintComponent.
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
int offsetX = getWidth() / 2;
int offsetY = getHeight() / 2;
int H = getHeight() - 1;
int r = 2;
int w = 2 * r + 1;
for (Point2D_F64 p : points.toList()) {
SePointOps_F64.transform(transform, p, a);
a.x *= scale / pixelToUnit;
a.y *= scale / pixelToUnit;
g2.fillOval(offsetX + (int) a.x, H - (offsetY + (int) a.y), w, w);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class Polygon3DSequenceViewer method renderPolygons.
private void renderPolygons(Graphics2D g2) {
for (Poly poly : polygons) {
SePointOps_F64.transform(worldToCamera, poly.pts[0], p1);
GeometryMath_F64.mult(K, p1, x1);
// don't render what's behind the camera
if (p1.z < 0)
continue;
g2.setColor(poly.color);
boolean skip = false;
for (int i = 1; i < poly.pts.length; i++) {
SePointOps_F64.transform(worldToCamera, poly.pts[i], p2);
GeometryMath_F64.mult(K, p2, x2);
if (p2.z < 0) {
skip = true;
break;
}
line.setLine(x1.x, x1.y, x2.x, x2.y);
g2.draw(line);
Point3D_F64 tempP = p1;
Point2D_F64 tempX = x1;
p1 = p2;
p2 = tempP;
x1 = x2;
x2 = tempX;
}
if (!skip) {
SePointOps_F64.transform(worldToCamera, poly.pts[0], p2);
GeometryMath_F64.mult(K, p2, x2);
line.setLine(x1.x, x1.y, x2.x, x2.y);
g2.draw(line);
}
}
}
Aggregations