Dear all,
On Friday, November 15, 2013 11:15:21 AM UTC-5, Alex Karargyris wrote:
-- Thank you for the help. I managed to setup StreamingHttpResponse to read the images from the media folder. However I believe that there is a syntax error with html code <img>. It doesn't display the image. Any help? I am attaching the code below.Thanks in advance!
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
On Friday, November 15, 2013 11:15:21 AM UTC-5, Alex Karargyris wrote:
I have this simple app that I opens webcam and processes the frames using OpenCV. In my views.py I have the following code:def processImage():while True:rval, frame = settings.CAP.read() //Read frames from webcamgray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) //Make frame grayscalepil_img = Image.fromarray(gray)response = HttpResponse(mimetype="image/png") pil_img.save(response, "PNG")return responseAlthough there is a while loop the function runs only once because it is broken by "return response". How could I change the code to make it run constantly?
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/d00a35a6-6dd8-4fd3-bc13-dc9e54883feb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment