您的位置:首页 > Web前端

OpenCV3.1 xfeatures2d::SIFT 使用

2016-03-11 13:12 316 查看

OpenCV3.1 SIFT使用

OpenCV3对OpenCV的模块进行了调整,将开发中与nofree模块放在 了OpenCV_contrib中(包含SIFT),gitHub上的官方项目分成了两个,opencv 与 opencv_contrib。所以,要使用sift接口需在opencv3.1基础上,再安装opencv_contrib。本文主要记录如何安装opencv_contrib,配置Xcode,sift接口的用法。

环境:OSX + Xcode + OpenCV3.1

OpenCV31 SIFT使用
install opencv_contrib

configuration Xcode
pro_name Build Setting Search Paths

pro_name Build Setting Other Linker Flags

sample of sift

References

install opencv_contrib

download contrib source code https://github.com/Itseez/opencv_contrib, follow README.md to install

$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
$ sudo make install


Where
<opencv_build_directory>
and
<opencv_source_directory>
is directory in opencv3.1 install tutorial

configuration Xcode

like How to develop OpenCV with Xcode

pro_name Build Setting > Search Paths

/usr/local/lib

/usr/local/include

pro_name Build Setting >Other Linker Flags

-lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lippicv -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core

sample of sift

sample in (souce_dir)/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp or bellow

#include "opencv2/xfeatures2d.hpp"

//
// now, you can no more create an instance on the 'stack', like in the tutorial
// (yea, noticed for a fix/pr).
// you will have to use cv::Ptr all the way down:
//
cv::Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
//cv::Ptr<Feature2D> f2d = xfeatures2d::SURF::create();
//cv::Ptr<Feature2D> f2d = ORB::create();
// you get the picture, i hope..

//-- Step 1: Detect the keypoints:
std::vector<KeyPoint> keypoints_1, keypoints_2;
f2d->detect( img_1, keypoints_1 );
f2d->detect( img_2, keypoints_2 );

//-- Step 2: Calculate descriptors (feature vectors)
Mat descriptors_1, descriptors_2;
f2d->compute( img_1, keypoints_1, descriptors_1 );
f2d->compute( img_2, keypoints_2, descriptors_2 );

//-- Step 3: Matching descriptor vectors using BFMatcher :
BFMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );


References

https://github.com/Itseez/opencv_contrib

https://github.com/Itseez/opencv

http://blog.csdn.net/lijiang1991/article/details/50756065

http://docs.opencv.org/3.1.0/d5/d3c/classcv_1_1xfeatures2d_1_1SIFT.html#gsc.tab=0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: