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);
}
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));
}
}
}
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];
}
}
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;
}
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);
}
}
}
Aggregations