It is currently Mon May 21, 2012 6:22 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: image from URL in form
PostPosted: Tue Apr 19, 2011 2:32 pm 
Offline

Joined: Tue Mar 15, 2011 1:59 pm
Posts: 5
Hello,

I need to have camera view in one of my custom module form. I can get image from camera via URL.
Is there such possibility to show image from URL on the form?
What is the best solution to archieve this?

Thanks for help in advance.
Robert.


Top
 Profile  
 
 Post subject: Re: image from URL in form
PostPosted: Tue Apr 19, 2011 9:52 pm 
Offline

Joined: Thu Sep 23, 2010 9:29 pm
Posts: 251
Location: Leeseringen, Germany
You could use a model on memory, and either use a fields.binary for the image and overwrite read() to fetch the current image, or you could use fields.function of type binary and have a function return the image.

There can be more ways to do this.

You can display fields.binary with "widget='image'".

_________________
Light travels faster than sound.
That is why some people appear bright until you hear them speak.


Top
 Profile  
 
 Post subject: Re: image from URL in form
PostPosted: Tue Apr 19, 2011 11:32 pm 
Offline

Joined: Tue Mar 15, 2011 1:59 pm
Posts: 5
Thank you for your response.

I thought and I have tried with fields.binary but this stores picture in the database. And I need to get it from URL not database. My url looks like this: http://10.255.253.149/cgi-bin/nph-zms?m ... 0&maxfps=5. If I put this address in
Code:
<img src="http://10.255.253.149/cgi-bin/nph-zms?mode=jpeg&monitor=7&scale=100&maxfps=5" />
I can get live picture from the camera.

I'm new in OpenERP developing so maybe there is some way, and I don't know how to do this.
If there is such possibility I kindly ask for help :).


Top
 Profile  
 
 Post subject: Re: image from URL in form
PostPosted: Wed Apr 20, 2011 1:45 pm 
Offline

Joined: Thu Sep 23, 2010 9:29 pm
Posts: 251
Location: Leeseringen, Germany
Yes, my approach gets the image and stores it in a binary field in the "database".
By using osv_memory it is a temporary "table" not saved to the underlaying postgres, but held in memory.

This temporary table is then read by a normal view <field> to view the image.

Something alone these (untested) lines:
Code:
class my_image(osv.osv_memory):
    _name = "my.image"
    _rec_name = "image"

    def _get_image(self, cr, uid, ids, field_name, arg, context):
      ret = {}
      picture_res = urllib2.urlopen('http://www.google.com/images/logos/ps_logo2.png')
      picture = picture_res.read()
      for id in ids:
        ret [id] = picture
      return ret

    _columns = {
        "image": fields.function(_get_image, string="Image", type="binary", method=True),
    }

_________________
Light travels faster than sound.
That is why some people appear bright until you hear them speak.


Top
 Profile  
 
 Post subject: Re: image from URL in form
PostPosted: Thu Apr 28, 2011 1:17 pm 
Offline

Joined: Tue Mar 15, 2011 1:59 pm
Posts: 5
Thank you for your response and help.

Unfortunatelly this solution is not working for me.
Even if it works, it will not provide me real time view from the camera, but only one frame. Is it correct?

Robert.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP