gpt4 book ai didi

python - mat 不是数值元组 : openCV error

转载 作者:太空狗 更新时间:2023-10-29 18:17:51 25 4
gpt4 key购买 nike

我已经写下了显示错误的代码,但我没有得到它:请帮助: 它的显示垫不是数字元组:

import cv
import cv2
capture = cv2.VideoCapture("j.3gp")

while(1):

_, frame1 = capture.read()

grayImage1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
_, frame2 = capture.read()
grayImage2 = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
differenceImage = cv2.absdiff(grayImage1,grayImage2)
thresholdImage = cv2.threshold(differenceImage,25,255,cv2.THRESH_BINARY)
cv2.imshow("Difference Image", differenceImage)
cv2.imshow("threshold Image", thresholdImage)
cv2.imshow("Image", frame1)
k = cv2.waitKey(30) & 0xff


Error arising :
-----------------------------------------------------------------------------------------

Traceback (most recent call last):
File "Desk.py", line 15, in <module>
cv2.imshow("threshold Image", thresholdImage)
TypeError: mat is not a numerical tuple

最佳答案

我自己得到了答案:cv2.threshold 返回两个值并在开头添加一个额外的变量来纠正错误,就像我在 capture.read()

thresholdImage = cv2.threshold(differenceImage,25,255,cv2.THRESH_BINARY)

应该是:

_ ,thresholdImage = cv2.threshold(differenceImage,25,255,cv2.THRESH_BINARY)

关于python - mat 不是数值元组 : openCV error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27365634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com