I'm making an android application with opencv that involves cutting images by hand and I'm having a problem. I recover the points that the user makes with his hand on the screen and then I apply a mask on the original image to get the part that the user wants. My concern is that when the user does not finish the drawing correctly, you can end up with a big line that goes from the last point to the first point. I would like, as a snapchat, to be able to make a cut without completely following the user's path but by surrounding his path.
For the moment I use the following functions :
Imgproc.fillPoly(mask,pts,new Scalar(255,255,255,255));
Core.bitwise_and(img, mask, dst);
pts are the points that the user sends after the plot.
img is the basic image