这是运行高翔 slambook2 代码出现的问题,有两种方法解决。

error: ‘CV_GRAY2BGR’ was not declared in this scope

/home/diyu/slambook2/ch8/optical_flow.cpp: In function ‘int main(int, char**)’:
/home/diyu/slambook2/ch8/optical_flow.cpp:145:37: error: ‘CV_GRAY2BGR’ was not declared in this scope
145 | cv::cvtColor(img2, img2_single, CV_GRAY2BGR);
| ^~~~~~~~~~~
/home/diyu/slambook2/ch8/direct_method.cpp: In function ‘void DirectPoseEstimationSingleLayer(const cv::Mat&, const cv::Mat&, const VecVector2d&, std::vector<double, std::allocator >, Sophus::SE3d&)’:
/home/diyu/slambook2/ch8/direct_method.cpp:206:35: error: ‘CV_GRAY2BGR’ was not declared in this scope
206 | cv::cvtColor(img2, img2_show, CV_GRAY2BGR);
| ^~~~~~~~~~~
make[2]: *** [CMakeFiles/optical_flow.dir/build.make:63:CMakeFiles/optical_flow.dir/optical_flow.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:105:CMakeFiles/optical_flow.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务…
make[2]: *** [CMakeFiles/direct_method.dir/build.make:63:CMakeFiles/direct_method.dir/direct_method.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:78:CMakeFiles/direct_method.dir/all] 错误 2
make: *** [Makefile:84:all] 错误 2

这个实验由于代码使用的是opencv2,而cmkelists.txt文件中是opencv4

error: ‘CV_GRAY2BGR’ was not declared in this scope
这是opencv2的用法,现在opencv3和4是COLOR_GARY2BGR

因此有两种选择

  1. 要么将代码中opencv2的用法改成opencv3或者4的用法。即将代码中的CV_GRAY2BGR改成COLOR_GRAY2BGR,这里不确定是不是只需修改这个就可以。

  2. 要么将cmakelists文件中的opencv4改成opencv2。

这里选择第二种做法,修改成opencv2

【已解决】error: ‘CV_GRAY2BGR’ was not declared in this scope相关推荐

  1. 解决[Error] ‘i‘ was not declared in this scope

    解决 想必大家都遇到过这种报错 这是为什么呢? #include<iostream> using namespace std; int main() {int sum=0;for(i=0; ...

  2. 【已解决】‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

    'CV_LOAD_IMAGE_GRAYSCALE' was not declared in this scope 由于OpenCV版本差异导致变量没有定义 'CV_LOAD_IMAGE_GRAYSCA ...

  3. 【C++】mingw32-make+cmake:error: ‘nullptr‘ was not declared in this scope解决方法

    ###问题 使用cmake成功(Configuring done Generating done)后,在cmd终端中执行 mingw32-make报错: error: 'nullptr' was no ...

  4. 解决Cygwin编译cocos2dx 遇到的 error: 'UINT64_C' was not declared in this scope 问题

    环境工具:Win10.VS2013.cocos2d-x-2.2.6.Cygwin.ADT 问题来源:写了一个小游戏,VS2013上运行成功,就尝试着打包apk,项目导入到ADT里面,添加了cocos2 ...

  5. 已解决ERROR: Cannot find command ‘git’- do you have ‘git’ installed and in your PATH?

    已解决ERROR: Cannot find command 'git'- do you have 'git' installed and in your PATH?异常的正确解决方法,亲测有效!!! ...

  6. 已解决error:stray‘\243‘in program异常的正确解决方法,亲测有效!!!

    已解决error:stray'\243'in program异常的正确解决方法,亲测有效!!! 文章目录 报错问题 解决方法 福利 报错问题 粉丝群里面的一个小伙伴敲代码时发生了报错(当时他心里瞬间凉 ...

  7. error: ‘CV_RGB2GRAY’ was not declared in this scope 的解决方法

    error: 'CV_RGB2GRAY' was not declared in this scope 的解决方法 参考文章: (1)error: 'CV_RGB2GRAY' was not decl ...

  8. Windows网络编程 c语言 报错:[Error] ‘bzero‘ was not declared in this scope

    阅读前请看一下:我是一个热衷于记录的人,每次写博客会反复研读,尽量不断提升博客质量.文章设置为仅粉丝可见,是因为写博客确实花了不少精力.希望互相进步谢谢!! 文章目录 阅读前请看一下:我是一个热衷于记 ...

  9. ndk error: malloc was not declared in this scope

    error: 'malloc' was not declared in this scope 解决方法: NDK_TOOLCHAIN_VERSION=4.8 APP_CPPFLAGS += -frtt ...

最新文章

  1. Spark中常用的算法
  2. 幼儿园体育游戏电子计算机教案,幼儿园大班体育游戏教案
  3. 真格量化——做空波动率策略
  4. rabbitmq详细入门文档+springboot结合使用
  5. 如何给U盘设置一张妖娆又骚气的图标
  6. Canny边缘检测算法原理及其VC实现详解(一)
  7. 在Windows XP中轻松发传真
  8. Windows server 2008 R2搭建主域控制器 + 辅域控制器
  9. 微软自带的防反编译工具dotfuscator.exe的使用
  10. ICRA 2021| 基于精确和减少漂移的关注距离的Camera-IMU-UWB融合定位方法
  11. 逆袭?或将掌舵万亿SaaS巨头的Taylor竟是“天选之人”
  12. tensorflow 2.5.0 ( keras )搭建wgan-gp 和 div
  13. 《Android进阶之光》--Dagger2
  14. HTML5权威指南pdf
  15. html5创新创业模板,大学生创新创业计划书模板完整版.doc
  16. oralce 表字段扩容(修改表字段长度)
  17. win安装android系统服务,拯救你的旧电脑:整个win+Android的双系统
  18. 暨阳社区创始人游牧:为什么我们要转型?
  19. javax.el.PropertyNotFoundException: Property ‘XXX‘ not found on type xx.xx.xx.xx问题解决(el表达式))
  20. mac安装golang,编写第一个go程序

热门文章

  1. dapper(dapper框架)
  2. Java web系统打包成exe安装文件
  3. 疯狂springboot终极讲义笔记(二)
  4. 12 道腾讯前端面试真题及答案整理
  5. DELL 电脑 重装系统出现 no boottable devices found
  6. python Flask 编写 api 接口,CORS 解决 flask 跨域问题
  7. 在知乎上看到的一个关于Linux运维工程师必知的几点,希望对有志于从事运维工作的你有帮助
  8. 福建农林大学计算机与信息学院副书记,福建农林大学计算机与信息学院导师介绍:钟一文...
  9. C语言学生成绩信息管理系统课程设计报告
  10. 2019全国计算机模拟题,2019年全国计算机二级Java考试模拟习题3