Approximate polygon — exact port of CV.approxPolyDP from js-aruco2.
This version handles CLOSED contours correctly using the circular indexing
approach from the JS implementation.
Select the corner of a polygon that is most “extreme” in the given directions.
Port of ArUcoScanner.prototype._getExtreme from JS.
mode_x: true for max, false for min
mode_y: true for max, false for min