Search in sources :

Example 46 with ImageRectangle

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);
    }
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 47 with ImageRectangle

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));
    }
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 48 with ImageRectangle

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());
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Test(org.junit.jupiter.api.Test)

Example 49 with ImageRectangle

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);
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Test(org.junit.jupiter.api.Test)

Example 50 with ImageRectangle

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);
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Test(org.junit.jupiter.api.Test)

Aggregations

ImageRectangle (boofcv.struct.ImageRectangle)57 Test (org.junit.jupiter.api.Test)15 GrayU8 (boofcv.struct.image.GrayU8)12 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)5 ImageGray (boofcv.struct.image.ImageGray)5 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)4 GrayS32 (boofcv.struct.image.GrayS32)4 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)3 GImageGray (boofcv.core.image.GImageGray)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 Point2D_I32 (georegression.struct.point.Point2D_I32)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)3 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)1 DogArray (org.ddogleg.struct.DogArray)1 GrowQueue_F64 (org.ddogleg.struct.GrowQueue_F64)1