Reputation: 490
I am trying to draw in a binary image some connected component found with findContours, using OpenCV 2.4.3 c++ interface. The code is like this.
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;
}
}
As you can see, I also tried to use fillConvexPoly. fillConvexPoly does not throw any error, but it does not draw correctly the polies. After that I tried to use fillPoly, and that is all, I cannot manage the unhandled exception.
I also tried to call fillPoly this way:
cv::fillPoly(bgs_detection_or, contours_poly, contours_poly.size(), 1, cv::Scalar(255));
But then I have a compile error: Error 35 error C2665: 'cv::fillPoly' : none of the 2 overloads could convert all the argument types
What am I doing wrong?
Upvotes: 1
Views: 1834
Reputation: 490
I found a workaround to achieve the final goal:
drawContours( bgs_detection_or, contours, i, cv::Scalar(255), CV_FILLED);
But I cannot understand why fillPoly throws unhandled error while fillConvexPoly is not.
Upvotes: 1