use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldDetection method computeTemplateConfidence.
@Test
void computeTemplateConfidence() {
TldDetection<GrayU8> alg = new TldDetection<>();
alg.config = new ConfigTld();
alg.config.confidenceThresholdUpper = 0.6;
alg.template = new HelperTemplate();
for (int i = 0; i < 4; i++) {
alg.fernRegions.add(new ImageRectangle(i, i, i, i));
}
alg.computeTemplateConfidence();
assertEquals(3, alg.candidateDetections.size());
for (int i = 0; i < 3; i++) {
TldRegion r = alg.candidateDetections.get(i);
assertEquals(0, r.connections);
assertTrue(r.confidence > 0.6);
assertTrue(r.rect.x0 != 0);
}
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldDetection method selectBestRegionsFern_larger.
/**
* See if the case where there are more than the maximum number of regions is handled correctly
*/
@Test
void selectBestRegionsFern_larger() {
TldDetection<GrayU8> alg = new TldDetection<>();
alg.config = new ConfigTld();
alg.config.maximumCascadeConsider = 20;
// all 10 should be accepted
for (int i = 0; i < 30; i++) {
alg.fernInfo.grow();
alg.fernInfo.get(i).r = new ImageRectangle(i, i, i, i);
alg.fernInfo.get(i).sumP = 50 - i;
alg.fernInfo.get(i).sumN = 6;
}
alg.selectBestRegionsFern(200, 200);
assertEquals(20, alg.fernRegions.size());
// should contain all the best ones
for (int i = 0; i < 20; i++) {
assertTrue(alg.fernRegions.contains(alg.fernInfo.get(i).r));
}
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldTemplateMatching method reset.
@Test
void reset() {
TldTemplateMatching alg = new TldTemplateMatching(interpolate);
alg.setImage(input);
alg.addDescriptor(true, new ImageRectangle(10, 12, 45, 22));
alg.addDescriptor(false, new ImageRectangle(23, 12, 55, 22));
assertEquals(1, alg.getTemplatePositive().size());
assertEquals(1, alg.getTemplateNegative().size());
alg.reset();
assertEquals(0, alg.getTemplatePositive().size());
assertEquals(0, alg.getTemplateNegative().size());
assertEquals(2, alg.unused.size());
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldTemplateMatching method computeConfidence.
@Test
void computeConfidence() {
TldTemplateMatching alg = new TldTemplateMatching(interpolate);
alg.setImage(input);
alg.addDescriptor(true, new ImageRectangle(2, 3, 17, 18));
alg.addDescriptor(false, new ImageRectangle(20, 32, 40, 60));
assertEquals(1, alg.computeConfidence(new ImageRectangle(2, 3, 17, 18)), 1e-8);
assertEquals(0, alg.computeConfidence(new ImageRectangle(20, 32, 40, 60)), 1e-8);
double found = alg.computeConfidence(new ImageRectangle(14, 30, 20, 50));
assertTrue(found >= 0 && found <= 1);
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldVarianceFilter method selectThreshold.
@Test
void selectThreshold() {
GrayU8 image = new GrayU8(50, 80);
ImageMiscOps.fillUniform(image, rand, 0, 200);
TldVarianceFilter alg = new TldVarianceFilter(GrayU8.class);
alg.setImage(image);
alg.selectThreshold(new ImageRectangle(10, 8, 21, 33));
double found = alg.getThresholdLower();
double expected = computeVariance(image, 10, 8, 21, 33) / 2.0;
assertEquals(expected, found, 1e-8);
}
Aggregations