import cv2 import numpy as np img = np.zeros((3,3)) img[1,1] = 2 img[0,2] = 2 print(img) mom = cv2.moments(img) print (mom['m00']) print (mom['m01']) print (mom['m10'])