why am i getting so many roi crashes
I don't think i understand copyTo/roi very well because the moment i fiddle with the size of a picture i copy onto another Mat (like picture in picture) i get opencv crashing on me with assertion statements.
What am i doing wrong, or how do i protect against this ? What are the rules?
I understand you can't copy a mat that is bigger then another mat into it. I think i also get crashes when work is done on a empty mat.
I can provide some example code.
Hello there, could you give us the exact assertion statements ? :)
Stuff like this essentially: http://answers.opencv.org/question/97...
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /tmp/opencv-20160502-20452-13c59z2/opencv-2.4.12/modules/core/src/matrix.cpp, line 323 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-20160502-20452-13c59z2/opencv-2.4.12/modules/core/src/matrix.cpp:323: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
@atv In OpenCV, it seems that the size of a picture has to be inverted according to the matrix initialization. For example, a picture with a size of 640x480 has to be initialized as a matrix like so :
Are you sure the matrix is well initialized according to the picture size ?
EDIT: It should be helpful if you code give us some example code to help your further. :)
I didn't know that.I'm using something like this: https://github.com/Itseez/opencv_cont...
So i don't think it's ever specifically initialized, i think it uses the webcam's resolution/capability. That is basically the code i'm using. I then use :
int pos_x = std::max(face_i.tl().x, 0); // Used to be x-10 int pos_y = std::max(face_i.tl().y, 0); // Used to be y-10
cv::Mat subview = srcBGR(roi); // subview.copyTo(original(roi_dst));
To copy a small picture into the rectangle and i use the if checks to hopefully safeguard me against roi crashes. But if i put a picture somewhere else (outside of the rectangle), or if i enlarge this picture, say 0,0 then it crashes very quickly.
@atv Try to insert some debug messages to verify some values, especially srcBGR.cols and srcBGR.rows, what do they tell you ?