Thursday 15 April 2010

python - Selecting contours error -


I'm working on a project involving the division of computer image processing items and I found the shape, but I only draw some For those of them, for example, writing error to fill it with the first one color error: Unfortunately, I'm getting this error. Logic 'contour' expected CvSeq to

The code where the error occurs piece

  mem = CV. CreateMemStorage () nc = cv.FindContours (img_th, meme, cv.CV_RETR_LIST, cv.CV_CHAIN_APPROX_SIMPLE, (0,0)) c = nc [1] cv.DrawContours (img_adth, c, cv.CV_RGB (255,0,0 ), cv.CV_RGB (0,255,0), 2,2, -1)    

You are getting the error from the drawing function.

I've never used OpenCV python API, but I think unlike C ++, C and Python API have a different style of representing the figure.

In C ++, you can choose a contour ID and attract only one. If you want to attract all shapes, then enter ID = -1.

You "point only in the vector to draw him a" C / Python therefore, is a pointer to the shape (NC) first contour. If you want to attract all shapes, then you use the loop for a while (profile! = Null).

To be more clear, I have changed your code in such a way, try to use this one I am not sure that it is quiet, so I know that it works a ..

  ... c = select nc.next // you exact cv.DrawContours (img_adth, c, CV to .CV_RGB (255,0,0), Cv.CV_RGB (0,255,0), 2,2, -1)    

No comments:

Post a Comment