I am trying to use the checkContour () function in the new python api (cv2) and it works do if I create the paths that need to be checked using findContours, for example.
contours, hierarchy = cv2.findContours(imgGray, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
cv2.contourArea(contours[0])
however, when I create the path myself, the following code does not work
contour = numpy.array([[0,0], [10,0], [10,10], [5,4]])
area = cv2.contourArea(contour)
and returns "error: (-215) contour.checkVector (2)> = 0 && (contour.depth () == CV_32F || contour.depth () == CV_32S) in the Area function loop"
when i switch to
contour = numpy.array([[0,0], [10,0], [10,10], [5,4]], dtype=numpy.int32)
I got an "error: (-210) The matrix could not be converted to a sequence of points due to an inappropriate element type in the cvPointSeqFromMat function"
How to make the following code in C ++ from the documentation
vector<Point> contour;
contour.push_back(Point2f(0, 0));
contour.push_back(Point2f(10, 0));
contour.push_back(Point2f(10, 10));
contour.push_back(Point2f(5, 4));
double area0 = contourArea(contour);
work in latest python API (2.3)?