Ask Your Question
0

fillPoly crashes

asked 2014-09-10 06:09:55 -0600

thdrksdfthmn gravatar image

I have called

 std::vector< cv::Point > contour = contourIn; // initialization with input contour
 cv::Mat maskC(cv::Size(680, 480), CV_8UC1, cv::Scalar::all(0));
 cv::fillPoly(mask, contour, cv::Scalar::all(255));

fillPoly is crashing saying:

OpenCV Error: Assertion failed (i < 0) in getMat, file /home/stefan/git_repos/opencv/modules/core/src/matrix.cpp, line 963

Before I was having the same code, but I was calling the fillConvexPoly instead of fillPoly:

cv::Mat maskC(cv::Size(680, 480), CV_8UC1, cv::Scalar::all(0));
std::vector< cv::Point > contourCvx = convexingContour(contourIn); // initialization with the convex hull of the input contour
cv::fillConvexPoly(maskC, contourCvx, cv::Scalar::all(255));

I am using this to create a mask of the contours interior. I have changed to fillPoly because the input contour is not always convex.

Please help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-09-10 07:45:13 -0600

Siegfried gravatar image

Hi, check the parameter you put into cv::fillPoly(...). In the documentations of fillPoly other types are used as in your code.

An example how to use fillPoly can be found in the opencv tutorials section here. There is also a question on stackoverflow regarding on how to draw a contour / polygon (using cv::fillPoly(...)).

edit flag offensive delete link more

Comments

yes, I have seen that, it needs a vector of contours (ArrayOfArray), thanks anyway. I am wandering why fillPoly has different parameters than fillConvexPoly?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-09-10 08:49:16 -0600 )edit

Question Tools

Stats

Asked: 2014-09-10 06:09:55 -0600

Seen: 6,666 times

Last updated: Sep 10 '14