原本在win7+VS2010环境下已经用CMake成功编译了opencv243
换在Win8+VS2013环境下会报几个错误。
解决方法如该链接:
https://github.com/Itseez/opencv/commit/52a904e17b28b59ab149f3eb57ff030468bcf1ef
1,找不到min和max的定义
解决方法:在该文件内添加#include <algorithm>
2,错误 3 error C1075: 与左侧的 大括号“{”(位于“D:\opencv_2.4.3\opencv\modules\features2d\src\features2d_init.cpp(167)”)匹配之前遇到文件结束D:\opencv_2.4.3\opencv\modules\core\include\opencv2\core\core.hpp4470 1 opencv_features2d
解决方法:features2d_init.cpp文件中,把obj.info()->addParam(obj, "detector", obj.detector);这一行改成obj.info()->addParam<FeatureDetector>(obj, "detector", obj.detector, false, 0, 0, "Detector algorithm.");
原链接最后一个改动我没做,但是debug编译成功了。
然而,release版编译不成功,错误出在orb.obj,所以还是要修改orb.cpp
去掉
#define GET_VALUE(idx) \
center[cvRound(pattern[idx].x*b + pattern[idx].y*a)*step + \
cvRound(pattern[idx].x*a - pattern[idx].y*b)]
这三行
添加
float x, y;
int ix, iy;
#define GET_VALUE(idx) \
(x = pattern[idx].x*a - pattern[idx].y*b, \
y = pattern[idx].x*b + pattern[idx].y*a, \
ix = cvRound(x), \
iy = cvRound(y), \
*(center + iy*step + ix) )
去掉
void ORB::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const
改为
void ORB::detectImpl(const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
完成