i am running a basic application using openCV for C++. I am attempting to split the image into rgb components using cvSplit()
as below:
CvMat* mat;
//initialize mat
CvMat* b = cvCreateMat(mat->rows, mat->cols, CV_8UC1);
CvMat* g = cvCreateMat(mat->rows, mat->cols, CV_8UC1);
CvMat* r = cvCreateMat(mat->rows, mat->cols, CV_8UC1);
cvSplit(mat, b, g, r, NULL );
It builds just fine, but when I attempt to run it, I get the following error:
OpenCV Error: Assertion failed (i < src.channels()) in cvSplit, file /home/username/Downloads/OpenCV-2.4.0/modules/core/src/convert.cpp, line 1196
terminate called after throwing an instance of 'cv::Exception'
What does this error mean, and how can I solve the problem?
The IplImage you are using to create the Mat should be in color. You need three channels to be able to use cvSplit
. You can check this with IplImage->nChannels
in your debugger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.