FeatureDetector vs. FeatureFinder in OpenCV - opencv

I'm trying to understand the difference between the FeatureDetector class and the FeatureFinder class. I've seen panorama examples written in OpenCV use both of these classes and it appears to be possible to use the SURF algorithm with either one. It was my understanding that the SURF FeatureDetector was moved to /nonfree because of possible issues with the SURF algorithm, but yet, FeatureFinder also can employ the SURF algorithm.
What's the difference between these two classes?

FeatureFinder can use the SURF algorithm because it is implemented using FeatureDetector.
Whichever you use, you are actually getting the same SURF implementation, just different interface.
FeatureFinder has an interface compatible with the stitching pipeline whereas FeatureDetector has an interface to match the 2d features framework.

Related

Which feature detection algorithm does cv2.Stitcher() use?

I just learnt about SIFT, ORB & SURF algorithms and how they are used for feature detection & extraction, and Homography & RANSAC techniques used in Image Fusion. While SIFT & SURF algorithms are patented and mostly have better accuracy (source1, source2), ORB algorithm is lightweight and Open Sourced.
OpenCV Stitcher function (documentation) is built such that it can be used even without knowing the entire image stitching pipeline.
So I am curious to know, which algorithms are used (especially for feature detection & extraction) in the cv2.Stitcher class? Also is it possible to choose different algorithms other than the default ones, used in its implementation?
The stitcher class uses ORB by Default:
stitcher->setFeaturesFinder(ORB::create());
in stitcher.cpp
You can use stitching_detailed.py/stitching_detailed.cpp or the stitching python package to play around with different detectors

Object recognition Using sift descriptors

I am a newbie to the field. My problem is to recognize whether an object similar to the object used in training images(Images of Similar objects) is present in test image or not. I want to use SIFT descriptors for recognition. Is the bag of words approach by clustering of SIFT descriptors which is used for object classification into different classes is suitable for it or if there is simpler approach using sift descriptors for it.
Thanks in advance
The bag of visual words (BoW) is indeed the classic approach, originally proposed by Sivic & Zisserman in 2003 [Paper]. It was among the first to depart from previous methods that favored global descriptors as opposed to local features like SIFT and SURF. I do recommend continuing to implement this classic pipeline if you are just beginning to learn about object detection and recognition.

Are there any fast alternatives to SURF and SIFT for scale-invariant feature extraction?

SURF is patented, as is SIFT. ORB and BRIEF are not patented, but their features are not scale-invariant, seriously limiting their usefulness in complex scenarios.
Are there any feature extractors that can extract scale-invariant features as fast as SURF and are not so strictly patented as SURF and SIFT?
Although you already choose BRISK, you might find FREAK interesting. Author claims to have better results than BRISK and ORB. I should also add that ORB is scale-invariant but has some problems in that area. So I would still recommend it for someone to try it.
The FREAK source code is compatible with OpenCV (how easy it is to merge them I do not know) and the author is working on submitting it to the OpenCV project.
EDIT:
FREAK is now part of opencv feature detectors / descriptors.
You can read here more about the differences between several feature detectors/extractors, and also a series of benchmarks which includes FREAK and other popular ones.
FREAK is supposed to be the fastest scale and rotation invariant descriptor extractor, it is open source and you can use it easily as it is implemented in OpenCV. You need a binary matcher that uses the Hamming Distance, like the BruteForceMatcher.
Here you have an example on how to use it, easily replaceble by SIFT descriptor.
I ended up using Brisk, which is a feature detector with performance comparable to SURF but under the BSD licence. Plus, it's got a very nice open source C++ implementation that plugs in easily to the OpenCV FeatureDetector framework, so it's like 2 lines choosing to use Brisk over SURF in your code.
You might try multi-scale histogram of oriented gradients. It won't be fully scale-invariant, but if your data are constrained with a reasonable set of scale limits (often the case in practice) then this can probably work for you.
Another approach, depending totally on what your intended application is, would be to leverage poselets, even if they are built on top of a non-scale-invariant descriptor like plain histogram of oriented gradient, or appearance models. If the annotations in your training data include examples of different items for detection all at different scales, then the Procrustes-style distance used in Poselets for training should take care of a lot of scale-invariance. This may not be satisfactory though if your primary application is not localized detection of parts.
As an aside, I think it's rather unfortunate that SIFT and SURF were capable of being patented this way, given that they were (at least in part) funded with tax-payer dollars through grants.
You can try KAZE, it is supposed to be faster and more precise (the videos seem fancy, but I did not get to try it myself yet). There is also an accelerated version of it available.
Pablo F. Alcantarilla, Adrien Bartoli and Andrew J. Davison, "KAZE Features", In European Conference on Computer Vision (ECCV). Fiorenze*, Italy. October 2012.
Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli, "Fast Explicit Diffusion for Accelerated Features in Nonlinear Scale Spaces", In British Machine Vision Conference (BMVC). Bristol, UK. September 2013
The source codes, videos and more can be found at the author's website.
*Firenze
FREAK is now included in OpenCV 2.4.2, you can use it easily :-)
Detection of landmark points and finding hog features(it's not patented ) by forming patches around landmark points .

OpenCV Cascade Classification with Histogram of Oriented Gradients (HOGs) feature type

I am trying to use the OpenCV's cascade classifier based on Histogram of Oriented Objects (HOGs) feature type -- such as the paper "Fast Human Detection Using a Cascade of Histograms of Oriented Gradients".
Searching in the web, I found that the Cascade Classificator of OpenCV only supports HAAR/LBP feature type (OpenCV Cascade Classification).
Is there a way to use HOGs with the OpenCV cascade classifier? What
do you suggest?
Is there a patch or another library that I can use?
Thanks in advance!
EDIT 1
I've kept my search, when I finally found in android-opencv that there is a trunk in Cascade Classifier which allows it to work with HOG features. But I don't know if it works...
Link: http://code.opencv.org/projects/opencv/repository/revisions/6853
EDIT 2
I have not tested the fork above because my problem has changed. But I found an interesting link which may be very useful in the future (when I come back to this problem).
This page contains the source code of the paper "Histograms of Oriented Gradients for
Human Detection". Also, more information. http://pascal.inrialpes.fr/soft/olt/
If you use OpenCV-Python, then you have the option of using some additional libraries, such as scikits.image, that have Histogram of Oriented Gradient built-ins.
I had to solve exactly this same problem a few months ago, and documented much of the work (including very basic Python implementations of HoG, plus GPU implementations of HoG using PyCUDA) at this project page. There is code available there. The GPU code should be reasonably easy to modify for use in C++.
It now seems to be available also in the non-python code. opencv_traincascade in 2.4.3 has a HOG featuretype option (which I did not try):
[-featureType <{HAAR(default), LBP, HOG}>]
Yes, you can use cv::CascadeClassifier with HOG features. To do this just load it with hogcascade_pedestrians.xml that you may find in opencv_src-dir/data/hogcascades.
The classifier works faster and its results are much better when it trained with hogcascade in compare with haarcascade...

Is Haar Cascade the only available technique for image recognition in OpenCV

I know that there are many detection techniques in OpenCV, such as SURF, STAR, ORB etc...but those techniques are for feature detection of new video feed, not for dealing with specific instances of objects that require prior learning. OpenCV's documentation isn't quite as easy to flip through and I've yet been able to find anything besides Haar, which I know deals best with face recognition.
So are there any other techniques besides Haar? The Haar technique dates back to research 10 years ago, so ideally I hope that there have been some more advances since then that have been implemented in OpenCV.
If you are looking for OpenCV machine learning type algorithms, check out this link.
For a state of the art on-the-fly object detection algorithm, have a look at OpenTLD. It uses bounding boxes and random forests to learn about an object over time. Check out the demo video here.
Also check out the matching_to_many_images.cpp sample from OpenCV. It uses feature descriptors to match objects much like Google Goggles works. A related example to this is the bagofwords_classification.cpp sample. It may be what you are looking for in this case. It uses feature detectors (SURF, SIFT, etc...) to detect objects and then classify them by comparing the relative positions of the features to a learned database of features. Have a look also at this tutorial from MIT.
The latentsvmdetect.cpp may also be a good starting point for you.
Hope that helps!

Resources