未处理的异常绘图不使用 OpenCV 2.4.3 C++接口中的 fillPoly 凸多边形



我正在尝试使用OpenCV 2.4.3 c ++接口在二进制图像中绘制一些使用findContours找到的连接组件。代码是这样的。

std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours( tempOR, contours, hierarchy, CV_RETR_EXTERNAL , CV_CHAIN_APPROX_TC89_L1, cv::Point(0, 0) );
bgs_detection_or=cv::Mat::zeros(cv::Size(m_frame_width, m_frame_height), CV_8UC1);
for( int i = 0; i < contours.size(); i++ )
{
    if (pointPolygonTest(contours[i], cv::Point2f(m_car_coords.x, m_car_coords.y-1), false)>-1)
    {
        std::vector<cv::Point> contours_poly;
        approxPolyDP( cv::Mat(contours[i]), contours_poly, 3, true );           
        //cv::fillConvexPoly(bgs_detection_or, contours_poly, cv::Scalar(255));
        cv::fillPoly(bgs_detection_or, contours_poly, cv::Scalar(255));
        break;
    }
}

如您所见,我也尝试使用fillConvexPoly.fillConvexPoly不会抛出任何错误,但它没有正确绘制Poles。之后,我尝试使用 fillPoly,仅此而已,我无法管理未经处理的异常。

我也试着这样称呼 fillPoly:

cv::fillPoly(bgs_detection_or, contours_poly, contours_poly.size(), 1, cv::Scalar(255));

但是我有一个编译错误:错误 35 错误 C2665:"cv::fillPoly":2 个重载都无法转换所有参数类型

我做错了什么?

我找到了实现最终目标的解决方法:

drawContours( bgs_detection_or, contours, i, cv::Scalar(255), CV_FILLED);

但我不明白为什么 fillPoly 会抛出未处理的错误,而 fillConvexPoly 则不会。

最新更新