use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldHelperFunctions method convertRegion_F64_I32.
@Test
public void convertRegion_F64_I32() {
Rectangle2D_F64 a = new Rectangle2D_F64();
Rectangle2D_I32 b = new Rectangle2D_I32();
a.set(10, 12, 10.8, 60.9);
TldHelperFunctions.convertRegion(a, b);
assertEquals(10, b.x0);
assertEquals(12, b.y0);
assertEquals(11, b.x1);
assertEquals(61, b.y1);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldLearning method updateLearning.
@Test
public void updateLearning() {
DummyVariance variance = new DummyVariance();
DummyFern fern = new DummyFern();
DummyTemplate template = new DummyTemplate();
DummyDetection detection = new DummyDetection();
TldLearning alg = new TldLearning(rand, config, template, variance, fern, detection);
alg.updateLearning(new Rectangle2D_F64(10, 20, 30, 40));
// Check to see if the variance threshold was set
assertEquals(0, variance.calledSelect);
// There should be a positive example
assertEquals(1, fern.calledP);
assertEquals(1, template.calledP);
// several negative examples too
assertEquals(10, fern.calledN);
// only negative template for ambiguous, which there are none since I'm being lazy
assertEquals(0, template.calledN);
assertEquals(0, detection.calledDetection);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldRegionTracker method process.
/**
* Very basic test. Feeds it the same image twice and sees if it does nothing without blowing up.
*/
@Test
public void process() {
TldRegionTracker alg = createAlg();
Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 115, 125);
alg.initialize(pyramid);
assertTrue(alg.process(pyramid, rect));
assertEquals(alg.getPairs().size, 10 * 10);
assertTrue(alg.process(pyramid, rect));
assertEquals(alg.getPairs().size, 10 * 10);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestEdgeIntensityPolygon method computeEdge.
@Test
public void computeEdge() {
GrayU8 image = new GrayU8(400, 500);
int value = 200;
ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);
EdgeIntensityPolygon<GrayU8> alg = new EdgeIntensityPolygon<>(2, 2, 10, GrayU8.class);
Polygon2D_F64 polygon = new Polygon2D_F64(4);
UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);
alg.setImage(image);
assertTrue(alg.computeEdge(polygon, polygon.isCCW()));
// should be average pixel intensity inside and outside
assertEquals(200, alg.getAverageInside(), 1e-8);
assertEquals(0, alg.getAverageOutside(), 1e-8);
// see what happens if the incorrect orientation is passed in
assertTrue(alg.computeEdge(polygon, !polygon.isCCW()));
assertEquals(0, alg.getAverageInside(), 1e-8);
assertEquals(200, alg.getAverageOutside(), 1e-8);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class VisualizeTldTrackerApp method process.
public void process(final SimpleImageSequence<T> sequence) {
if (!sequence.hasNext())
throw new IllegalArgumentException("Empty sequence");
image = sequence.next();
gui.setFrame((BufferedImage) sequence.getGuiImage());
ShowImages.showWindow(gui, "TLD Tracker", true);
// tracker.initialize(image,274,159,356,292);
// gui.turnOffSelect();
paused = true;
while (paused) {
Thread.yield();
}
int totalFrames = 0;
long totalTime = 0;
while (sequence.hasNext()) {
totalFrames++;
image = sequence.next();
gui.setFrame((BufferedImage) sequence.getGuiImage());
long before = System.nanoTime();
boolean success = tracker.track(image);
long after = System.nanoTime();
totalTime += after - before;
System.out.println("FPS = " + (totalFrames) / (totalTime / 2e9));
gui.update(tracker, success);
if (!success) {
System.out.println("No rectangle found");
} else {
Rectangle2D_F64 r = tracker.getTargetRegion();
System.out.println("Target: " + r);
}
gui.repaint();
while (paused) {
Thread.yield();
}
}
System.out.println("DONE");
}
Aggregations