Changeset 488
- Timestamp:
- 05/13/09 23:47:45 (3 years ago)
- Location:
- trunk/software/rb
- Files:
-
- 6 modified
-
auto.py (modified) (2 diffs)
-
controller.py (modified) (1 diff)
-
vision/_vision.c (modified) (5 diffs)
-
vision/makefile (modified) (1 diff)
-
vision/vision.c (modified) (1 diff)
-
vision/vision.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/software/rb/auto.py
r482 r488 44 44 def __init__(self, controller): 45 45 self.controller = controller 46 47 # self.nav_func = navigate_points 48 self.nav_func = navigate_course 46 49 47 50 def _main(self): 51 if self.controller.navigator == 'auto': 52 self.nav_func() 53 # update motors 54 55 def process(self, type, data): 56 if type == 'vision_points': 57 self.points = data[0] 58 59 def navigate_course(self): 60 for point in self.points(): 61 # count points `in front' of us 62 # If it's `mostly' clear 63 # go forward 64 # else 65 # count points on left/right 66 # turn in most clear direction 67 68 def navigate_points(self): 48 69 ''' 49 70 Update the output based on `current_data`. … … 91 112 time.sleep(1) 92 113 self.wiimote.rumble = False 93 94 class ForwardNavigator(object):95 '''96 Class to go forward, staying between lines and avoiding obsticles97 '''98 pass -
trunk/software/rb/controller.py
r487 r488 43 43 self.data_queue = Queue() 44 44 self.init_drive() 45 #self.init_camera()45 self.init_camera() 46 46 #self.init_gps() 47 47 #self.init_microstrain() -
trunk/software/rb/vision/_vision.c
r486 r488 32 32 classifier_t *classifier = NULL; 33 33 34 void free_pixbuf_data(guchar *pixels, gpointer _ipl_image) 35 { 36 printf("freeing ipl image data\n"); 37 IplImage *ipl_image = _ipl_image; 38 cvReleaseImage(&ipl_image); 39 } 40 41 /** 42 * Convert a IplImage to a GdkPixbuf 43 * The input image is left untouched 44 * The returned image should be freeded/g_object_unrefd by the caller 45 */ 34 46 GdkPixbuf *ipl_image_to_gtk_pixbuf(IplImage *image) { 35 47 /* OpenCV uses BRG */ … … 45 57 rgb->height, 46 58 rgb->widthStep, 47 NULL,48 NULL59 free_pixbuf_data, 60 rgb 49 61 ); 50 cvReleaseImageHeader(&rgb);51 62 return pixbuf; 52 63 } … … 73 84 return NULL; 74 85 } 86 75 87 // TODO: start with a larger list 88 printf("generating new pixbuf\n"); 76 89 PyObject *points = PyList_New(0); 77 90 … … 93 106 94 107 GdkPixbuf *pixbuf = ipl_image_to_gtk_pixbuf(input); 95 PyObject *py_pixbuf = pygobject_new((GObject*)pixbuf); 108 PyObject *py_pixbuf = pygobject_new((GObject*)pixbuf); 109 g_object_unref(pixbuf); 96 110 97 111 cvReleaseMemStorage(&seq->storage); … … 100 114 cvReleaseMat(&classes); 101 115 102 return Py_BuildValue("(OO)", points, py_pixbuf); 116 PyObject *rval = Py_BuildValue("(OO)", points, py_pixbuf); 117 Py_DecRef(points); 118 Py_DecRef(py_pixbuf); 119 return rval; 103 120 } 104 121 -
trunk/software/rb/vision/makefile
r484 r488 1 CFLAGS = -p -pg -g -Wall -Werror - pedantic -fPIC --std=gnu99 -fgnu89-inline -O3 $(shell pkg-config --cflags opencv gsl)1 CFLAGS = -p -pg -g -Wall -Werror -Wno-unused -pedantic -fPIC --std=gnu99 -fgnu89-inline -O3 $(shell pkg-config --cflags opencv gsl) 2 2 #CFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 3 CPPFLAGS = -p -pg -g -Wall -Werror - pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl)3 CPPFLAGS = -p -pg -g -Wall -Werror --Wno-unused pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 4 4 LDFLAGS = $(shell pkg-config --libs opencv gsl) 5 5 DLFLAGS = -shared -nostartfiles -
trunk/software/rb/vision/vision.c
r485 r488 68 68 return transformed; 69 69 } 70 71 int [3]point_to_ 70 72 71 73 CvSeq *get_points(CvMat *classes) -
trunk/software/rb/vision/vision.h
r479 r488 27 27 CvPoint end; 28 28 } CvLine; 29 30 /** 31 * Structure representing points in the field, contains x/y coord centered at 32 * the robot and the value at the location. 33 */ 34 typedef struct { 35 int x; // Distance in front/behind the robot in meters 36 int y; // Distance left/right the robot in meters 37 int value; // Value of the point. See classify.h for values (e.g. RB_GRASS) 38 } point_t; 39 29 40 30 41 /**

