No segmentation fault while it should
Sometimes I do not get a segmentation fault (while I should) when I access the image with:
image.at<uchar>()
For example, if I declare an image of size 800 x 800 and access a pixel outside this range I may not get a segmentation fault. E.g.
Mat image_test(800, 800, CV_8UC1, Scalar(0));
std::cout << "value: " << (int) image_test.at<uchar>(850, 2) << std::endl;
In the code above it just prints a value 146 which is of course impossible since all pixels are initialized with zero. My question is what does really happen behind the scene?
debug mode should trigger an exception there.
(also, 850x2 is still insde the linear image memory, try 900x900 or such.)
Tried with image_test.at<uchar>(900, 900) and still not segmentation fault. Can I enable debug mode with gcc? Because I do not use cmake for this project.. Also how do you know the space of linear memory?
gcc -g my.cpp ...
but then you have to link to debug opencv libs, too, meaning, you probably need a 2nd cmake/make/make install pass