本文介绍了无法使用adaptiveThreshold:函数AdaptiveThreshold中的CV_8UC1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用过openCV python并遇到错误.
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, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
plt.subplot(1,1,1),plt.imshow(img_thresh_Gaussian, cmap = 'gray')
plt.title("Image"), plt.xticks([]), plt.yticks([])
plt.show()
但我收到了:
cv2.error: /home/phuong/opencv_src/opencv/modules/imgproc/src/thresh.cpp:1280: error: (-215) src.type() == CV_8UC1 in function adaptiveThreshold
我还必须安装其他东西吗?
Do I have to install something else?
推荐答案
您应该这样加载文件
src.create(rows, cols, CV_8UC1);
src = imread(your-file, CV_8UC1);
然后是
adaptiveThreshold(src, dst, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 75, 10);
这篇关于无法使用adaptiveThreshold:函数AdaptiveThreshold中的CV_8UC1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!