繁体   English   中英

在执行阈值预期 Ptr 时出错<cv::UMat>对于参数“%s”

[英]getting an error while doing thresholding Expected Ptr<cv::UMat> for argument '%s'

我是 OpenCv 的新手,我正在对灰度图像进行阈值处理,但它显示了一个错误,即TypeError: Expected Ptr for argument '%s'

grey = cv2.cvtColor(o, cv2.COLOR_BGR2GRAY)
thresh1 = cv2.threshold(cv2.UMat(grey),127,255,cv2.THRESH_BINARY)
cv2.imshow("thresh1",thresh1)
cv2.waitKey(0)
cv2.destroyAllWindows()

你不需要 cv2.UMat(grey),只需要图像。

import cv2
grey = cv2.cvtColor(o, cv2.COLOR_BGR2GRAY)
a, thresh1 = cv2.threshold(grey, 127, 255,cv2.THRESH_BINARY)
cv2.imshow("thresh1",thresh1)
cv2.waitKey(0)
cv2.destroyAllWindows()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM