Rose-Hulman Robotics Team

Changeset 485

Show
Ignore:
Timestamp:
05/06/09 22:30:47 (3 years ago)
Author:
mosttw
Message:

Scaling of the camera image

Location:
trunk/software
Files:
1 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/Makefile

    r479 r485  
    11default: all 
    22 
    3 all: $(SUBDIRS) rb/gui/gui.xml 
     3all: $(SUBDIRS) rb/gui/gui.xml rb/vision/classify_dtree.o 
    44        python setup.py build_ext --inplace 
    55 
     
    3030        # python -m rb.auto 
    3131 
     32CPPFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 
     33 
     34rb/vision/classify_dtree.o: rb/vision/classify_dtree.cpp 
     35        g++ $(CPPFLAGS) -c -o $@ $+ 
  • trunk/software/rb/controller.py

    r482 r485  
    1 # Copyright (C) 2009 Thomas W. Most 
    2 # Copyright (C) 2008 Andy Spencer 
     1# Copyright (C) 2008-2009 Thomas W. Most 
     2# Copyright (C) 2008-2009 Andy Spencer 
    33# 
    44# This program is free software: you can redistribute it and/or modify 
     
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    1616 
    17 import thread 
    18 from Queue import Queue 
     17from Queue import Queue, Empty 
     18from thread import start_new_thread 
    1919 
    2020import gobject 
    2121 
    22 from thread import start_new_thread 
    2322import rbconfig 
    2423import rb.drive 
    25 import rb.gps 
    26 import rb.microstrain 
    2724import rb.kalman 
    28 import rb.vision 
    29  
    30 from rb.transcript     import TranscriptLogger 
     25from rb.transcript import TranscriptLogger 
    3126 
    3227 
     
    110105                elif nav == 'laptop': 
    111106                        pass 
    112                 elif nav == 'wiimote': 
    113                         pass 
    114107                 
    115108                self.navigator = nav 
    116  
    117109                return True 
    118110         
     
    128120 
    129121        def init_camera(self): 
    130                 self.camera = rb.vision.Camera(self) 
     122                from rb.vision import Camera 
     123                self.camera = Camera(self) 
    131124         
    132125        def init_gps(self): 
    133                 self.gps = rb.gps.GPS(rbconfig.gps_port) 
     126                from rb.gps import GPS 
     127                self.gps = GPS(rbconfig.gps_port) 
    134128         
    135129        def init_microstrain(self): 
    136                 self.microstrain = rb.microstrain.MicroStrain(rbconfig.microstrain_port) 
     130                from rb.microstrain import MicroStrain 
     131                self.microstrain = MicroStrain(rbconfig.microstrain_port) 
    137132         
    138133         
     
    147142                        try: 
    148143                                type, data = self.data_queue.get(timeout=.1) 
    149                         except: 
     144                        except Empty: 
    150145                                pass 
    151146                        else: 
     
    166161                with GTK+ will need to move things to GTK's main loop. 
    167162                ''' 
    168                 #print "process(%r, ...) in thread %s" % (type, thread.get_ident()) 
    169  
    170                 for interface in [self.auto, self.wiimote, self.shell, self.gui]: 
    171                         if interface != False and hasattr(interface, "process"): 
    172                                 interface.process(type, data) 
    173                  
    174163                if type == 'gps_fix': 
    175164                        self.kalman.update_gps(data) 
     
    180169                elif type == 'drive_speeds': 
    181170                        self.kalman.update_drive_speed(data) 
     171                 
     172                for interface in (self.auto, self.wiimote, self.shell, self.gui): 
     173                        if interface and hasattr(interface, "process"): 
     174                                interface.process(type, data) 
     175                 
  • trunk/software/rb/gui/camera.py

    r484 r485  
    2525 
    2626        def expose_cb(self, da, event): 
    27                 print "expose" 
     27                # This rescales and redraws the image at every expose event, which 
     28                # is pretty awful.  This could pretty easily be changed to at least 
     29                # keep the scaled image around between exposes. 
    2830                if not self.pixbuf: 
    2931                        return 
    3032                # TODO: Scale 
    3133                drawable = da.window 
    32                 gc = gtk.gdk.GC(drawable) 
    3334                alloc = self.get_allocation() 
     35                new_w = alloc.width 
     36                new_h = alloc.height 
     37                scaled_pixbuf = self.pixbuf.scale_simple(new_w, new_h, gtk.gdk.INTERP_NEAREST) 
    3438                drawable.draw_pixbuf( 
    35                                 gc, self.pixbuf, 
     39                    drawable.new_gc(), 
     40                    scaled_pixbuf, 
    3641                                0, 0, # src_x, src_y, 
    37                                 alloc.x, alloc.x, 
    38                                 alloc.width, alloc.height, 
    39                                 gtk.gdk.RGB_DITHER_NONE, 
    40                                 1, 1, # x_dither, y_dither 
     42                                0, 0, # dest_x, dest_y, 
     43                                alloc.width, alloc.height 
    4144                ) 
  • trunk/software/rb/gui/gui.glade

    r482 r485  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    22<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> 
    3 <!--Generated with glade3 3.4.5 on Thu Apr 30 07:14:52 2009 --> 
     3<!--Generated with glade3 3.4.5 on Wed May  6 22:08:34 2009 --> 
    44<glade-interface> 
    55  <widget class="GtkWindow" id="window"> 
     
    359359          </widget> 
    360360          <packing> 
     361            <property name="expand">False</property> 
    361362            <property name="position">1</property> 
    362363          </packing> 
  • trunk/software/rb/gui/gui.xml

    r482 r485  
    11<?xml version="1.0"?> 
    2 <!--Generated with glade3 3.4.5 on Thu Apr 30 07:14:52 2009 --> 
     2<!--Generated with glade3 3.4.5 on Wed May  6 22:08:34 2009 --> 
    33<interface> 
    44  <object class="GtkAdjustment" id="adjustment1"> 
     
    365365          </object> 
    366366          <packing> 
     367            <property name="expand">False</property> 
    367368            <property name="position">1</property> 
    368369          </packing> 
  • trunk/software/rb/vision/__init__.py

    r484 r485  
    4040if __name__ == "__main__": 
    4141        test() 
     42 
  • trunk/software/rb/vision/_vision.c

    r484 r485  
    8383        CvSeqReader reader; 
    8484        cvStartReadSeq(seq, &reader, 0); 
    85         for(int i = 0; i < seq->total; i++) { 
     85        int i; 
     86        for(i = 0; i < seq->total; i++) { 
    8687                int data[3]; 
    8788                CV_READ_SEQ_ELEM(data, reader); 
  • trunk/software/rb/vision/vision.c

    r484 r485  
    5252        CvMat* mat= cvCreateMat( 3, 3, CV_32F ); 
    5353        CvPoint2D32f from[] = { 
    54                 cvPoint2D32f(0           , size.height*0.12), 
    55                 cvPoint2D32f(0           , size.height-1), 
    56                 cvPoint2D32f(size.width-1, size.height-1), 
    57                 cvPoint2D32f(size.width-1, size.height*0.12) 
     54                cvPoint2D32f(1208, 1172), 
     55                cvPoint2D32f(1196, 1224), 
     56                cvPoint2D32f(1295, 1178), 
     57                cvPoint2D32f(1294, 1231) 
    5858        }; 
    5959        CvPoint2D32f to[] = { 
    60                 cvPoint2D32f(0              , -62          ), 
    61                 cvPoint2D32f(size.width*0.33, size.height-1), 
    62                 cvPoint2D32f(size.width*0.67, size.height-1), 
    63                 cvPoint2D32f(size.width-1   , -62          ) 
     60                cvPoint2D32f(1210, 1170), 
     61                cvPoint2D32f(1210, 1250), 
     62                cvPoint2D32f(1290, 1170), 
     63                cvPoint2D32f(1290, 1250) 
    6464        }; 
    6565        cvGetPerspectiveTransform(from, to, mat);