[][src]Function opencv::imgproc::draw_contours

pub fn draw_contours(
    image: &mut dyn ToInputOutputArray,
    contours: &dyn ToInputArray,
    contour_idx: i32,
    color: Scalar,
    thickness: i32,
    line_type: i32,
    hierarchy: &dyn ToInputArray,
    max_level: i32,
    offset: Point
) -> Result<()>

Draws contours outlines or filled contours.

The function draws contour outlines in the image if inline formula or fills the area bounded by the contours if inline formula . The example below shows how to retrieve connected components from the binary image and label them: : @include snippets/imgproc_drawContours.cpp

Parameters

  • image: Destination image.
  • contours: All the input contours. Each contour is stored as a point vector.
  • contourIdx: Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
  • color: Color of the contours.
  • thickness: Thickness of lines the contours are drawn with. If it is negative (for example, thickness=#FILLED ), the contour interiors are drawn.
  • lineType: Line connectivity. See #LineTypes
  • hierarchy: Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see maxLevel ).
  • maxLevel: Maximal level for drawn contours. If it is 0, only the specified contour is drawn. If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account when there is hierarchy available.
  • offset: Optional contour shift parameter. Shift all the drawn contours by the specified inline formula .

Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly even when no hierarchy date is provided. This is done by analyzing all the outlines together using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved contours. In order to solve this problem, you need to call #drawContours separately for each sub-group of contours, or iterate over the collection using contourIdx parameter.

C++ default parameters

  • thickness: 1
  • line_type: LINE_8
  • hierarchy: noArray()
  • max_level: INT_MAX
  • offset: Point()