use of georegression.geometry.UtilPoint2D_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;
DogArray_I32 bestIndexes = new DogArray_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);
}
}
for (int i = 0; i < bestIndexes.size(); i++) {
selected.add(bestIndexes.get(i));
}
}
use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.
the class DetectUserActions method isAtLocation.
public boolean isAtLocation(double x, double y) {
double centerX = 0, centerY = 0;
for (int i = 0; i < points.size(); i++) {
Point2D_F64 p = points.points.get(i).p;
centerX += p.x;
centerY += p.y;
}
centerX /= points.size();
centerY /= points.size();
double distance = UtilPoint2D_F64.distanceSq(centerX, centerY, x, y);
return distance <= thresholdDistance * 4;
}
use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.
the class TestAssociateImageDistanceEuclideanSq method checkDistance.
@Test
void checkDistance() {
var alg = new AssociateImageDistanceEuclideanSq();
alg.setSource(-1, new Point2D_F64(5, 7));
double expected = UtilPoint2D_F64.distanceSq(5, 7, 10, 1.5);
assertEquals(expected, alg.distance(-1, new Point2D_F64(10, 1.5)));
}
use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.
the class TestLlahOperations method findNeighbors.
/**
* Sees if all the neighbors are found for the specified point. The specified point should not be
* included in the neighbor list
*/
@Test
void findNeighbors() {
LlahOperations llahOps = createLlahOps(LlahInvariant.AFFINE);
List<Point2D_F64> list = UtilPoint2D_F64.random(-1, 1, 20, rand);
List<Point2D_F64> expected = new ArrayList<>();
llahOps.nn.setPoints(list, false);
Point2D_F64 target = list.get(10);
var distances = new double[list.size()];
for (int i = 0; i < list.size(); i++) {
expected.add(list.get(i));
distances[i] = target.distance(list.get(i));
}
new QuickSort_F64().sort(distances, list.size(), expected);
llahOps.findNeighbors(target);
for (int i = 0; i < neighborsN; i++) {
assertTrue(llahOps.neighbors.contains(expected.get(i + 1)));
}
}
use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.
the class TestUchiyaMarkerTracker method sequence_Easy.
/**
* Give it an image sequence and see if it can track the target. Only translation
*/
@Test
void sequence_Easy() {
int targetID = 2;
List<Point2D_F64> dots = documents.get(targetID);
UchiyaMarkerTracker tracker = createTracker();
for (var doc : documents) {
tracker.llahOps.createDocument(doc);
}
var prevMean = new Point2D_F64();
var currMean = new Point2D_F64();
for (int frame = 0; frame < 10; frame++) {
List<Point2D_F64> copied = new ArrayList<>();
var affine = new Affine2D_F64(1, 0, 0, 1, frame * 5, frame);
for (int i = 0; i < dots.size(); i++) {
Point2D_F64 c = new Point2D_F64();
AffinePointOps_F64.transform(affine, dots.get(i), c);
copied.add(c);
}
tracker.process(copied);
DogArray<UchiyaMarkerTracker.Track> tracks = tracker.getCurrentTracks();
assertEquals(1, tracks.size);
UchiyaMarkerTracker.Track t = tracks.get(0);
assertEquals(targetID, t.globalDoc.documentID);
// Make sure the track is moving in the expected way
UtilPoint2D_F64.mean(t.predicted.toList(), currMean);
if (frame > 0) {
assertEquals(5.0, currMean.x - prevMean.x, 0.5);
}
prevMean.setTo(currMean);
}
}
Aggregations