use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class AssociationPanel method setAssociation.
public synchronized void setAssociation(List<AssociatedPair> matches) {
List<Point2D_F64> leftPts = new ArrayList<>();
List<Point2D_F64> rightPts = new ArrayList<>();
for (AssociatedPair p : matches) {
leftPts.add(p.p1);
rightPts.add(p.p2);
}
setLocation(leftPts, rightPts);
assocLeft = new int[leftPts.size()];
assocRight = new int[rightPts.size()];
for (int i = 0; i < assocLeft.length; i++) {
assocLeft[i] = i;
assocRight[i] = i;
}
Random rand = new Random(234);
colors = new Color[leftPts.size()];
for (int i = 0; i < colors.length; i++) {
colors[i] = new Color(rand.nextInt() | 0xFF000000);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class AssociationPanel method drawAllFeatures.
private void drawAllFeatures(Graphics2D g2, double scaleLeft, double scaleRight, int rightX) {
if (assocLeft == null || rightPts == null || leftPts == null)
return;
for (int i = 0; i < assocLeft.length; i++) {
if (assocLeft[i] == -1)
continue;
Point2D_F64 l = leftPts.get(i);
Point2D_F64 r = rightPts.get(assocLeft[i]);
Color color = colors[i];
drawAssociation(g2, scaleLeft, scaleRight, rightX, l, r, color);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class AssociationScorePanel method drawPoints.
private void drawPoints(Graphics2D g2, List<Point2D_F64> points, int startX, int startY, double scale) {
for (Point2D_F64 p : points) {
int x1 = (int) (scale * p.x) + startX;
int y1 = (int) (scale * p.y) + startY;
VisualizeFeatures.drawPoint(g2, x1, y1, Color.BLUE);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class AssociationScorePanel method drawDistribution.
/**
* Visualizes score distribution. Larger circles mean its closer to the best
* fit score.
*/
private void drawDistribution(Graphics2D g2, List<Point2D_F64> candidates, int offX, int offY, double scale) {
findStatistics();
// draw all the features, adjusting their size based on the first score
g2.setColor(Color.RED);
g2.setStroke(new BasicStroke(3));
double normalizer;
if (scorer.getScoreType().isZeroBest())
normalizer = best * containmentFraction;
else
normalizer = Math.abs(best) * (Math.exp(-1.0 / containmentFraction));
for (int i = 0; i < candidates.size(); i++) {
Point2D_F64 p = candidates.get(i);
double s = associationScore[i];
// scale the circle based on how bad it is
double ratio = 1 - Math.abs(s - best) / normalizer;
if (ratio < 0)
continue;
int r = maxCircleRadius - (int) (maxCircleRadius * ratio);
if (r > 0) {
int x = (int) (p.x * scale + offX);
int y = (int) (p.y * scale + offY);
g2.drawOval(x - r, y - r, r * 2 + 1, r * 2 + 1);
}
}
// draw the best feature
g2.setColor(Color.GREEN);
g2.setStroke(new BasicStroke(10));
int w = maxCircleRadius * 2 + 1;
Point2D_F64 p = candidates.get(indexBest);
int x = (int) (p.x * scale + offX);
int y = (int) (p.y * scale + offY);
g2.drawOval(x - maxCircleRadius, y - maxCircleRadius, w, w);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class CompareTwoImagePanel method findBestPoints.
private void findBestPoints(int x, int y, List<Point2D_F64> pts, List<Integer> selected) {
double bestDist = clickDistance * clickDistance;
GrowQueue_I32 bestIndexes = new GrowQueue_I32(20);
for (int i = 0; i < pts.size(); i++) {
if (!isValidPoint(i))
continue;
Point2D_F64 p = pts.get(i);
double d = UtilPoint2D_F64.distanceSq(p.x, p.y, x, y);
if (d < bestDist) {
bestDist = d;
bestIndexes.reset();
bestIndexes.add(i);
} else if (Math.abs(d - bestDist) < 0.01) {
bestIndexes.add(i);
}
}
if (bestIndexes.size() > 0) {
int indexRight = bestIndexes.get(0);
}
for (int i = 0; i < bestIndexes.size(); i++) {
selected.add(bestIndexes.get(i));
}
}
Aggregations