问题描述
ms@ubuntu:~/Documents/codingtest/ellipse_detection/build$ make
Scanning dependencies of target Circle
[ 50%] Building CXX object CMakeFiles/Circle.dir/main.cpp.o
/home/ms/Documents/codingtest/ellipse_detection/main.cpp: In function ‘int main(int, char**)’:
/home/ms/Documents/codingtest/ellipse_detection/main.cpp:93:71: error: ‘CV_THRESH_BINARY’ was not declared in this scope
int threshold_value = threshold( src_gray, threshold_output, 0, 255, CV_THRESH_BINARY|CV_THRESH_OTSU);
^
/home/ms/Documents/codingtest/ellipse_detection/main.cpp:93:88: error: ‘CV_THRESH_OTSU’ was not declared in this scope
int threshold_value = threshold( src_gray, threshold_output, 0, 255, CV_THRESH_BINARY|CV_THRESH_OTSU);
^
/home/ms/Documents/codingtest/ellipse_detection/main.cpp:94:44: error: ‘CV_RETR_LIST’ was not declared in this scope
findContours( threshold_output, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
^
/home/ms/Documents/codingtest/ellipse_detection/main.cpp:94:58: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
findContours( threshold_output, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
^
CMakeFiles/Circle.dir/build.make:81: recipe for target 'CMakeFiles/Circle.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/Circle.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/Circle.dir/all' failed
make[1]: *** [CMakeFiles/Circle.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2
问题解决
这是opencv2和opencv3区别的问题,理论上出现“CV_XXX”宏的问题,可以先试试: (1)在“CV_XXX”前面加“cv::CV_XXX”; (2)去掉“CV_XXX”中的“CV_”,变成“XXX” 测试后编译通过!