Ask Your Question

Getting position of object calculated from background subtraction

asked 2014-09-10 10:46:47 -0500

emkuy3 gravatar image

I have been playing around with background subtractor MOG2 and have been able to get an output foreground mask where only the moving object in the video is shown.

The problem is sometimes the object can be split into multiple 'shapes' separated by black. Some examples:

image description

image description

What I would like to do is just get a bounding box of the detected object and therefore know its position in the frame. I have tried a basic findCountours function on the mask but that didn't pick the object as a single shape.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-09-10 11:45:03 -0500

berak gravatar image

updated 2014-09-10 11:47:30 -0500

if you're only interested in the position of the object, you could dilate it, until the gaps go away (before applying findContours):


image description

edit flag offensive delete link more

answered 2014-09-10 11:42:12 -0500

edit flag offensive delete link more

Question Tools


Asked: 2014-09-10 10:46:47 -0500

Seen: 615 times

Last updated: Sep 10 '14