Failure to use adaptiveThreshold: CV_8UC1 in function adaptiveThreshold

前端 未结 6 1011
执笔经年
执笔经年 2020-12-15 03:29

I have used openCV python and encountered an error.

img_blur = cv2.medianBlur(self.cropped_img,5)
img_thresh_Gaussian = cv2.adaptiveThreshold(img_blur, 255,          


        
6条回答
  •  感情败类
    2020-12-15 03:45

    you can change the code to slightly like this :

    img_blur = cv2.medianBlur(self.cropped_img,5).astype('uint8')
    img_thresh_Gaussian = cv2.adaptiveThreshold(img_blur, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
    

    just by adding ('uint8') while blurring has resolved my issue.

提交回复
热议问题