Ask Your Question

Revision history [back]

assertion Failed in Mat::at

If I try to execute this code:

image = imread(s);
GrayImage.create(Size(image.cols, image.rows), CV_8UC1);
    for (int st = 0; st < image.cols * image.rows * 3; st += 3)
           GrayImage.at<unsigned char>(st / 3) = g.getValue(BGR(image.at<unsigned char>(st),
                                    image.at<unsigned char>(st + 1), image.at<unsigned char>(st)));

I get the error:

OpenCV Error: Assertion failed (elemSize() == (((((DataType<_Tp>::type) & ((512 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)16384|0x3a50) >> ((DataType<_Tp>::type) & ((1 << 3) - 1))2) & 3))) in cv::Mat::at

(I debugged it the error occurs when calling GrayImage.at[...]) Does somebody know what this error means and how to fix it? I googled it already, but there wasn't a working solution until now.