Detected contours can be compressed to reduce the number of points. In this sense, OpenCV provides several methods to reduce the number of points. This can be set with the parameter method. Additionally, this compression can be disabled by setting the flag to cv2.CHAIN_APPROX_NONE, where all boundary points are stored; hence, no compression is performed.
The cv2.CHAIN_APPROX_SIMPLE method can be used to compress the detected contours because it compresses horizontal, vertical, and diagonal segments of the contour, preserving only endpoints. For example, if we use cv2.CHAIN_APPROX_SIMPLE to compress the contour of a rectangle, it will only be composed of four points.
Finally, OpenCV provides two more flags for compressing contours based on the Teh-Chin algorithm, which is a non-parametric method. The first step of this algorithm determines the region of support...