I'm trying to get started working with sift feature extraction using (C++) OpenCv. I need to extract features using SIFT, match them between the original image (e.g. a book) and a scene, and after that calculate the camera pose.
So far I have found this algorithm using SURF. Does anyone know a base code from which I can get started, or maybe a way to convert the algorithm in the link from SURF to SIFT?
Thanks in advance.
EDIT:
Ok, I worked out a solution for the sift problem. Now I'm trying to figure the camera pose. I'm trying to use: solvePnP, can anyone help me with an example?
Check out the feature2d tutorial section of the new OpenCV docs website.
There tutorials with code showing:
Feature detection with e.g. SURF
Feature Description
Feature Matching
If you have managed to find matches between the image and the scene, then I suggest you apply cv::findHomography(). It will calculate the homography matrix using 4 matches as input.
You can convert to camera pose from the homography matrix directly.
For using SIFT instead of SURF, I changed SurfFeatureDetector to SiftFeatureDetector and SurfDescriptorExtractor to SiftDescriptorExtractor. For some images, I found that the combination SURF detector <--> SIFT descriptor yields relatively accurate results, but you should experiment with other combinations (FAST detector - FREAK descriptor or ORB detector - BRISK descriptor), depending on your requirements.
Please follow this tutorial for solving the homography part of your question:
Feature Matching and Homography
Also, maybe this will help: Pose Estimation
Related
I'm trying to use SIFT (from opencv) to get a histogram that describes an image. The problem is, that SIFT identifies a lot of points of interest in the image and gives me a 128 elements vector. While It seems to me as this is what SIFT supposed to do, my lab's PI told me there is an implementation that gives a single 128 elements vector for the all image. Do you know of such an implementation ?
If not, is there any other way of getting a good descriptor for an image ?
(for the purpose of machine learning classification)
In SIFT descriptors feature extraction, each keypoints/interest points gives a 128D SIFT features and as there are multiple keypoints in an image, you will get some 128D x No. of keypoints SIFT vectors for each image. As per my experience, if you try to use SIFT features extraction in OpenCV, you will have to build the library from scratch as SIFT is patented algorithm, the OpenCV community have removed the plug-in library for SIFT and SURF.
You can also try other feature extraction techniques like VLAD, Fisher vector, RGB color histogram, HoG (Histogram of Oriented Gradient) features.
I wish to stitch two or more images using OpenCV and C++. The images have regions of overlap but they are not being detected. I tried using homography detector. Can someone please suggest as to what other methods I should use. Also, I wish to use the ORB algorithm, and not SIFT or SURF.
The images can be found at-
https://drive.google.com/open?id=133Nbo46bgwt7Q4IT2RDuPVR67TX9xG6F
This a very common problem. Because images like this, they actually do not have much in common. The overlap region is not rich in feature. What you can do is dig into opencv stitcher code and there they use confidence factor for feature matching, you can play with that confidence factor to get matches in this case. But this will only work if your feature detector is able to detect some features in overlapping resion.
You can also look at this post:
Related Question
It might be helpful for you.
"OpenCV stitching code"
This is full pipleline of OPencv Stitching code. You can see that there are lot of parameters you can change to make your code give some good stitching result. Also I would suggest using a small image (640 X480) for the feature detection step. Using small images is better than using very large images
I am new to opencv, I made some examples and I played around with it.
But I want to do a more complex project for school that includes irregular shape detection in an image.
Here a some of the shapes just to make an idea:
Can anyone give me some general guides on what are the steps for achieving this and what should I use from opencv. I want to do it in the c++ version.
Note: the image might also be colored.
You can use SURF feature of opencv to extract shape features and match with flannMatcher or BFMatcher.
Please see the examples:
1/ SURF Feature Extraction
2/ Flann Matcher
3/ BF Matcher
Hope this will help you.
For a project, I have to detect a cube with a webcam. I think that OpenCV could be a good solution to find out where is it (real-time).
I'm new in the computer vision domain, and I wonder which algo can I use ? Hough ?
I've seen this video (quite impressive!): http://www.youtube.com/watch?v=ytvO2dijZ7A
Do you know how he was able to do it ?
Thank you a lot for your help
To get the result as in the video, you have given, you can use squares.cpp that comes with OpenCV samples. (It is for images. Hope you can do it for videos.)
Other useful SO on this topic are:
1) OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection
2) Square detection doesn't find squares
I see HOG is often used with SVM for target detection, can it be used in matching keypoints in two images?
and btw, where could I find OpenCV sample of using HOGDescriptor?
HOG can be used without SVM for feature matching.
just choose some points ( edge, for example ) and calculate the feature of HOG inside ROI with those points centered.
HOGDescriptor seems only for GPU programming.
I created Descriptor for HOG as a Mat in openCV and it also works for OpenCV matching functions.
If you are working with images you can use SIFT/SURF with SVM. There is nothing that stops you from using HOG for keypoint matching, but bear in mind that the effectiveness depends on discrimination power and robustness of the descriptor.
Edit: My bad in understanding when I originally mentioned HOG being for video only. Somehow I was thinking about histogram of optical flow vectors which is very effective for video activity description.
Edit 2 [Oct '12]: I now suggest people to try ORB or BRISK for those looking for license friendly descriptors that are fast and quite effective for keypoint matching.