一.问题描述
调用ret, thresh = cv2.threshold(seg, 127, 255, cv2.THRESH_BINARY)进行二值化,出现
cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/thresh.cpp:1659: error: (-210:Unsupported format or combination of formats) in function 'threshold'
二.解决思路
我的seg数组默认是np.int64类型的,但是上述函数要求uint8 ,所以对seg加以下语句即可解决问题
seg = seg.astype(np.uint8)