How it works...
cv2.contourArea computes the area of a contour, as implied by its name. It takes a point set which represents a contour as its first argument, and a Boolean flag as its second one. The routine returns the float-point area of the contour. The flag allows us to compute either the signed (when True) or unsigned (when False) area, where the sign stands for a clockwise or counter-clockwise order of points in the contour. An important note about cv2.contourArea is that it's not guaranteed that the area is correct for contours with self-intersection.
The function to get the length of a curve is cv2.arcLength. It accepts two parameters, a contour as a first argument, and a flag as a second. The flag controls the closedness of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access