Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

initialise a 4 channel matrix opencv

I am trying to initialise a 4 channel matrix with row = 1 and columns = 5, but I am always getting an exception error: (-215) (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()) . Anyone knows what I am doing wrong.

            cv::Mat_<char> samples(1,5,CV_8UC4);

            samples.at<cv::Vec4b>(0,0) =  { 1,  2 , 3 , 4 } ;
            samples.at<cv::Vec4b>(0,1) =  { 1,  2 , 3 , 4 } ;
            samples.at<cv::Vec4b>(0,2) =  { 1,  2 , 3 , 4 } ;
            samples.at<cv::Vec4b>(0,3) =  { 1,  2 , 3 , 4 } ;
            samples.at<cv::Vec4b>(0,4) =  { 1,  2 , 3 , 4 } ;