簡體   English   中英

在 django 網頁中顯示 ip 攝像頭實時饋送

[英]show ip camera live feed in django webpage

在 url 部分中定義了cameafeedview 的代碼請幫助我出錯的地方。累了這個代碼,但沒有幫助Django 網頁中來自相機的Opencv Live Stream

    def camerafeedView(request):
        return render(request,'camerafeed.html')

    def gen(camera):
        video = cv2.VideoCapture()
        video.open("rtsp://user:pass@IP")
        video.release()
        ret,image =  self.video.read()
        ret,jpeg = cv2.imencode('.jpg',image)
        while True:
            frame = jpeg.tobytes()
            yield(b'--frame\r\n'
            b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')

        def camerafeed(request): 
            return StreamingHttpResponse(gen(),content_type="multipart/x-mixed-replace;boundary=frame")

模板代碼:

   <html>
       <head>
           <title>Video Streaming Demonstration</title>
           <h1>test</h1>
       </head>
       <body>
           <h1>Video Streaming Demonstration</h1>
           <img src="{% url 'camerafeed' % }}">
       </body>
   </html>

它只顯示 html 頁面,但沒有實時攝像頭提要..請幫助我在這里出錯的地方

還是沒有解決辦法? 我在這里有同樣的問題

問題可能與您使用 RTSP 流有關。 根據我的研究,RTSP 流不能直接在瀏覽器中播放,您必須先將其轉換為以瀏覽器支持的格式播放。 有關更多信息,您可以查看以下鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM