--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a13fe785-83ec-4a18-8377-090bdeda279d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
def stream_response_generator():
yield "<html><body>\n"
for x in range(1, 10):
rval, frame = settings.CAP.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imwrite('media/image.jpeg', gray, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
time.sleep(.1)
x={"src": "%s/image.jpeg" % (settings.MEDIA_URL), "alt": "Video Frame"}
yield "<img %s/>" % x
yield "</body></html>\n"
def camera(request):
resp = StreamingHttpResponse(stream_response_generator())
return resp
yield "<html>"
yield '<meta http-equiv="refresh" content="0.01" />'
yield "<body>\n"
rval, frame = settings.CAP.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imwrite('media/image.jpeg', gray, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
x={"src": "..%s/image.jpeg" % (settings.MEDIA_URL), "alt": "Video Frame"}
yield '<img src="%(src)s" alt="%(alt)s"/>' % x
yield "</body></html>\n"
However as it doesn't stream the images but instead it saves and the html is refreshed every 0.01 secs. This does not seem to be an elegant solution because a) there is latency and b) the browser keeps reloading constantly. Some of you suggested websockets. Is there some good example for Django + Websockets for streaming images to the browser?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/60f5ed0b-2179-4c63-9d9b-159ff8381049%40googlegroups.com.