python - 类型错误:预期的 Ptr对于参数'src'?
问题描述
每当我使用 cv2.dilate 来扩大图像时,我得到 TypeError: Expected Ptr<cv::UMat> for argument 'src' 错误,我作为输入提供的图像。
frameDelta = cv2.absdiff(firstFrame, gray)
cv2.imshow("frameDelta",frameDelta)
thresh = cv2.threshold(frameDelta, 25,255,cv2.THRESH_BINARY)
thresh = cv2.dilate(thresh, None, iterations = 2)
我已经尝试过 cv2.UMat(thresh),当我使用它时,我得到 TypeError: Required argument 'ranges' (pos 2) not found
解决方案
cv2.threshold 确实产生两个返回值。你分配它的方式,“thresh”将是一个元组,第一个条目是整数类型,第二个条目是阈值图像。采用
frameDelta = cv2.absdiff(firstFrame, gray)
cv2.imshow("frameDelta",frameDelta)
thresh = cv2.threshold(frameDelta, 25,255,cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations = 2)
反而。
推荐阅读
- android - 为什么 Kotlin 在从资源中设置 Glide 错误可绘制时提示创建扩展函数?
- oracle - Oracle SQL - 无法看到创建的表
- c# - 我在使用 Office365 的 oauth2 身份验证对用户进行身份验证时遇到问题
- html - 使用 XSLT 将带有名称和内容的元标记添加到我的 html 页面
- computer-vision - 图像转换:将直线转换为圆弧
- java - 读取spss文件java
- r - 使用 ggplot2 创建渐变色条
- reactjs - 从 redux-form 覆盖初始值
- laravel - 将图像存储在本地驱动器中并在数据库中保存路径
- pyqt5 - PyQt5 pyqtgraph(添加/删除)曲线在单个图中