-210Unsupported format or combination of formats,in function cv,moments

(-210:Unsupported format or combination of formats) in function ‘cv::moments’

原始程序报错部分:
from cv2 import moments #计算外边缘质心 M = cv2.moments(outer_edge+0) center_x = int(M["m10"] / M["m00"]) center_y = int(M["m01"] / M["m00"])
这是因为moments()函数输入必须为array类型,且其中元素必须为浮点型。
改正之后:
from cv2 import moments #计算外边缘质心 M = cv2.moments(outer_edge+0.0) center_x = int(M["m10"] / M["m00"]) center_y = int(M["m01"] / M["m00"])
新手小白,请多指教,谢谢!

你可能感兴趣的:(-210Unsupported format or combination of formats,in function cv,moments)