I have a contour represented by a std::vector<cv::point2f> and I have to find its convexity defects.
So I write these 2 lines (cHull is a vector of integer indices) :
cv::convexHull( calibContour , cHull ) ;
cv::convexityDefects( calibContour , cHull , defects )
And at runtime I get this error:
OpenCV Error: Assertion failed (npoints >= 0) in convexityDefects, file /home/nvidia/Desktop/opencv-3.3.1/modules/imgproc/src/convhull.cpp, line 274
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/Desktop/opencv-3.3.1/modules/imgproc/src/convhull.cpp:274: error: (-215) npoints >= 0 in function convexityDefects
The 274th line of convexhull.cpp does in fact check for the presence of points in the contour, but only for signed integers:
npoints = points.checkVector(2, CV_32S);
Why is that so?
I don't want to convert the vector from float to integer, as I am writing a time-sensitive application.
Can I just change or remove che typecheck in the opencv code and rebuild it?
Thanks for your answers, cheers,
Giacomo