I am getting this error:
Error: Assertion failed ((unsigned)i0 < (unsigned)size.p[0]) in cv::Mat::at
Problem Statement: I am trying to read each pixel value of the image.
int main()
{
std::string path = "E://Trial//lambo.png";
cv::Mat src = cv::imread(path);
cv::Mat srcBgra;
cv::cvtColor(src, srcBgra,cv::COLOR_BGR2BGRA);
std::cout<<"---Channels:"<<srcBgra.channels()<<std::endl;
for(int i=0; i<srcBgra.rows; i++)
{
for (int j = 0; j< srcBgra.cols; j++)
{
cv::Vec4b pixelValue = srcBgra.at<cv::Vec4b>(j,i);
std::cout<<"Pixel: "<<pixelValue<<std::endl;
}
}
cv::imshow("Display", src);
cv::imshow("Display 2", srcBgra);
cv::waitKey(0);
return 0;
}
I am getting abort error. Error: Assertion failed ((unsigned)i0 < (unsigned)size.p[0]) in cv::Mat::at
Any suggestions?
Please note: If I remove the Mat::at function part, the program is working fine. imshow() function is displaying both the images.