Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 执行阈值设置时出错预期Ptr<;cv::UMat>;对于参数';%s';_Python_Opencv_Image Processing_Computer Vision - Fatal编程技术网

Python 执行阈值设置时出错预期Ptr<;cv::UMat>;对于参数';%s';

Python 执行阈值设置时出错预期Ptr<;cv::UMat>;对于参数';%s';,python,opencv,image-processing,computer-vision,Python,Opencv,Image Processing,Computer Vision,我是OpenCv新手,我正在对灰度图像进行阈值处理,但它显示了一个错误,即TypeError:参数“%s”应为Ptr 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

我是OpenCv新手,我正在对灰度图像进行阈值处理,但它显示了一个错误,即TypeError:参数“%s”应为Ptr

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(灰色),只需要图像

导入cv2
灰色=cv2.CVT颜色(o,cv2.COLOR_bgr2灰色)
a、 thresh1=cv2.threshold(灰色,127255,cv2.THRESH_二进制)
cv2.imshow(“阈值1”,阈值1)
cv2.等待键(0)
cv2.destroyAllWindows()

,thresh1=cv2.阈值(灰色,127255,cv2.阈值二进制)
应该可以工作。
thresh1=cv2.阈值(cv2.UMat(灰色),127255,cv2.阈值二进制)[1]
是另一种方法