Closed nithinreddyy closed 2 years ago
Hi @nithinreddyy, This project is limited to dragging a single rectangle on an image. I don't have any plans to add support for multiple rectangles. Thanks, @arccoder
You can draw multiple ones, but only the last one will be shown as follows: Define a global var: drageRects=[]
In Function def dragrect(event, x, y, flags, dragObj) add:
if event == cv2.EVENT_RBUTTONDOWN:
drageRects.append(copy.deepcopy(dragObj))
dragObj.reset()
print("Reset",len(drageRects))
mouseUp(dragObj)
Add the function reset to Dragrectangle: def reset(self):
self.outRect.x = 0
self.outRect.y = 0
self.outRect.w = 0
self.outRect.h = 0
self.active = 0
Now, whenever you rightclick the current rectangle is added to the list of drageRects and you can start drawing a new one.
I'm unable to draw multiple rectangles in the same image. Can anyone help me with this?