OpenCV Getting Started-extracting sift key points
In the content-based image retrieval, the local invariant feature of the image is relative to the global feature, the local feature can powerfully describe the feature of the image, it has important significance, and in many gray-based local feature extraction algorithm sift has the best effect, the concrete principle depends on the Lowe paper, Below use OpenCV to feel the following effect.
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/nonfree/ Features2d.hpp>//using namespace Cv;int main (int argc, const char *argv[]) { Mat input = Imread ("Input.jpg", 0);// Load as grayscale siftfeaturedetector detector; Vector<keypoint> keypoints; Detector.detect (input, keypoints); Show the keypoints on an image Mat output; Drawkeypoints (input, keypoints, output); Imwrite ("sift_result.jpg", output); return 0;}
Run:
g++ sift_demo.cxx Compile link error:
/tmp/cczzicnk.o:in function ' main ':
Sift_demo.cxx: (. text+0x4d): Undefined reference to ' Cv::imread (std::string const&, int) '
/tmp/cczzicnk.o:in function ' Cv::mat::~mat () ':
Sift_demo.cxx: (. text._zn2cv3matd2ev[_zn2cv3matd5ev]+0x2b): Undefined reference to ' Cv::fastfree (void*) '
/tmp/cczzicnk.o:in function ' Cv::mat::release () ':
Sift_demo.cxx: (. text._zn2cv3mat7releaseev[_zn2cv3mat7releaseev]+0x3b): Undefined reference to ' Cv::mat::d eallocate ()‘
Collect2:error:ld returned 1 exit status
Workaround: The description did not find the location of the library, developed, g++ Sift_demo.cxx' pkg-config opencv--cflags--libs '
Finally, the results are as follows, we can see a lot of key points, in the form of the circle in the original image.
OpenCV Getting Started-extracting sift key points