use of georegression.struct.point.Point2D_I16 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), false, 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 georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.
the class VideoDetectCorners method updateGUI.
@Override
public void updateGUI(BufferedImage guiImage, T origImage) {
Graphics2D g2 = guiImage.createGraphics();
for (int i = 0; i < corners.size(); i++) {
Point2D_I16 pt = corners.get(i);
g2.setColor(Color.BLACK);
g2.fillOval(pt.x - 4, pt.y - 4, 9, 9);
g2.setColor(Color.RED);
g2.fillOval(pt.x - 2, pt.y - 2, 5, 5);
}
if (panel == null) {
panel = ShowImages.showWindow(guiImage, "Image Sequence");
addComponent(panel);
} else {
panel.setImage(guiImage);
panel.repaint();
}
}
use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.
the class ExampleNonMaximumSupression method renderNonMax.
public static BufferedImage renderNonMax(GrayF32 intensity, int radius, float threshold) {
// Create and configure the feature detector
NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(radius, threshold));
// We will only searching for the maximums. Other variants will look for minimums or will exclude previous
// candidate detections from being detected twice
QueueCorner maximums = new QueueCorner();
nonmax.process(intensity, null, null, null, maximums);
// Visualize the intensity image
BufferedImage output = new BufferedImage(intensity.width, intensity.height, BufferedImage.TYPE_INT_RGB);
VisualizeImageData.colorizeSign(intensity, output, -1);
// render each maximum with a circle
Graphics2D g2 = output.createGraphics();
g2.setColor(Color.blue);
for (int i = 0; i < maximums.size(); i++) {
Point2D_I16 c = maximums.get(i);
VisualizeFeatures.drawCircle(g2, c.x, c.y, radius);
}
return output;
}
use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.
the class GenericNonMaxAlgorithmTests method checkSamePoints.
private void checkSamePoints(QueueCorner list0, QueueCorner list1) {
for (int j = 0; j < list0.size(); j++) {
Point2D_I16 b = list0.get(j);
boolean foundMatch = false;
for (int k = 0; k < list1.size(); k++) {
Point2D_I16 a = list1.get(k);
if (a.x == b.x && a.y == b.y) {
foundMatch = true;
break;
}
}
assertTrue(foundMatch);
}
}
use of georegression.struct.point.Point2D_I16 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);
}
}
Aggregations