Reputation: 49329
I am using background subtraction to detect movement on the screen then I use cvFindContours to detect contours when I use cvBoundingRect I get a lot of small rectangle this is due to background subtraction does not return smooth connected binary image there are holes in the diff image which causes a lot of little rectangles. My question is how can I group these little rectangles in to a bigger rectangle around the whole movement.
Upvotes: 1
Views: 576
Reputation: 2702
It depends on how disconnected are your detected contours, you could try to smooth your Image using cvSmooth and then apply some morphological operators such as Dilation (cvDilate()) and Closing (cvMorphologyEx()).
cvDilate() for example takes an IplConvKernel produced by CreateStructuringElementEx and you can make a structuring element that best suits your needs.
Upvotes: 1