Ask Your Question
0

HOW TOP NONFREE RUN

asked 2017-06-28 05:44:38 -0600

updated 2017-06-29 01:55:22 -0600

berak gravatar image

I have gone through the instructions for running cmake a number of times, and it works for the basic modules that are included in Opencv, but when it comes to the old 'nonfree' modules, in the Extra Modules git download , it won't compile to be able to run a program that has #include "opencv/xfeatures2d.hpp"

https://github.com/Itseez/opencv_contrib ^This is the place to download the extra modules

This what Terminal gives me when I try to 'make' GIVE NO ERROR AFTER THAT I COMPILE MY PROGRAM GIVING ERROR

g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test  test.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect  -lopencv_stitching -lopencv_xobjdetect -lopencv_nonfree 

test.cpp: In function ‘int main(int, char**)’:
test.cpp:44:44: error: no matching function for call to ‘cv::xfeatures2d::SURF::SURF(int&)’
   SurfFeatureDetector detector( minHessian );
                                            ^
In file included from test.cpp:20:0:
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: candidate: cv::xfeatures2d::SURF::SURF()
 class CV_EXPORTS_W SURF : public Feature2D
                    ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note:   candidate expects 0 arguments, 1 provided
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: candidate: cv::xfeatures2d::SURF::SURF(const cv::xfeatures2d::SURF&)
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note:   no known conversion for argument 1 from ‘int’ to ‘const cv::xfeatures2d::SURF&’
test.cpp:44:23: error: cannot declare variable ‘detector’ to be of abstract type ‘cv::xfeatures2d::SURF’
   SurfFeatureDetector detector( minHessian );
                       ^
In file included from test.cpp:20:0:
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note:   because the following virtual functions are pure within ‘cv::xfeatures2d::SURF’:
 class CV_EXPORTS_W SURF : public Feature2D
                    ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:132:26: note:    virtual void cv::xfeatures2d::SURF::setHessianThreshold(double)
     CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0;
                          ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:133:28: note:    virtual double cv::xfeatures2d::SURF::getHessianThreshold() const
     CV_WRAP virtual double getHessianThreshold() const = 0;
                            ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:135:26: note:    virtual void cv::xfeatures2d::SURF::setNOctaves(int)
     CV_WRAP virtual void setNOctaves(int nOctaves) = 0;
                          ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:136:25: note:    virtual int cv::xfeatures2d::SURF::getNOctaves() const
     CV_WRAP virtual int getNOctaves() const = 0;
                         ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:138:26: note:    virtual void cv::xfeatures2d::SURF::setNOctaveLayers(int)
     CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0;
                          ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:139:25: note:    virtual int cv::xfeatures2d::SURF::getNOctaveLayers() const
     CV_WRAP virtual int getNOctaveLayers() const = 0;
                         ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:141:26: note:    virtual void cv::xfeatures2d::SURF::setExtended(bool)
     CV_WRAP virtual void setExtended(bool extended) = 0;
                          ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:142:26: note:    virtual bool cv::xfeatures2d::SURF::getExtended() const
     CV_WRAP virtual bool getExtended() const = 0;
                          ^
/usr/local/include/opencv2/xfeatures2d/nonfree.hpp:144:26: note:    virtual void cv::xfeatures2d::SURF::setUpright(bool)
     CV_WRAP virtual void setUpright(bool ...
(more)
edit retag flag offensive close merge delete

Comments

would you also be so kind to close your issue here ?

this is clearly not a library bug, but a usage problem.

berak gravatar imageberak ( 2017-06-29 05:49:57 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2017-06-29 02:05:31 -0600

berak gravatar image

updated 2017-06-29 04:06:01 -0600

the problem is NOT with the opencv libraries, but you try to run outdated, opencv2.4 based code.

api has changed a bit with 3.x, you'll have to adapt :

  • -lopencv_xfeatures2d, NOT -lopencv_nonfree (does no more exist)
  • Ptr<xfeatures2d::SURF> surf = xfeatures2d::SURF::create() , not SURF() (you have to use that smart pointer)

    surf->detect(image, keypoints) (pointer access for all functions)

also make sure, to #include <vector> and (at least) using std::vector;

here's the docs

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-06-28 05:44:38 -0600

Seen: 200 times

Last updated: Jun 29 '17