在 opencv 3.0 C++ 中擦除 boundRect

Erase a boundRect in opencv 3.0 C++

我正在使用轮廓在图像中查找对象。并且我将可能的候选人附在 boundRects 中以查看最终结果,我想删除高度 > 宽度(将其附在黑色圆圈中)的决赛重角。任何建议这样做。感谢您的帮助和回复。我的代码是:

enter vector<vector<Point> > contours_poly(contours.size());
            vector<Rect> boundRect(contours.size());

            for (size_t i = 0; i < contours.size(); i++)
            {
                approxPolyDP(Mat(contours[i]), contours_poly[i], 3, true);
                boundRect[i] = boundingRect(Mat(contours_poly[i]));
            }
             for (int i = 0; i < contours.size(); i++)
            {
                Scalar color = Scalar(255, 0, 255);
                rectangle(result_white, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0);
                rectangle(imageLoad, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0);
            }
            imshow("white final", imageLoad);

最后的结果是: final image

为什么要删除它们?

如果不符合您的要求,请不要将它们附加到矩形矢量(对矢量使用 push_back)。