设为首页 加入收藏

TOP

关于OpenCV3.0 beta 编译出现ORB那边的错误的解决(一)
2015-02-02 14:10:00 来源: 作者: 【 】 浏览:129
Tags:关于 OpenCV3.0 beta 编译 出现 ORB 那边 错误 解决

好久没碰opencv了,现在已经3.0 beta了。


今天编译遇到了error: cannot declare variable ‘orb’ to be of abstract type ‘cv::ORB


原因是ORB这个类不能再这么调用了。


在opencv 根目录找到opencvroot/samples/gpu/performance/tests.cpp


修改成如下代码。


TEST(ORB)
{
? ? Mat src = imread(abspath("../data/aloeL.jpg"), IMREAD_GRAYSCALE);
? ? if (src.empty()) throw runtime_error("can't open ../data/aloeL.jpg");


? ? //ORB orb(4000);
? ? Ptr orb = ORB::create(4000,1.2f,8,31,0,2,ORB::HARRIS_SCORE,31,20);
? ? vector keypoints;
? ? Mat descriptors;
? ?
? ? orb->detectAndCompute(src, Mat(), keypoints, descriptors);


? ? //orb(src, Mat(), keypoints, descriptors);


? ? CPU_ON;
? ? //orb(src, Mat(), keypoints, descriptors);
? ? orb->detectAndCompute(src, Mat(), keypoints, descriptors);
? ? CPU_OFF;


? ? cuda::ORB_CUDA d_orb;
? ? cuda::GpuMat d_src(src);
? ? cuda::GpuMat d_keypoints;
? ? cuda::GpuMat d_descriptors;


? ? d_orb(d_src, cuda::GpuMat(), d_keypoints, d_descriptors);


? ? CUDA_ON;
? ? d_orb(d_src, cuda::GpuMat(), d_keypoints, d_descriptors);
? ? CUDA_OFF;
}


这里说明原因,我查看了opencv3.0的feature2d.hpp代码发现


class CV_EXPORTS_W ORB : public Feature2D?
{?
public:?
? ? enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 };?
?
? ? CV_WRAP static Ptr create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31,?
? ? ? ? int firstLevel=0, int WTA_K=2, int scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20);
?
? ? CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;?
? ? CV_WRAP virtual int getMaxFeatures() const = 0;?
?
? ? CV_WRAP virtual void setScaleFactor(double scaleFactor) = 0;?
? ? CV_WRAP virtual double getScaleFactor() const = 0;?
?
? ? CV_WRAP virtual void setNLevels(int nlevels) = 0;?
? ? CV_WRAP virtual int getNLevels() const = 0;?
?
? ? CV_WRAP virtual void setEdgeThreshold(int edgeThreshold) = 0;?
? ? CV_WRAP virtual int getEdgeThreshold() const = 0;?
?
? ? CV_WRAP virtual void setFirstLevel(int firstLevel) = 0;?
? ? CV_WRAP virtual int getFirstLevel() const = 0;?
?
? ? CV_WRAP virtual void setWTA_K(int wta_k) = 0;?
? ? CV_WRAP virtual int getWTA_K() const = 0;?
?
? ? CV_WRAP virtual void setScoreType(int scoreType) = 0;?
? ? CV_WRAP virtual int getScoreType() const = 0;?
?
? ? CV_WRAP virtual void setPatchSize(int patchSize) = 0;?
? ? CV_WRAP virtual int getPatchSize() const = 0;?
?
? ? CV_WRAP virtual void setFastThreshold(int fastThreshold) = 0;?
? ? CV_WRAP virtual int getFastThreshold() const = 0;?
};?


没有构造函数,只有一个静态的create。


此外,检测函数也不能用原来的操作符重载的检测函数了。


class ORB_Impl : public ORB?
{?
public:?
? ? explicit ORB_Impl(int _nfeatures, float _scaleFactor, int _nlevels, int _edgeThreshold,?
? ? ? ? ? ? int _firstLevel, int _WTA_K, int _scoreType, int _patchSize, int _fastThreshold) :?
? ? ? ? nfeatures(_nfeatures), scaleFactor(_scaleFactor), nlevels(_nlevels),?
? ? ? ? edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), wta_k(_WTA_K),?
? ? ? ? scoreType(_scoreType), patchSize(_patchSize), fastThreshold(_fastThreshold)?
? ? {}?
?
? ? void setMaxFeatures(int maxFeatures) { nfeatures = maxFeatures; }?
? ? int getMaxFeatures() const { return nfeatures; }?
?
? ? void setScaleFactor(double scaleFactor_) { scaleFactor = scaleFactor_; }?
? ? double getScaleFactor() const { return scaleFactor; }?
?
? ? void setNLevels(int nlevels_) { nlevels = nlevels_; }?
? ? int getNLevels() const { return nlevels; }?
?
? ? void setEdgeThreshold(int edgeThreshold_) { edgeThreshold = edgeThreshold_; }?
? ? int getEdgeThreshold() const { return edgeThreshold; }?
?
? ? void setFirs

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Rails项目如何改变已建立的model.. 下一篇Android中处理Touch Icon的方案

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: