Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Image moments help you to calculate some features like center of mass of the object, area of the object etc.

See it for more information

Suppose you have a contour cnt that is found from cv2.findContours()

M = cv2.moments(cnt)

From this moments, you can extract useful data like area, centroid etc. Centroid is given by the relations:

cx = int(M['m10']/M['m00'])

cy = int(M['m01']/M['m00'])