I have used OpenCV 2.3.1 with Android 2.2 to find contours in bitmaps which seems to be working fine on Samsung Galaxy Ace, but now I need help with moving those contours. My aim is to make a selected contour follow the user’s finger when dragged to a different location. Help of any kind would be appreciated.
EDIT:
I am now able to move the contours based on the user’s touch, but then they don’t stay at the new position. So, I assume I need to erase the image from the original position and redraw it at the new one. Moreover, its only the surrounding contour which moves and not the pixels of the image within the contour. I am more concerned about the image pixels. How can I get the image pixels to move to the new location? It would also be great if I could somehow get the co-ordinates of the pixels within the contour.
Sorry, I wanted to upload an image but it seems new members cant upload images at this stage. For example – I have the contour surrounding the line in pink. When I drag, only the contour moves and the black pixels of the line do not move at all. Is there any way by which I can get the black pixels within the pink contour to move?
Another problem is that when I try my code on a closed figure like a circle or a square, I get two contours. One for the inner boundary and one surrounding for the outer boundary. But again as I said earlier, I am more interested in the image pixels. Please help.
P.S. – The image can be anything, any shape. I have just taken the example of a line.
First of all you have to add
TouchListener/ClickListener(or something else, I don’t knowAndroid API) to your bitmap or canvas.When user is touched the screen (listener is fired) than you have to identify which contour has user selected. For this use pointPolygonTest function.
About moving:
Contouris just a sequence (vector) ofPoints so if you want to shift (move) some contour you have to do the following (c++ code):Hope it helps.