[][src]Function opencv::imgproc::min_enclosing_triangle

pub fn min_enclosing_triangle(
    points: &dyn ToInputArray,
    triangle: &mut dyn ToOutputArray
) -> Result<f64>

Finds a triangle of minimum area enclosing a 2D point set and returns its area.

The function finds a triangle of minimum area enclosing the given set of 2D points and returns its area. The output for a given 2D point set is shown in the image below. 2D points are depicted in red and the enclosing triangle in yellow.

Sample output of the minimum enclosing triangle function

The implementation of the algorithm is based on O'Rourke's ORourke86 and Klee and Laskowski's KleeLaskowski85 papers. O'Rourke provides a inline formula algorithm for finding the minimal enclosing triangle of a 2D convex polygon with n vertices. Since the #minEnclosingTriangle function takes a 2D point set as input an additional preprocessing step of computing the convex hull of the 2D point set is required. The complexity of the #convexHull function is inline formula which is higher than inline formula. Thus the overall complexity of the function is inline formula.

Parameters

  • points: Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector<> or Mat
  • triangle: Output vector of three 2D points defining the vertices of the triangle. The depth of the OutputArray must be CV_32F.