Search in sources :

Example 36 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method checkConnectNeighbor.

private void checkConnectNeighbor(int x, int y) {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(3, 3);
    grid.get(1, 1).add(new LineSegment2D_F32(0, 0, 2, 3));
    grid.get(x, y).add(new LineSegment2D_F32(2, 3, 4, 6));
    ConnectLinesGrid app = new ConnectLinesGrid(0.1, 1, 1);
    app.process(grid);
    List<LineSegment2D_F32> list = grid.createSingleList();
    assertEquals(1, list.size());
    LineSegment2D_F32 l = list.get(0);
    if (l.a.x == 4) {
        Point2D_F32 temp = l.a;
        l.a = l.b;
        l.b = temp;
    }
    assertEquals(0, l.a.x, 1e-8);
    assertEquals(0, l.a.y, 1e-8);
    assertEquals(4, l.b.x, 1e-8);
    assertEquals(6, l.b.y, 1e-8);
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 37 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class LocalWeightedHistogramRotRect method createSamplePoints.

/**
 * create the list of points in square coordinates that it will sample.  values will range
 * from -0.5 to 0.5 along each axis.
 */
protected void createSamplePoints(int numSamples) {
    for (int y = 0; y < numSamples; y++) {
        float regionY = (y / (numSamples - 1.0f) - 0.5f);
        for (int x = 0; x < numSamples; x++) {
            float regionX = (x / (numSamples - 1.0f) - 0.5f);
            samplePts.add(new Point2D_F32(regionX, regionY));
        }
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 38 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class LocalWeightedHistogramRotRect method computeHistogramInside.

/**
 * Computes the histogram quickly inside the image
 */
protected void computeHistogramInside(RectangleRotate_F32 region) {
    for (int i = 0; i < samplePts.size(); i++) {
        Point2D_F32 p = samplePts.get(i);
        squareToImageSample(p.x, p.y, region);
        interpolate.get_fast(imageX, imageY, value);
        int indexHistogram = computeHistogramBin(value);
        sampleHistIndex[i] = indexHistogram;
        histogram[indexHistogram] += weights[i];
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 39 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TldFernClassifier method computeFernValueRand.

/**
 * Computes the value of a fern after adding noise to the image being sampled.
 */
protected int computeFernValueRand(float c_x, float c_y, float rectWidth, float rectHeight, TldFernDescription fern) {
    rectWidth -= 1;
    rectHeight -= 1;
    int desc = 0;
    for (int i = 0; i < fern.pairs.length; i++) {
        Point2D_F32 p_a = fern.pairs[i].a;
        Point2D_F32 p_b = fern.pairs[i].b;
        float valA = interpolate.get_fast(c_x + p_a.x * rectWidth, c_y + p_a.y * rectHeight);
        float valB = interpolate.get_fast(c_x + p_b.x * rectWidth, c_y + p_b.y * rectHeight);
        valA += rand.nextGaussian() * fernLearnNoise;
        valB += rand.nextGaussian() * fernLearnNoise;
        desc *= 2;
        if (valA < valB) {
            desc += 1;
        }
    }
    return desc;
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 40 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestLocalWeightedHistogramRotRect method createSamplePoints.

@Test
public void createSamplePoints() {
    int w = 9;
    LocalWeightedHistogramRotRect alg = new LocalWeightedHistogramRotRect(w, 3, 12, 3, 255, null);
    int i = 0;
    for (int y = 0; y < w; y++) {
        for (int x = 0; x < w; x++, i++) {
            Point2D_F32 p = (Point2D_F32) alg.samplePts.get(i);
            float expectedX = (x / (float) (w - 1)) - 0.5f;
            float expectedY = (y / (float) (w - 1)) - 0.5f;
            assertEquals(expectedX, p.x, 1e-4f);
            assertEquals(expectedY, p.y, 1e-4f);
        }
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2