Is there any solution in opencv 2.4 which returns non-const reference to a sub-Mat?
I am asking this because I want to overwrite in place a subimage, defined by a roi,
but mat(roi) returns a const reference, so I can’t write say mat(roi)=mat2,
or cv::rectangle(mat(roi), rect_relative_to_roi).
EDIT: (I’ll be more specific using Andrej’s answer)
If I have defined complex drawing functions which work on a subimage,
is the only way I can avoid sending relative coordinates to the drawing function,
that I copy back and forth the subimage I want to work with?
I mean like this:
/* Mat canvas; */
Mat subimg = canvas(roi);
draw_sth(subimg);
subimg.copyTo(canvas(roi));
Well, it turns out
is the answer, it will modify the original canvas, as Mat’s are to be looked at as reference-counted smart pointers, they just point at the image data.
On the other hand, copyTo() is not good. Take a look at the opencv code: