gpt4 book ai didi

java - 如何在 OpenCV Python 中读取 Minoru 3d 网络摄像头的视频?

转载 作者:行者123 更新时间:2023-11-30 21:08:28 24 4
gpt4 key购买 nike

我正在研究安装在 Windows 10(64 位)上的 opencv python我正在使用 Minoru 3D 网络摄像头。我编写了一个从 2 镜头相机读取视频的代码。我在这里遇到以下错误:

Traceback (most recent call last):
File "C:/Python27/pythoncode/reading a video from two lens", line 6, in <module>
if(cap & cap1):
TypeError: unsupported operand type(s) for &: 'cv2.VideoCapture' and 'cv2.VideoCapture'

代码:

import numpy as np
import cv2
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
cap1 = cv2.VideoCapture(1)
if(cap & cap1):
while(true):
ret, frame=cap.read()
cv2.imshow('bgr image',frame)
print ret
ret1, frame1=cap1.read()
cv2.imshow('image1',frame1)
print ret1
if cv2.waitKey(30)>=0:
break
cap.release()
cap1.release()
cv2.destroyAllWindows()

最佳答案

您的代码和错误消息非常难以阅读;请在每行代码前加四个空格,或者选择所有代码并按Ctrl+K,转动

回溯(最近一次调用最后一次):文件“C:/Python27/pythoncode/从两个镜头读取视频”,第 6 行,if(cap & cap1):类型错误:& 不支持的操作数类型: 'cv2.VideoCapture' 和 'cv2.VideoCapture' import numpy as np import cv2 import matplotlib.pyplot as plt cap = cv2.VideoCapture(0) cap1 = cv2.VideoCapture(1) if(cap & cap1): while(true) : ret,frame=cap.read() cv2.imshow('bgr image',frame) 打印 ret ret1,frame1=cap1.read() cv2.imshow('image1',frame1) 打印 ret1 if cv2.waitKey(30) )>=0: 中断 cap.release() cap1.release() cv2.destroyAllWindows()

进入

Traceback (most recent call last):
File "C:/Python27/pythoncode/reading a video from two lens", line 6, in <module>
if(cap & cap1):
TypeError: unsupported operand type(s) for &: 'cv2.VideoCapture' and 'cv2.VideoCapture'

import numpy as np
import cv2
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
cap1 = cv2.VideoCapture(1)
if(cap & cap1):
while(true):
ret, frame=cap.read()
cv2.imshow('bgr image',frame)
print ret
ret1, frame1=cap1.read()
cv2.imshow('image1',frame1)
print ret1
if cv2.waitKey(30)>=0:
break
cap.release()
cap1.release()
cv2.destroyAllWindows()

根据错误信息,错误出现在 if(cap & cap1): 行,这是因为不能使用运算符 &(按位 AND)在两个 cv2.VideoCapture 对象上。

我假设您试图确保两个变量都不是 None,实现此目的的方法是将行更改为:

if (cap != None) and (cap1 != None):

关于java - 如何在 OpenCV Python 中读取 Minoru 3d 网络摄像头的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38420407/

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