code in which cameafeedview is defined in the url section please help where i am wrong .Tired this code also but no help 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")
Template code:
<html>
<head>
<title>Video Streaming Demonstration</title>
<h1>test</h1>
</head>
<body>
<h1>Video Streaming Demonstration</h1>
<img src="{% url 'camerafeed' % }}">
</body>
</html>
it show only html page but no live camaera feed ..please help where i am wrong here