0

I have a video file and I need to circle all moving objects in a certain frame I select. My idea of a solution to this problem is: Circle all moving objects (white areas) on a video on which was applied motion detector and circle the same areas on the original frame.

I am using BackgroundSubtractorGMG() from cv2 to detect movement

Below I show the way I expect this program to work(I used to paint, so I am now sure this is correct, but I hope it is good enough to demonstrate the concept)

The original frame

The frame with applied motion detector and selected moving objects

The final result

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60

1 Answers1

1

As others have said in comments:

  1. Get the mask from you background subtraction algorithm
  2. use cv.findContours(mask, ...) to find contours
  3. (optional) select which contours you want to keep (something like ((x, y), radius) = cv.minEnclosingCircle(contour) or a, b, w, h = cv.boundingRect(c) and if radius > 5
  4. use drawing functions like cv.rectangle or similar to draw the shape around the contour (like so: cv.rectangle(img, (a, b), (a + w, b + h), (0, 255, 0), 2))
fogx
  • 1,749
  • 2
  • 16
  • 38