Method FindContours
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
FindContours(InputArray, out Point[][], out HierarchyIndex[], RetrievalModes, ContourApproximationModes, Point?)
Finds contours in a binary image.
public static void FindContours(InputArray image, out Point[][] contours, out HierarchyIndex[] hierarchy, RetrievalModes mode, ContourApproximationModes method, Point? offset = null)
Parameters
imageInputArraySource, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. Zero pixels remain 0’s, so the image is treated as binary. The function modifies the image while extracting the contours.
contoursPoint[][]Detected contours. Each contour is stored as a vector of points.
hierarchyHierarchyIndex[]Optional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i], the members of the elements hierarchy[i] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
modeRetrievalModesContour retrieval mode
methodContourApproximationModesContour approximation method
offsetPoint?Optional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
FindContours(InputArray, out Mat[], OutputArray, RetrievalModes, ContourApproximationModes, Point?)
Finds contours in a binary image.
public static void FindContours(InputArray image, out Mat[] contours, OutputArray hierarchy, RetrievalModes mode, ContourApproximationModes method, Point? offset = null)
Parameters
imageInputArraySource, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. Zero pixels remain 0’s, so the image is treated as binary. The function modifies the image while extracting the contours.
contoursMat[]Detected contours. Each contour is stored as a vector of points.
hierarchyOutputArrayOptional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i], the members of the elements hierarchy[i] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
modeRetrievalModesContour retrieval mode
methodContourApproximationModesContour approximation method
offsetPoint?Optional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.