OpenCV for ANDROID image compare

J1and1 picture J1and1 · Jun 15, 2012 · Viewed 11.8k times · Source

I want to develop app which will recognize object(like monument or something) present in front of camera using OpenCv and then it will show information about it.

So the question is how to recognize object(like monument or something) shape or compare to images with OpenCV?
And what is the best method for doing this?

It would be good if there was some kind of samples or tutorials for object detection and comparison.

Thank you.

Answer

Rui Marques picture Rui Marques · Jun 15, 2012

The best method for what you ask is using local features detectors like OpenCV's SIFT, SURF and ORB, for example.

You need at least one picture from the object you want to detect. Afterwards, those algorithms can compare that image with other images to see if they are similar enough.

Here is the Documentation for the algorithms.

  • ORB and others:

http://docs.opencv.org/modules/features2d/doc/feature_detection_and_description.html

  • SURF and SIFT ('nonfree'):

http://docs.opencv.org/modules/nonfree/doc/feature_detection.html

The way these algorithms work for that task is by selecting interesting points for each image, and compare them to see if they match. If several matches are found, it is most likely the images have the same object.

Tutorials (from Feature Detection and below):

http://docs.opencv.org/doc/tutorials/features2d/table_of_content_features2d/table_of_content_features2d.html

You can also find C++ samples related to this topic here (samples are also within OpenCV download package):

  • eg. "matching_to_many_images.cpp"
  • "video_homography.cpp"

http://code.opencv.org/projects/opencv/repository/revisions/master/show/samples/cpp

And Android Java samples here (unrelated but also helpful):

http://code.opencv.org/projects/opencv/repository/revisions/master/show/samples/android

Or Python samples which are actually the more updated ones for this topic (at the time this post was written):

http://code.opencv.org/projects/opencv/repository/revisions/master/show/samples/python2

As a final note, like @BDFun said in the comment, this is not trivial to do.

More - if you want an overview of OpenCV Feature detection and description, check this post.