What are you trying to do?  Typical approach would be to use Javascript to pull 
the images.  Take a look at dajaxice.  


—
Sent from Mailbox for iPhone

On Mon, Nov 18, 2013 at 1:57 PM, Alex Karargyris <akarargy...@gmail.com>
wrote:

> So thanks to Simon I was able to make this work. Here is the code for those 
> who might be interested:
>     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?
> Thanks a lot!
> -Alex
> 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 webcam
>>         gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)         //Make 
>> frame grayscale
>>         pil_img = Image.fromarray(gray)  
>>         
>>         response = HttpResponse(mimetype="image/png")
>>         pil_img.save(response, "PNG")
>>         
>>         return response
>>
>> Although 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+unsubscr...@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/60f5ed0b-2179-4c63-9d9b-159ff8381049%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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/1384825037826.412bfaaf%40Nodemailer.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to