【发布时间】:2017-11-01 17:01:02
【问题描述】:
我一直在寻找使用 OpenCV 分离 RGB 层并仅提取图像的绿色层的方法,但是当我想运行从代码生成的可执行文件时,我得到了这些错误,我有是这样的:
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>
using namespace cv;
using namespace std;
Mat img, g, fin_img;
img = imread("img.png",CV_LOAD_IMAGE_COLOR);
vector<Mat> channels(3);
g = Mat::zeros(Size(img.rows, img.cols), img.type());
channels.push_back(g);
channels.push_back(g);
channels.push_back(img);
merge(channels, fin_img);
imshow("img", fin_img);
waitKey(0);
return 0;
错误是这样的:
OpenCV 错误:合并中的断言失败 (mv[i].size == mv[0].size && mv[i].depth() == depth),文件 /opt/opencv/modules/core/src /convert.cpp,第 336 行 在抛出 'cv::Exception' 的实例后调用终止 what(): /opt/opencv/modules/core/src/convert.cpp:336: 错误: (-215) mv[i].size == mv[0].size && mv[i].depth() == 函数合并的深度
【问题讨论】:
-
rows = src.rows;只有我还是src不见了? -
我更正了代码,道歉,但是这段代码确实可以编译,但是当要执行它时,它显示了我输入的错误