Save the point coordinates of the output contour. Usually, the vector<vector<Point>> data type is used, and it can be seen from Point that the coordinates are stored.
hierarchy
Optional parameter, save the hierarchical relationship of the output contour. Usually the vector<Vec4i> data type is used. See details below
mode
Contour level detection mode, see below for details
method
How to store contour coordinate points, see below for details
offset
Additional offset, added to each detected contour point, can be negative. When the analyzed image is the ROI of another image, by adding or subtracting this offset, the detection results of the ROI image can be projected to the corresponding position of the original image.
hierarchy[i][0]: The index number of the next contour at the same level of the i-th contour.
hierarchy[i][1]: The index number of the previous contour of the same level of the i-th contour.
hierarchy[i][2]: The index number of the sub-contour of the i-th contour.
hierarchy[i][3]: The index number of the parent contour of the i-th contour.
If the current contour does not correspond to the next contour, previous contour, parent contour or embedded contour, the corresponding bits of hierarchy[i][0] ~hierarchy[i][3] are set to the default value -1.
1.2 Contour level detection mode: index number (level)
RETR_EXTERNAL (index order: bottom right to top left)
Only the outermost contour is detected, and inner contours contained within the outer contour are ignored.
RETR_LIST(recommended) (index order: from bottom right to top left, from outside to inside)
Detect all contours, including inner and outer contours, but the detected contours do not establish a hierarchical relationship, which means that there is no parent contour or embedded contour in this retrieval mode, so the hierarch[i] vector of all elements 3. The fourth component will be set to -1.
RETR_CCOMP(not recommended) (index order: from inside to outside, from bottom right to top left)
All contours are detected, but only two hierarchical relationships are established for all contours. The outer periphery is the top layer. If the inner contour within the outer periphery also contains other contour information, all contours within the inner periphery belong to the top layer.
RETR_TREE(recommended)
All contours are detected and a hierarchical tree structure is established for all contours. The outer contour contains the inner contour, and the inner contour can continue to contain inline contours.
Save all continuous contour points on the object boundary into the contours vector
CHAIN_APPROX_SIMPLE(recommended)
Only the inflection point information of the contour is saved, and all points at the inflection points of the contour are saved into the contours vector. The information points on the straight line segments between the inflection points are not retained, which is relatively efficient.
CHAIN_APPROX_TC89_L1或CV_CHAIN_APPROX_TC89_KCOS
Use tehChinl chain approximation algorithm (not important)
The index value of the contour to be drawn, enter -1 to draw all contours
color
The color of the drawn line
thickness
The thickness of the drawn line. If it takes a negative value, it means filling
lineType
The connectivity type for drawing lines
hierarchy
Optional hierarchy information. It is only used when you need to draw some outlines. (See parameter maxLevel for details) The default is noArray(), which returns an empty array.
maxLevel
The highest level for drawing contour lines. This parameter is only considered when the parameter hierarchy is valid. See the table below for details
offset
Extra offset, which is added to each drawn contour point, can be negative. When the analyzed image is the ROI of another image, by adding or subtracting this offset, the rendering result of the ROI image can be projected to the corresponding position of the original image.
Optional values for maxLevel are as follows:
maxLevel optional value
meaning
0
Only the specified outline is drawn
1
Draw the specified contour and its subordinate contours
2
Draws the specified contour and all its sub-contours
Directional area signs (not important). If true: This function returns the value of a marked area depending on the direction of the contour (clockwise or counterclockwise). If false: The default value means that the absolute value without direction is returned.
This function uses Green's formula to calculate the area of a contour. For contours with self-intersection points, this function will almost certainly give incorrect results.
Set the accuracy. The smaller it is, the higher the accuracy is. The polygon is closer to the curve, and the fitting effect is better but the efficiency is low.
Output the convex hull. Data type depends on returnPoints, vector<Point> or vector<int>
clockwise
The direction of rotation of the line fitting the convex hull, clockwise if TRUE, counterclockwise otherwise.
returnPoints
If true, the coordinates of the point are stored in hull. If it is false, the index of the point is stored in the hull, and the index value is obtained according to the parameter points. Default is true