while True 20 ret frame = capread 21 if not ret or frame is None 22 break 23 24 frame = cv2flipframe 0 25 gray = cv2cvtColorframe cv2COLOR_BGR2GRAY 26 _ dst = cv2thresholdg
这个错误是因为 cv2.findNonZero() 函数的参数需要传入二值化后的图像,但是此处传入的是一个布尔型数组,导致函数不能正常工作。
解决方法是将布尔型数组转换为二值化后的图像,可以使用 np.uint8() 函数实现,具体代码如下:
white_index = cv2.findNonZero(np.uint8(color == 0))
原文地址: https://www.cveoy.top/t/topic/g9Lu 著作权归作者所有。请勿转载和采集!