Rose-Hulman Robotics Team

Changeset 666 for trunk/software

Show
Ignore:
Timestamp:
02/11/10 01:45:40 (2 years ago)
Author:
mosttw
Message:

Unbroke camera display, added caching

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/rb/gui/camera.py

    r626 r666  
    2222        def __init__(self): 
    2323                gtk.DrawingArea.__init__(self) 
    24                 self.pipeline = gst.parse_launch('appsrc ! autovideosink') 
     24                self.pixbuf = None 
     25                #self.pipeline = gst.parse_launch('appsrc ! autovideosink') 
    2526 
    2627                self.connect("expose-event", self.expose_cb) 
    2728         
    2829        def push_frame(self, (source, ipl_image)): 
    29                 self.pixbuf = ipl_image.to_gdk_pixbuf() 
    30  
    3130                @gobject.idle_add 
    3231                def update_gui(): 
     32                        self.pixbuf = ipl_image.to_gdk_pixbuf() 
     33                        self.scaled_pixbuf = None 
    3334                        self.queue_draw() 
    3435                        return False 
     
    4041                if not self.pixbuf: 
    4142                        return 
    42                 drawable = da.window 
    4343                alloc = self.get_allocation() 
    44                 new_w = alloc.width 
    45                 new_h = alloc.height 
    46                 scaled_pixbuf = self.pixbuf.scale_simple(new_w, new_h, gtk.gdk.INTERP_NEAREST) 
     44                if self.scaled_pixbuf is None or self.scale != (alloc.width, alloc.height): 
     45                        drawable = da.window 
     46                        self.scaled_pixbuf = self.pixbuf.scale_simple( 
     47                                                                                                alloc.width, alloc.height, 
     48                                                                                                gtk.gdk.INTERP_NEAREST) 
     49                        self.scale = (alloc.width, alloc.height) 
    4750                drawable.draw_pixbuf( 
    4851                    drawable.new_gc(), 
    49                     scaled_pixbuf, 
    50                                 0, 0, # src_x, src_y, 
    51                                 0, 0, # dest_x, dest_y, 
    52                                 alloc.width, alloc.height 
     52                    self.scaled_pixbuf, 
     53                        0, 0, # src_x, src_y, 
     54                        0, 0, # dest_x, dest_y, 
     55                        alloc.width, alloc.height  
    5356                ) 
    5457