cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/thresh.cpp:1659: error: (-210

created at 01-30-2022 views: 83

problem Description

Call ret, thresh = cv2.threshold(seg, 127, 255, cv2.THRESH_BINARY) for binarization, appear

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'

solutions

My seg array is of type np.int64 by default, but the above function requires uint8, so adding the following statement to seg can solve the problem

seg = seg.astype(np.uint8)
created at:01-30-2022
edited at: 01-30-2022: