Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

.1. Sometimes, there is a square bracket with values e.g. [-1], [0] behind the function

the square bracket with number states which contour you are considerin to use, as it always results in multiple contours, so using '[]' with a number you an decide which contour you want, starting from 0.

2. what is the meanning of [, contours[, hierarchy[, offset]]]

contours –Contours is a list, or tree of lists of points. The points describe each contour, that is, a vector that could be drawn as an outline around the parts of the shape based on it's difference from a background.

hierarchy – 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 elements hierarchy[i][0] , hiearchy[i][1] , hiearchy[i][2] , and hiearchy[i][3] 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. Hierarchy shows how the shapes relate to each other, layers as such - if shapes are on top of each other this can be determined here. See this : https://docs.opencv.org/trunk/d9/d8b/tutorial_py_contours_hierarchy.html to understand hierarchy

Also check this documentation for more details: https://docs.opencv.org/3.3.1/d4/d73/tutorial_py_contours_begin.html