【问题标题】:show ip camera live feed in django webpage在 django 网页中显示 ip camera live feed
【发布时间】:2019-06-12 06:34:18
【问题描述】:

在url部分定义cameafeedview的代码请帮助我错了。这个代码也累了但没有帮助 Opencv Live Stream from camera in Django Webpage

    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 页面,但没有实时摄像头提要..请帮助我在这里错了

【问题讨论】:

  • 有什么解决办法吗?

标签: python django camera


【解决方案1】:

问题可能与您使用 RTSP 流有关。根据我的研究,RTSP 流不能直接在浏览器中播放,您必须先将其转换为以浏览器支持的格式播放。有关更多信息,您可以查看以下link。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-10
    • 2018-09-15
    相关资源
    最近更新 更多