Ask Your Question
0

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
1

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):

dilate(img,img,getStructuringElement(MORPH_ELLIPSE,Size(6,6)));

image description

edit flag offensive delete link more
2

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

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

Seen: 495 times

Last updated: Sep 10 '14