mat不是数字元组:openCV错误 [英] mat is not a numerical tuple : openCV error

查看:229
本文介绍了mat不是数字元组:openCV错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have write down a code showing error i ma not getting it: Please help: Its showing mat is not a numerical tuple:

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()中所做的一样

I got the answer myself: cv2.threshold returns two values and adding an extra variable at the start rectifies the error like given below as I did in capture.read()

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

应为:

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

这篇关于mat不是数字元组:openCV错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆