OpenCV Bounding Box

前端 未结 4 1724
一整个雨季
一整个雨季 2020-12-08 17:59

I am working on software using OpenCV in C++ environment. The objective is to detect a boxing glove and draw a bounding box around gloves contours.

4条回答
  •  不思量自难忘°
    2020-12-08 18:46

    You currently draw a bounding box around each contour, and findContour will find a contour around each connected white or black component, of which there are many in your picture.

    So the first thing I would do is filter all that noise with some morphological operations on the thresholded image: do some opening and closing, both of which are combinations of dilation and erosion.

    In your case something like cvDilate (2 times); cvErode(4 times); cvDilate(2 times)

    This should merge all white blobs into one smooth blob, but the black hole in the middle will remain. You could find the right one by size, but it is easier to call findContours with the CV_RETR_EXTERNAL instead of CV_RETR_TREE, then it will only return the outermost contours.

提交回复
热议问题