I am working on a image processing project and i am encountering a crash in the system. This is the error that keeps popping:
OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channel s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3 ) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file d:\libs\opencv-249\build\i nclude\opencv2\core\mat.hpp, line 537
I was able to find that the following bit of code is making the problem
samples = (src.size(), src.type());
imshow ("source" , src);
for( int y = 0; y < src.rows; y++ )
for( int x = 0; x < src.cols; x++ )
for( int z = 0; z < 3; z++){
samples.at<float>((y + (x*src.rows)), z) = src.at<Vec3b>(y,x)[z];}
samples is a Mat object that is declared in the header file of this class.
I also referred to this link but even though the error is the same the code that is causing the crash is not the same as mine. But the awkward thing is that this exact piece of code works fine within another function, but when i try to include the same code within a method that belongs to a class it is making this error.
I am clueless. Can anyone help me out?

