Python 和 IP 摄像头的问题

发布于 2024-11-06 08:29:44 字数 716 浏览 0 评论 0原文

我在从我拥有的 IP 摄像机获取视频流时遇到问题。我正在使用 opencv 从中获取图像。这是我的代码:

import sys
import cv

video="http://prot-on.dyndns.org:8080/video2.mjpeg"
capture =cv.CaptureFromFile(video)
cv.NamedWindow('Video Stream', 1 )
while True:
  # capture the current frame
  frame = cv.QueryFrame(capture)
  if frame is None:
    break
  else:
    #detect(frame)
    cv.ShowImage('Video Stream', frame)
  if k == 0x1b: # ESC
    print 'ESC pressed. Exiting ...'
    break

实际上,这个东西可以工作,但是显示图像需要太多时间。我猜这是因为 ffmpeg 的错误。

    [mjpeg @ 0x8cd0940]max_analyze_duration reached
    [mjpeg @ 0x8cd0940]Estimating duration from bitrate, this may be inaccurate

我不是 python 专家,所以任何帮助将不胜感激!

I'm having problems to get a video stream from a IP camera I have. I'm using opencv to get the images from it. Here's the code i have:

import sys
import cv

video="http://prot-on.dyndns.org:8080/video2.mjpeg"
capture =cv.CaptureFromFile(video)
cv.NamedWindow('Video Stream', 1 )
while True:
  # capture the current frame
  frame = cv.QueryFrame(capture)
  if frame is None:
    break
  else:
    #detect(frame)
    cv.ShowImage('Video Stream', frame)
  if k == 0x1b: # ESC
    print 'ESC pressed. Exiting ...'
    break

Actually, this thing works, but it takes too much time to display the images. I'm guessing it's because of this error from ffmpeg.

    [mjpeg @ 0x8cd0940]max_analyze_duration reached
    [mjpeg @ 0x8cd0940]Estimating duration from bitrate, this may be inaccurate

I'm not a python expert so any help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦晓ヶ微光ヅ倾城 2024-11-13 08:29:44

首先,mjpeg是一种相对简单的视频格式。如果您阅读网络摄像机的手册,您就可以找到如何使用一些 JavaScript 代码在浏览器中显示视频。事实上,如果您打开 http://prot-on.dyndns.org:8080 的链接/video2.mjpeg 在 Google Chrome 中,您可以毫无问题地观看视频。 (也许你不应该留下相机的真实URL)

其次,据我所知,你的相机的帧速率相当慢。这可能是由于互联网延迟或相机设置造成的。将您在 Chrome 中看到的内容与您的代码显示的视频进行比较,如果它们具有相同的质量,那么这不是您的代码的问题。

First, mjpeg is a relatively simple video format. If you read your IP camera's manual, it's very like that you can find how to display the video in browser with a bit JavaScript code. In fact, if you open link of http://prot-on.dyndns.org:8080/video2.mjpeg in Google Chrome, you would see the video without any problem. (Maybe you shouldn't leave the real URL of your camera)

Second, as far as I can see, the frame rate of your camera is pretty slow. That might due to Internet latency or your camera's setting. Compare what you see in Chrome with the video displayed by your code, if they are of same quality, then it's not your code's problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文