c++ - Simple SIFT Detector ISSUE on OpenCV -
i'm implementing simple example familiar opencv , sift.
1 #include <opencv2/core/core.hpp> 2 #include <opencv2/features2d/features2d.hpp> 3 #include <opencv2/highgui/highgui.hpp> 4 5 using namespace std; 6 7 int main(int argc, char** argv) { 8 9 const cv::mat input = cv::imread("/tmp/image.jpg", 0); //load grayscale 10 11 cv::siftfeaturedetector detector; 12 std::vector<cv::keypoint> keypoints; 13 detector.detect(input, keypoints); 14 15 // add results image , save. 16 cv::mat output; 17 cv::drawkeypoints(input, keypoints, output); 18 cv::imwrite("/tmp/sift_result.jpg", output); 19 20 return 0; 21 22 } i expecting quite straightforward, it's throwing following errors:
undefined reference 'cv::sift::commonparams::commonparams()'@ line 11undefined reference 'cv::featuredetector::detect(cv::mat const&, std::vector<cv::keypoint, std::allocator<cv::keypoint> >&, cv::mat const&) const'@ line 13undefined reference 'cv::drawkeypoints(cv::mat const&, std::vector<cv::keypoint, std::allocator<cv::keypoint> > const&, cv::mat&, cv::scalar_<double> const&, int)'@ line 17
can please tell me what's going wrong? problem in code, or missing headers?
complete build output:
make building file: ../main.cpp invoking: gcc c++ compiler g++ -i/usr/local/include/opencv -i/usr/include/c++/4.5.2 -o0 -g3 -wall -c -fmessage-length=0 -std=c++0x -mmd -mp -mf"main.d" -mt"main.d" -o "main.o" "../main.cpp" finished building: ../main.cpp building target: bioinfo invoking: gcc c++ linker g++ -l/usr/local/lib -o "bioinfo" ./imageprocessingclass.o ./main.o -lopencv_core -lopencv_highgui ./main.o: in function `main': /.../debug/../main.cpp:38: undefined reference `cv::sift::commonparams::commonparams()' /.../debug/../main.cpp:38: undefined reference `cv::sift::detectorparams::detectorparams()' /.../debug/../main.cpp:38: undefined reference `cv::siftfeaturedetector::siftfeaturedetector(cv::sift::detectorparams const&, cv::sift::commonparams const&)' /.../debug/../main.cpp:40: undefined reference `cv::featuredetector::detect(cv::mat const&, std::vector<cv::keypoint, std::allocator<cv::keypoint> >&, cv::mat const&) const' /.../debug/../main.cpp:44: undefined reference `cv::drawkeypoints(cv::mat const&, std::vector<cv::keypoint, std::allocator<cv::keypoint> > const&, cv::mat&, cv::scalar_<double> const&, int)' ./main.o: in function `~siftfeaturedetector': /usr/local/include/opencv2/features2d/features2d.hpp:1502: undefined reference `vtable cv::siftfeaturedetector' /usr/local/include/opencv2/features2d/features2d.hpp:1502: undefined reference `cv::featuredetector::~featuredetector()' collect2: ld returned 1 exit status make: *** [bioinfo] error 1 build finished
it seems have forgotten link opencv libraries. remember if you're linking against opencv 2.4 there new library "non-free" algorithms named opencv_nonfree need link against sift.
Comments
Post a Comment