简体   繁体   English

没有从 openCV 中的网络摄像头获得连续视频 output

[英]Not getting a continuous video output from webcam in openCV

I am new to OpenCV and I am trying to render video from my webcam but instead of getting a continuous live video, I get a single frame as a picture.我是 OpenCV 的新手,我正在尝试从我的网络摄像头渲染视频,但我没有获得连续的实时视频,而是获得了单帧图片。 When I tap on close button it shows me the next frame as a picture.当我点击关闭按钮时,它会将下一帧显示为图片。

import cv2
vid=cv2.VideoCapture(0)
while(vid.isOpened()):
    ret,frame=vid.read()
    cv2.imshow('Video',frame)
    if cv2.waitKey(0) & 0xFF ==ord('e'):
        break
vid.release()
cv2.destroyAllWindows()

I am using Asus X507uf laptop.我正在使用华硕 X507uf 笔记本电脑。 Maybe it is my webcam's fault.也许这是我的网络摄像头的错。

Try this code -试试这个代码 -

import cv2
vid=cv2.VideoCapture(0)
while(vid.isOpened()):
    ret,frame=vid.read()
    cv2.imshow('Video',frame)
    if cv2.waitKey(1) & 0xFF ==ord('e'):
        break
   
vid.release()
cv2.destroyAllWindows()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM