ORBSLAM也编译了好多次了,因为后来出现别的算法使用的opencv的版本不同,总会出现问题。因此记录一下。
首先一定要注意OpenCV的版本,我这里使用的是3.4.16的版本,然后要和CmakeLists.txt里面的OpenCV对应起来。
1 错误 ‘CV_LOAD_IMAGE_UNCHANGED’ was not declared in this scope119 | imLeft = cv::imread(vstrImageLeft[ni],CV_LOAD_IMAGE_UNCHANGED);
解决办法:打开vscode,查找所有存在CV_LOAD_IMAGE_UNCHANGED的文件,添加头文件:
#include "opencv2/imgcodecs/legacy/constants_c.h"
2 错误:‘CvMat’ has not been declared/‘CV_GRAY2BGR’ was not declared in this scope error: ‘CV_RGB2GRAY’ was not declared in this scope
解决办法:同样打开vscode,查找所有存在CV_RGB2GRAY的文件,添加以下头文件即可:
#include <opencv2/imgproc/types_c.h>