访问本地 HTTP 主机上的视频流 运行

Accessing a Video Stream running on local HTTP host

外部摄像头正在 http://localhost:3000/index.html 上输出视频流。

我想让这个流可供我用于 opencv 人脸检测和其他算法。

到目前为止我尝试过的:

import cv2
import warnings
warnings.filterwarnings('ignore')    

cap = cv2.VideoCapture("http://localhost:3000/index.html")

while True:

    ret, frame = cap.read()
    cv2.imshow('video', frame)

    k = cv2.waitKey(30) & 0xff
    if k == 27:  # press 'ESC' to quit
        break

此returns以下错误:

[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (116) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): http://localhost:3000/ in function 'cv::icvExtractPattern'


Traceback (most recent call last):
  File "C:/Users/void_/PycharmProjects/AIML/Computer Vision/app3.py", line 18, in <module>
    cv2.imshow('video', frame)
cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

我已经在我的系统上安装了 FFMpeg。我怎样才能继续使用来自本地服务器的视频流 - http://localhost:3000/index.html ? 下图显示了部分实时提要和终端 window,即 运行 流。

这个问题我已经想通了

我试图从 localhost:3000/index.html 上在网络浏览器上放映的输出中提取提要。这是来自源的输出。因此,要获取提要,我需要访问提要的源,而不是 UDP 端口。

import cv2
import warnings
warnings.filterwarnings('ignore')    

cap = cv2.VideoCapture("udp://@0.0.0.0:11111")

while True:

    ret, frame = cap.read()
    cv2.imshow('video', frame)

    k = cv2.waitKey(30) & 0xff
    if k == 27:  # press 'ESC' to quit
        break

直播开始了!