doubt about ROIs in android

asked 2014-08-21 13:32:37 -0500

borjaevo gravatar image


I have a doubt about how ROIs work on java. My way to create a ROI of an image is this:

Rect r1 = new Rect(x,y,sizex,sizey);
Mat roi1 = new Mat(A,r1);

where A is the source image. If i modify roi1 i also modify A? I want to do this to modify a concrete area of A but i do not get. What i'm doing wrong?

edit retag flag offensive close merge delete


yes, you modify the original image. a ROI does not make a copy of the pixels in opencv (no matter what language)

try: Mat roi_copy = new Mat(A,r1).clone(); , again, i'm not sure, what you wanted, please report back.

berak gravatar imageberak ( 2014-08-21 14:40:09 -0500 )edit

And this is a good way to create a ROI or is necessary to use submat?

borjaevo gravatar imageborjaevo ( 2014-08-21 14:42:51 -0500 )edit

both are equivalent. same output, same problem.

berak gravatar imageberak ( 2014-08-21 14:47:44 -0500 )edit

Thank you!

borjaevo gravatar imageborjaevo ( 2014-08-21 16:27:34 -0500 )edit