简体   繁体   English

cv2.VideoCapture('html 直播'?)

[英]cv2.VideoCapture( ' html live stream'? )

Gets error when trying to open livestream.尝试打开直播时出错。 I'm streaming this from my raspberry pi to my view it on windows so I can run opencv and yolo.我正在将它从我的树莓派流式传输到我在 windows 上的视图中,这样我就可以运行 opencv 和 yolo。 Is there a way to do this with opencv?有没有办法用 opencv 做到这一点?

import cv2

cap = cv2.VideoCapture('http://______/html/#')

while True:
    ret, frame = cap.read()

    cv2.imshow("frame", frame)
    key = cv2.waitKey(50)
    if key == 27:
        break
cv2.destroyAllWindows()

So the URL I was trying to connect to had a little display of the livestream from the raspberry pi and the settings under it.因此,我尝试连接的 URL 显示了来自树莓派的直播及其下的设置。 What I had to do along with the code from this answer was right click on the live stream display, open it up in another tab and use the URL from that tab.我必须与此答案中的代码一起做的是右键单击实时 stream 显示,在另一个选项卡中打开它并使用该选项卡中的 URL 。 It's about 2-3 seconds off though.不过,它大约需要 2-3 秒。

https://stackoverflow.com/a/57539561/17280268 https://stackoverflow.com/a/57539561/17280268

import cv2

cap = cv2.VideoCapture('http://345.63.46.1256/html/cam_pic_new.php?time=1642941457007&p')

#^^ Opened in new tab URL ^^
#cap = cv2.VideoCapture('http://345.63.46.1256/html/')

cv2.namedWindow('live cam', cv2.WINDOW_NORMAL)

while(True):
    ret, frame = cap.read()
    #img_resize = cv2.resize(frame, (960, 540))
    cv2.imshow('live cam', frame)
    if cv2.waitKey(50) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

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

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