opencv cvtColor断言失败c++
opencv cvtColor assertion failed C++
当我尝试将输入图像转换为灰度时,我得到一个断言错误。我见过很多帖子都围绕着同样的问题,但似乎没有人给出错误的原因。在下面的代码中,输入不是NULL,并且是从我的驱动器上的图像"test.jpg"加载的使用imgRead。
Mat img_gray;
cvtColor(input, img_gray, CV_BGR2GRAY);
断言错误:
OpenCV自动车牌识别使用file: testOpenCV错误:断言失败(scn == 3 || scn == 4)在cvtColor,文件/opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/OpenCV/work/OpenCV -2.4.9/modules/imgproc/src/color.cpp,行3737libc + + abi。终止调用抛出异常
代码取自https://github.com/MasteringOpenCV/code/blob/master/Chapter5_NumberPlateRecognition/DetectRegions.cpp
检查第72行。
我试了很多照片都没有运气。任何建议都将不胜感激。由于
该断言消息意味着您传入的图像不是3或4通道。例如,如果你传入一个通道灰度图像,它将失败。
试着输入
std:: cerr & lt; & lt;image changes: " <<image.channels () & lt; & lt;std:: endl;
紧接cvtColor()
。我确信它不会输出3或4。
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 生成MRPT库时cmake配置失败
- 为什么除非添加括号,否则构造函数上的模板替换会失败?
- variadic模板中的模板参数推导失败