use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class HysteresisEdgeTracePoints method addFirstSegment.
/**
* Starts a new segment at the first point in the contour
*/
private void addFirstSegment(int x, int y) {
Point2D_I32 p = queuePoints.grow();
p.set(x, y);
EdgeSegment s = new EdgeSegment();
s.points.add(p);
s.index = 0;
s.parent = s.parentPixel = -1;
e.segments.add(s);
open.add(s);
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class HysteresisEdgeTracePoints method check.
/**
* Checks to see if the given coordinate is above the lower threshold. If it is the point will be
* added to the current segment or be the start of a new segment.
*
* @param parent The edge segment which is being checked
* @param match Has a match to the current segment already been found?
* @return true if a match was found at this point
*/
private boolean check(int x, int y, EdgeSegment parent, boolean match) {
if (intensity.isInBounds(x, y)) {
int index = intensity.getIndex(x, y);
if (intensity.data[index] >= lower) {
intensity.data[index] = MARK_TRAVERSED;
if (!match) {
Point2D_I32 p = queuePoints.grow();
p.set(x, y);
parent.points.add(p);
} else {
// a match was found so it can't just be added to the current edge
startNewSegment(x, y, parent);
}
return true;
}
}
return false;
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestDescribePointBriefSO method testManualCheck.
/**
* Compute the BRIEF descriptor manually and see if it gets the same answer
*/
@Test
public void testManualCheck() {
GrayF32 input = createImage(width, height);
GrayF32 blurred = input.createNew(width, height);
filterBlur.process(input, blurred);
GImageGray a = FactoryGImageGray.wrap(blurred);
DescribePointBriefSO<GrayF32> alg = createAlg();
alg.setImage(input);
int c_x = input.width / 2;
int c_y = input.height / 2;
TupleDesc_B desc = alg.createFeature();
alg.process(c_x, c_y, 0, briefRadius, desc);
double s = briefRadius / BoofDefaults.BRIEF_SCALE_TO_RADIUS;
for (int i = 0; i < def.compare.length; i++) {
Point2D_I32 c = def.compare[i];
Point2D_I32 p0 = def.samplePoints[c.x];
Point2D_I32 p1 = def.samplePoints[c.y];
boolean expected = a.get((int) Math.round(c_x + p0.x * s), (int) Math.round(c_y + p0.y * s)).doubleValue() < a.get((int) Math.round(c_x + p1.x * s), (int) Math.round(c_y + p1.y * s)).doubleValue();
assertTrue(expected == desc.isBitTrue(i));
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestDescribeDenseHogFastAlg method computeDescriptor.
@Test
public void computeDescriptor() {
DescribeDenseHogFastAlg<GrayF32> helper = new DescribeDenseHogFastAlg<>(10, 8, 2, 2, 1, imageType);
helper.growCellArray(imgWidth, imgHeight);
int stride = helper.cellCols;
// manually build a simple histogram for input and manually construct the expected resulting descriptor
TupleDesc_F64 expected = new TupleDesc_F64(40);
setHistogram(helper.cells[2].histogram, 2, 3, expected.value, 0);
setHistogram(helper.cells[3].histogram, 2, 3, expected.value, 10);
setHistogram(helper.cells[stride + 2].histogram, 5, 0, expected.value, 20);
setHistogram(helper.cells[stride + 3].histogram, 7, 8, expected.value, 30);
DescribeSiftCommon.normalizeDescriptor(expected, 0.2);
helper.computeDescriptor(0, 2);
Point2D_I32 where = helper.locations.get(0);
TupleDesc_F64 found = helper.descriptions.get(0);
assertEquals(8 * 2, where.x);
assertEquals(0, where.y);
assertEquals(40, found.size());
assertTrue(DescriptorDistance.euclidean(expected, found) < 1e-8);
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class BaseTestDescribePointBinaryCompare method testManualCheck.
/**
* Compute the descriptor manually and see if it gets the same answer
*/
@Test
public void testManualCheck() {
T input = createImage(width, height);
GImageGray a = FactoryGImageGray.wrap(input);
DescribePointBinaryCompare<T> alg = createAlg(def);
alg.setImage(input);
int c_x = input.width / 2;
int c_y = input.height / 2;
TupleDesc_B desc = createFeature();
alg.process(c_x, c_y, desc);
for (int i = 0; i < def.compare.length; i++) {
Point2D_I32 c = def.compare[i];
Point2D_I32 p0 = def.samplePoints[c.x];
Point2D_I32 p1 = def.samplePoints[c.y];
boolean expected = a.get(c_x + p0.x, c_y + p0.y).doubleValue() < a.get(c_x + p1.x, c_y + p1.y).doubleValue();
assertTrue(expected == desc.isBitTrue(def.compare.length - i - 1));
}
}
Aggregations