cv::split in OpenCV 2.4.1 and Visual Studio

1

I had a problem while splitting rgb image into single channels. My simple code is as following

    **cv::Mat src = cv::imread("D:/Test/a.jpg", 1);
std::vector<cv::Mat> img_rgb;
cv::split(src, img_rgb);
cv::imshow("a", src);**

My debug shows that this probem come from the split function and the following errors was throwed. *Unhandled exception at 0x10005768 in Test_Opencv2.4.1.exe: 0xC0000005: Access violation reading location 0x000000bc.*

Does anyone know how to solve this problem? Thanks in advance!

c++
image
opencv
asked on Stack Overflow Jun 11, 2012 by XYZ

1 Answer

1

You might have to use the other slash and escape it, plus you always need to check the return of imread():

cv::Mat src = cv::imread("D:\\Test\\a.jpg", 1);
if (src.empty())
{
    std::cout << "!!! Couldn't load image" << endl;
    // exit
}
answered on Stack Overflow Jun 11, 2012 by karlphillip

User contributions licensed under CC BY-SA 3.0