use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class GeneralTemplateMatchTests method checkExpected.
private void checkExpected(Point2D_I32... points) {
// I'm being lazy, update this in the future
assertFalse(alg.isBorderProcessed());
// only process the regions which are not considered the border
int x0 = alg.getBorderX0();
int y0 = alg.getBorderY0();
// solutions should be local maximums
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, -Float.MAX_VALUE, 0, true));
QueueCorner found = new QueueCorner(10);
extractor.process(alg.getIntensity(), null, null, null, found);
assertTrue(found.size >= points.length);
// search for all the expected matches
for (Point2D_I32 expected : points) {
int numMatches = 0;
for (Point2D_I16 f : found.toList()) {
double d = UtilPoint2D_F64.distance(f.x - x0, f.y - y0, expected.x, expected.y);
if (d <= 1)
numMatches++;
}
assertEquals(1, numMatches);
}
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class TestSelectNBestFeatures method testExtra.
/**
* The value of N is less than the number of features
*/
@Test
public void testExtra() {
GrayF32 intensity = new GrayF32(10, 20);
intensity.set(5, 10, -3);
intensity.set(4, 10, -3.5f);
intensity.set(5, 11, 0);
intensity.set(8, 8, 10);
QueueCorner corners = new QueueCorner();
corners.add(5, 10);
corners.add(4, 10);
corners.add(5, 11);
corners.add(8, 8);
SelectNBestFeatures alg = new SelectNBestFeatures(20);
alg.setN(3);
alg.process(intensity, corners, true);
QueueCorner found = alg.getBestCorners();
assertEquals(3, found.size);
assertEquals(8, found.get(0).x);
assertEquals(8, found.get(0).y);
// same test, but with negative features
alg.process(intensity, corners, false);
found = alg.getBestCorners();
assertEquals(3, found.size);
assertEquals(4, found.get(0).x);
assertEquals(10, found.get(0).y);
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class TestSelectNBestFeatures method testTooLittle.
/**
* The size of N is less than the number of points
*/
@Test
public void testTooLittle() {
GrayF32 intensity = new GrayF32(10, 20);
intensity.set(5, 10, -3);
intensity.set(4, 10, -3.5f);
intensity.set(5, 11, 0);
intensity.set(8, 8, 10);
QueueCorner corners = new QueueCorner();
corners.add(5, 10);
corners.add(4, 10);
corners.add(5, 11);
corners.add(8, 8);
SelectNBestFeatures alg = new SelectNBestFeatures(20);
alg.setN(20);
alg.process(intensity, corners, true);
QueueCorner found = alg.getBestCorners();
assertEquals(4, found.size);
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class ShowFeatureOrientationApp method setActiveAlgorithm.
@Override
public synchronized void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
if (input == null)
return;
RegionOrientation orientation = (RegionOrientation) cookie;
orientation.setObjectRadius(10);
T workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
deriv.setInput(workImage);
int r = 2;
GeneralFeatureDetector<T, D> detector = FactoryDetectPoint.createHarris(new ConfigGeneralDetector(NUM_FEATURES, r, 1), null, derivType);
D derivX = null, derivY = null, derivXX = null, derivYY = null, derivXY = null;
if (detector.getRequiresGradient()) {
derivX = deriv.getDerivative(true);
derivY = deriv.getDerivative(false);
} else if (detector.getRequiresHessian()) {
derivXX = deriv.getDerivative(true, true);
derivYY = deriv.getDerivative(false, false);
derivXY = deriv.getDerivative(true, false);
}
detector.process(workImage, derivX, derivY, derivXX, derivYY, derivXY);
QueueCorner points = detector.getMaximums();
FancyInterestPointRender render = new FancyInterestPointRender();
if (orientation instanceof OrientationGradient) {
((OrientationGradient<D>) orientation).setImage(deriv.getDerivative(true), deriv.getDerivative(false));
} else if (orientation instanceof OrientationIntegral) {
T ii = GIntegralImageOps.transform(workImage, null);
((OrientationIntegral<T>) orientation).setImage(ii);
} else if (orientation instanceof OrientationImageAverage) {
((OrientationImageAverage) orientation).setImage(workImage);
} else {
throw new IllegalArgumentException("Unknown algorithm type.");
}
for (int i = 0; i < points.size; i++) {
Point2D_I16 p = points.get(i);
double angle = orientation.compute(p.x, p.y);
render.addCircle(p.x, p.y, radius, Color.RED, angle);
}
BufferedImage temp = new BufferedImage(input.getWidth(), input.getHeight(), input.getType());
Graphics2D g2 = (Graphics2D) temp.getGraphics();
g2.drawImage(input, 0, 0, null);
g2.setStroke(new BasicStroke(2.5f));
render.draw(g2);
panel.setImage(temp);
panel.repaint();
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class BenchmarkExtractors method setup.
@Setup
public void setup() {
BoofConcurrency.USE_CONCURRENT = concurrent;
intensity.reshape(width, width);
corners = new QueueCorner();
Random rand = new Random(234);
ImageMiscOps.fillUniform(intensity, rand, 0, 200);
ConfigExtract config = new ConfigExtract();
config.radius = radius;
config.detectMaximums = true;
config.detectMinimums = false;
config.threshold = threshold;
config.useStrictRule = true;
blockStrictMax = FactoryFeatureExtractor.nonmax(config);
}
Aggregations