OpenCV groupRectangles - getting grouped and ungrouped rectangles

前端 未结 3 1540
臣服心动
臣服心动 2020-12-03 00:03

I\'m using OpenCV and want to group together rectangles that have significant overlap. I\'ve tried using groupRectangles for this, which takes a group threshold

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 00:29

    The solution I ended up going with was to duplicate all of the initial rectangles before calling groupRectangles. That way every input rectangle is guaranteed to be grouped with at least one other rectangle, and will appear in the output:

    int size = rects.size();
    for( int i = 0; i < size; i++ )
    {
        rects.push_back(Rect(rects[i]));
    }
    groupRectangles(rects, 1, 0.2);
    

提交回复
热议问题