Ask Your Question

Revision history [back]

What I do in C++ is the following. Maybe it can help to try and translate this to Java API.

// Create a dummy container for copying the original frame into
Mat image_copy;
// Copy over the image data
image_original.copyTo(image_copy);
// Draw the rectangle onto the copy
rectangle(image_copy, Point(roi_x0,roi_y0), Point(x,y), CV_RGB(255,0,0));
// Renew the window with the image
imshow(window_name, image_copy);

By copying the image into a dummy one, I make sure that the original one is not altered but the drawings are saved only for this local copy. I don't know if this would have effect to your case.