holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.41k stars 484 forks source link

VideoStream from CCTV #6926

Open lankoestee opened 2 weeks ago

lankoestee commented 2 weeks ago

When I use the VideoStream class to get the network camera information, it can only get the video stream information of the local camera. If I want to use a remote network camera, such as a video stream transmitted through the rtmp or rtsp protocol, how should I display it in the panel?

Using opencv can achieve the effect I want:

import cv2
cap = cv2.VideoCapture("rtsp://cctv_url")
ret, frame = cap.read()
while ret:
    ret, frame = cap.read()
    cv2.imshow("frame",frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()
cap.release()

Is it possible to use Panel's VideoStream to achieve the above effect?

MarcSkovMadsen commented 2 weeks ago

Yes. I've tried something like that by streaming the frame as pngs to the PNG pane.

There is an unfinished tutorial here https://github.com/holoviz/panel/pull/6727. Look at the tutorial. It's probably more advanced than you n eed, but I hope you can find inspiration from it.

lankoestee commented 2 weeks ago

@MarcSkovMadsen Thanks! The tutorial you mentioned is very useful! However, the video display fps is very slow. When I use the cv2.imshow method, I can reach a display frame rate of 15fps, but the frame rate is significantly lower when using the tutorial method. Is there any better way to solve this problem?