Regarding the imutils
library related to OpenCV, I have the following questions:
What is the function of contours.sort_contours()
?
(cnts, _) = contours.sort_contours(cnts)
In the above statement, what is the meaning of (cnts, _)
, especially '_'
Note: cnts
is a variable containing the contours of the recognized image
My English is not very good, sorry! Thank you all for your answers and help!
The imutils
library is a convenience library written to make basic image processing tasks easier (https://github.com/PyImageSearch/imutils).
One such task is sorting and labelling contours in images. Based on documentation provided here, there is a separate contours.py
file hosting sort_contours()
and label_contour
functions. (You need to remember that these functions can be used only after finding contours using OpenCV
)
Now to answer your questions:
1. What is the function of contours.sort_contours()
?
sort_contour()
from the file contours.py
in this way: contours.sort_contours()
.2. Understanding (cnts, _) = contours.sort_contours(cnts)
cnts
.cnts
is used to store the sorted contours._
, which stores the bounding boxes. _
is mostly used a variable when it will not be needed for further processing.