OpenCV 错误:断言失败((img.depth() == CV_8U || img.depth() == CV_32
OpenCV error : Assertion failed ((img.depth() == CV_8U || img.depth() == CV_32F)
当我尝试从这里在Visual Studio 2010中运行此代码时。 我收到以下错误
OpenCV Error: Assertion failed ((img.depth() == CV_8U || img.depth() == CV_32F)
&& img.type() == templ.type()) in cv::matchTemplate, file ........opencvmod
ulesimgprocsrctemplmatch.cpp, line 249
An exception occured
您似乎没有成功加载图像。因此,请确保通过设置正确传入图像argv[]
。请注意以下代码行:
if(argc <= 1)
{
std::cout<<"n Help "<<std::endl;
std::cout<<"n ------------------------------------n"<<std::endl;
std::cout<<"./blink_detect open_eye.jpg close_eye.jpgn"<<std::endl;
std::cout<<"Eg :: ./blink_detect 2.jpg 3.jpgn"<<std::endl;
std::cout<<"n ------------------------------------n"<<std::endl;
exit(0);
}
... ...
img1 = imread( argv[1], 1 );
img2 = imread( argv[2], 1 );
编辑:您可以通过两种方式设置argv[]
:
通过项目的命令参数:
Project > Configuration Properties > Debugging > Command Arguments > 2.jpg 3.jpg
直接在源代码中:
argc = 3; argv[1] = "2.jpg"; argv[2] = "3.jpg";
相关文章:
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 概念中的cv限定符需要表达式参数列表
- 将CHW格式的浮点向量转换为cv::Mat
- 错误的cv::face FacemarkLBF实例化
- 如何检查给定的参数是否为 cv::noArray()?
- 开放 CV 中的动态内存分配,用于视频处理
- 如何在 opencv 中使用 cv::VideoCapture::waitAny()
- 错误:未定义对cv::cudacodec::createVideoReader的引用
- OpenCV 3.4.1 error readNetFromTensorflow 无法在 cv::d nn::ReadProtoFromBinaryFile 中打开 .pb
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 选择基于另一个垫子的非零像素的cv::Mat的一部分?
- 将 cv::mat 转换为 QImage
- Inference pytorch C++ with alexnet and cv::imread image
- OpenCV 3.4.3 中对 'cv::String::d eallocate()' 错误的未定义引用
- cv::Normalise() 中的 L2_NORM 和 NORM_MINMAX 实现有什么区别?
- 将 cv::Mat 转换为 std::vector 的通用函数
- 如何在C++中设置演员的"Render Custom Depth Pass"和"Depth Stencil Value"?
- OpenCV undefined reference to 'cv::imread(cv::String const&, int)'
- 在 QML VideoOutput 中将 cv::mat 显示为 QVideoFrame
- 如何应用带有cv::cuda和C++的Canny Edge检测器?