In mathematics, a moment can be seen as a specific quantitative measure of a function shape. An image moment can be seen as a weighted average of image pixel intensities, or a function of such moments, encoding some interesting properties. In this sense, image moments are useful to describe some properties of the detected contours (for example, the center of mass of the object, or the area of the object, among others).
cv2.moments() can be used to calculate all the moments up to the third order of a vector shape or a rasterized shape.
The signature for this method is as follows:
retval = cv.moments(array[, binaryImage])
Therefore, in order to calculate the moments for a detected contour (for example, the first detected contour), perform the following:
M = cv2.moments(contours[0])
If we print M, we get the following information:
{'m00': 235283.0, 'm10...