Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::xfeatures2d::SURF abstract?

With all default opencv + opencv_contrib build (vs2013), it seems that the mentioned class is abstract.

Test code:

#include <opencv2\core.hpp>
#include <opencv2\features2d.hpp>
#include <opencv2\xfeatures2d\nonfree.hpp>
//the corresponding libraries are linked


int main()
{
    cv::Mat m;
    cv::xfeatures2d::SURF surf;
    return 0;
}

Error:

Error   1   error C2259: 'cv::xfeatures2d::SURF' : cannot instantiate abstract class    c:\documents\visual studio 2013\projects\xfeattest\xfeattest\main.cpp   8   1   xfeatTest

2   IntelliSense: object of abstract class type "cv::xfeatures2d::SURF" is not allowed:
        function "cv::xfeatures2d::SURF::setHessianThreshold" is a pure virtual function
        function "cv::xfeatures2d::SURF::getHessianThreshold" is a pure virtual function
        function "cv::xfeatures2d::SURF::setNOctaves" is a pure virtual function

The nonfree.hpp:

#ifndef __OPENCV_XFEATURES2D_FEATURES_2D_HPP__
#define __OPENCV_XFEATURES2D_FEATURES_2D_HPP__

#include "opencv2/features2d.hpp"

namespace cv
{
namespace xfeatures2d
{

/*!
 SIFT implementation.

 The class implements SIFT algorithm by D. Lowe.
*/
class CV_EXPORTS_W SIFT : public Feature2D
{
public:
    CV_WRAP static Ptr<SIFT> create( int nfeatures = 0, int nOctaveLayers = 3,
                                    double contrastThreshold = 0.04, double edgeThreshold = 10,
                                    double sigma = 1.6);
};

typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;

/*!
 SURF implementation.

 The class implements SURF algorithm by H. Bay et al.
 */
class CV_EXPORTS_W SURF : public Feature2D
{
public:
    CV_WRAP static Ptr<SURF> create(double hessianThreshold=100,
                  int nOctaves = 4, int nOctaveLayers = 3,
                  bool extended = false, bool upright = false);

    CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0;
    CV_WRAP virtual double getHessianThreshold() const = 0;

    CV_WRAP virtual void setNOctaves(int nOctaves) = 0;
    CV_WRAP virtual int getNOctaves() const = 0;

    CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0;
    CV_WRAP virtual int getNOctaveLayers() const = 0;

    CV_WRAP virtual void setExtended(bool extended) = 0;
    CV_WRAP virtual bool getExtended() const = 0;

    CV_WRAP virtual void setUpright(bool upright) = 0;
    CV_WRAP virtual bool getUpright() const = 0;
};

typedef SURF SurfFeatureDetector;
typedef SURF SurfDescriptorExtractor;

}
} /* namespace cv */

#endif

Any idea what the problem could be?

click to hide/show revision 2
retagged

updated 2014-10-23 15:53:46 -0600

berak gravatar image

cv::xfeatures2d::SURF abstract?

With all default opencv + opencv_contrib build (vs2013), it seems that the mentioned class is abstract.

Test code:

#include <opencv2\core.hpp>
#include <opencv2\features2d.hpp>
#include <opencv2\xfeatures2d\nonfree.hpp>
//the corresponding libraries are linked


int main()
{
    cv::Mat m;
    cv::xfeatures2d::SURF surf;
    return 0;
}

Error:

Error   1   error C2259: 'cv::xfeatures2d::SURF' : cannot instantiate abstract class    c:\documents\visual studio 2013\projects\xfeattest\xfeattest\main.cpp   8   1   xfeatTest

2   IntelliSense: object of abstract class type "cv::xfeatures2d::SURF" is not allowed:
        function "cv::xfeatures2d::SURF::setHessianThreshold" is a pure virtual function
        function "cv::xfeatures2d::SURF::getHessianThreshold" is a pure virtual function
        function "cv::xfeatures2d::SURF::setNOctaves" is a pure virtual function

The nonfree.hpp:

#ifndef __OPENCV_XFEATURES2D_FEATURES_2D_HPP__
#define __OPENCV_XFEATURES2D_FEATURES_2D_HPP__

#include "opencv2/features2d.hpp"

namespace cv
{
namespace xfeatures2d
{

/*!
 SIFT implementation.

 The class implements SIFT algorithm by D. Lowe.
*/
class CV_EXPORTS_W SIFT : public Feature2D
{
public:
    CV_WRAP static Ptr<SIFT> create( int nfeatures = 0, int nOctaveLayers = 3,
                                    double contrastThreshold = 0.04, double edgeThreshold = 10,
                                    double sigma = 1.6);
};

typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;

/*!
 SURF implementation.

 The class implements SURF algorithm by H. Bay et al.
 */
class CV_EXPORTS_W SURF : public Feature2D
{
public:
    CV_WRAP static Ptr<SURF> create(double hessianThreshold=100,
                  int nOctaves = 4, int nOctaveLayers = 3,
                  bool extended = false, bool upright = false);

    CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0;
    CV_WRAP virtual double getHessianThreshold() const = 0;

    CV_WRAP virtual void setNOctaves(int nOctaves) = 0;
    CV_WRAP virtual int getNOctaves() const = 0;

    CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0;
    CV_WRAP virtual int getNOctaveLayers() const = 0;

    CV_WRAP virtual void setExtended(bool extended) = 0;
    CV_WRAP virtual bool getExtended() const = 0;

    CV_WRAP virtual void setUpright(bool upright) = 0;
    CV_WRAP virtual bool getUpright() const = 0;
};

typedef SURF SurfFeatureDetector;
typedef SURF SurfDescriptorExtractor;

}
} /* namespace cv */

#endif

Any idea what the problem could be?