error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
49 | cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
49 | cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
安装cvsba遇到了CV_TERMCRIT_ITER 和 CV_TERMCRIT_EPS报错
接下来一步一步分析找到原因,如果要直接看结果可以跳到文末
1.报错的代码在:/cvsba/utils/test_cvsba.cpp里的49行:
cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
2.一般是头文件的问题,test_cvsba.cpp里包含头文件有
#include "cvsba.h"
#include "readparams.h"
3.我们找到这两个头文件所在的位置:
sudo find / -name "*cvsba*"
sudo find / -name "*readparams*"
4.找到了文件所在位置:
cvsba-1.0.0/src/cvsba.h
cvsba-1.0.0/utils/readparams.h
5.使用gedit 打开cvsba.h
sudo gedit cvsba.h
6.在cvsba.h里面尝试用ctrl+F找到CV_TERMCRIT_ITER,发现没有这个关键词
7.再打开readparams.h,也找不到
8.cvsba.h所包含的头文件
#include
#include
#include
9.core.hpp有两个来源:Opencv的Release 和 Debug,猜测会不会是因为路径没有指明造成的
/usr/local/OpenCV/Release/include/opencv4/opencv2/core/core.hpp
/usr/local/OpenCV/Debug/include/opencv4/opencv2/core/core.hpp
尝试将头文件里面改为#include让指定更加明确,但并没有效果
10.将每一个头文件打开,找到里面都有木有关键词:CV_TERMCRIT_ITER
11.最后尝试直接屏蔽这两个关键词所在的语句
// cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
然后make成功了
总结:
1.根据报错代码找到报错的test_cvsba.cpp文件
/home/chen/下载/cvsba-1.0.0/utils/test_cvsba.cpp:49:29: error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
49 | cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
| ^~~~~~~~~~~~~~~~
/home/chen/下载/cvsba-1.0.0/utils/test_cvsba.cpp:49:46: error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
49 | cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
2.用gedit编辑它
sudo gedit test_cvsba.cpp
3.打开test_cvsba.cpp后,将这一行注释掉
// cv::TermCriteria criteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 150, 1e-10);
4.重新make后就可以正常运行了