0
我得到對象的質心圖像中是這樣的:開放CV,IMG [X,Y]總是返回0
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
_, contours, _ = cv2.findContours(gray.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_TC89_L1)
centres = []
for i in range(len(contours)):
moments = cv2.moments(contours[i])
centres.append((int(moments['m10']/moments['m00']), int(moments['m01']/moments['m00'])))
我遍歷中心,並試圖讓每個中心像素的顏色。出於某種原因,所有的回報是0,0,0
for c in centres:
print img[c]
我也得到這個錯誤
IndexError: index 484 is out of bounds for axis 0 with size 480