Example Detect Interest Points

From BoofCV
Revision as of 04:01, 2 November 2011 by Peter (talk | contribs) (Created page with "= Detect Interest Point Example = <center> <gallery widths=600px heights=250px> Image:Example_interestpoint_detected.jpg | Detected fast hessian features in standard sun flower ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Detect Interest Point Example

Interest points are a general term in computer vision for points in the image that can detected and are relevant for higher level processing. Interest points are commonly used by image stabilization and structure from motion applications to track how the image changes from frame to frame. The following example shows how interest points can be detected easily using the InterestPointDetector<T> interface.

InterestPointDetector is a generalized interface that allows the user to switch between different types of interest points. Functions are provided that can be used to test if it provides scale and/or orientation information on the interest point. The disadvantages of using this interface is that it prevents tight coupling between algorithms, leading to excessive computations.


Example Code:

Concepts:

  • Point feature detection

Relevant Applets:

Example Code

public class ExampleInterestPoint {

	public static <T extends ImageBase>
	void detect( BufferedImage image , Class<T> imageType ) {
		T input = ConvertBufferedImage.convertFrom(image,null,imageType);

		// create a Fast Hessian detector from the SURF paper.
		// Other detectors can be used in this example too.
		InterestPointDetector<T> detector = FactoryInterestPoint.fromFastHessian(10,100,2,9,3,4);

		// find interest points in the image
		detector.detect(input);

		// Draw the features
		Graphics2D g2 = image.createGraphics();
		FancyInterestPointRender render = new FancyInterestPointRender();

		for( int i = 0; i < detector.getNumberOfFeatures(); i++ ) {
			Point2D_F64 pt = detector.getLocation(i);

			// note how it checks the capabilities of the detector
			if( detector.hasScale() ) {
				double scale = detector.getScale(i);
				render.addCircle((int)pt.x,(int)pt.y,(int)(scale*2.5));
			} else {
				render.addPoint((int) pt.x, (int) pt.y);
			}
		}
		// make the circle's thicker
		g2.setStroke(new BasicStroke(3));

		// just draw the features onto the input image
		render.draw(g2);
		ShowImages.showWindow(image,"Detected Features");
	}

	public static void main( String args[] ) {
		BufferedImage image = UtilImageIO.loadImage("../evaluation/data/sunflowers.png");
		detect(image, ImageFloat32.class);
	}
}