use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class Zhang99ComputeTargetHomography method computeHomography.
/**
* Computes the homography from a list of detected grid points in the image. The
* order of the grid points is important and must follow the expected row major
* starting at the top left.
*
* @param observedPoints List of ordered detected grid points in image pixels.
* @return True if it computed a Homography and false if it failed to compute a homography matrix.
*/
public boolean computeHomography(CalibrationObservation observedPoints) {
if (observedPoints.size() < 4)
throw new IllegalArgumentException("At least 4 points needed in each set of observations. " + " Filter these first please");
List<AssociatedPair> pairs = new ArrayList<>();
for (int i = 0; i < observedPoints.size(); i++) {
int which = observedPoints.get(i).index;
Point2D_F64 obs = observedPoints.get(i);
pairs.add(new AssociatedPair(worldPoints.get(which), obs, true));
}
if (!computeHomography.process(pairs, found))
return false;
return true;
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class Zhang99OptimizationFunction method process.
public void process(Zhang99AllParam param, double[] residuals) {
int index = 0;
for (int indexView = 0; indexView < param.views.length; indexView++) {
Zhang99AllParam.View v = param.views[indexView];
ConvertRotation3D_F64.rodriguesToMatrix(v.rotation, se.getR());
se.T = v.T;
CalibrationObservation viewSet = observations.get(indexView);
for (int i = 0; i < viewSet.size(); i++) {
int gridIndex = viewSet.get(i).index;
Point2D_F64 obs = viewSet.get(i);
// Put the point in the camera's reference frame
SePointOps_F64.transform(se, grid.get(gridIndex), cameraPt);
param.getIntrinsic().project(cameraPt, pixelPt);
residuals[index++] = pixelPt.x - obs.x;
residuals[index++] = pixelPt.y - obs.y;
}
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class VisualizeShapes method drawArrowSubPixel.
public static void drawArrowSubPixel(Point2D_F64 p0, Point2D_F64 p1, Line2D.Double line, Graphics2D g2) {
drawSubPixel(p0, p1, line, g2);
double x2 = p0.x + (p1.x - p0.x) * 0.9;
double y2 = p0.y + (p1.y - p0.y) * 0.9;
double tanX = (p1.y - y2);
double tanY = (x2 - p1.x);
drawSubPixel(new Point2D_F64(x2 + tanX, y2 + tanY), p1, line, g2);
drawSubPixel(new Point2D_F64(x2 - tanX, y2 - tanY), p1, line, g2);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class VisualizeShapes method fillPolygon.
public static void fillPolygon(Polygon2D_F64 polygon, double scale, Graphics2D g2) {
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Path2D path = new Path2D.Double();
Point2D_F64 p = polygon.get(0);
path.moveTo(p.x * scale, p.y * scale);
for (int i = 1; i <= polygon.size(); i++) {
p = polygon.get(i % polygon.size());
path.lineTo(p.x * scale, p.y * scale);
}
g2.fill(path);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class GenericTestsDetectDescribeMulti method detectFeatures.
/**
* Detects features inside the image and checks to see if it is in compliance of its reported capabilities
*/
@Test
public void detectFeatures() {
DetectDescribeMulti<T, TD> alg = createDetDesc();
alg.process(image);
for (int n = 0; n < alg.getNumberOfSets(); n++) {
PointDescSet<TD> set = alg.getFeatureSet(n);
int N = set.getNumberOfFeatures();
assertTrue(N > 5);
for (int i = 0; i < N; i++) {
Point2D_F64 p = set.getLocation(i);
TD desc = set.getDescription(i);
assertTrue(desc != null);
assertTrue(p.x != 0 && p.y != 0);
assertTrue(p.x >= 0 && p.y >= 0 && p.x < image.width && p.y < image.height);
}
}
}
Aggregations