use of boofcv.alg.feature.orientation.OrientationImageAverage 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();
}
Aggregations