Changeset 484
- Timestamp:
- 05/06/09 22:27:01 (3 years ago)
- Location:
- trunk/software
- Files:
-
- 11 modified
-
rb/gui/camera.py (modified) (1 diff)
-
rb/vision/__init__.py (modified) (2 diffs)
-
rb/vision/_vision.c (modified) (4 diffs)
-
rb/vision/classify.c (modified) (1 diff)
-
rb/vision/classify.h (modified) (1 diff)
-
rb/vision/classify_dtree.cpp (modified) (2 diffs)
-
rb/vision/classify_dtree.h (modified) (1 diff)
-
rb/vision/main.c (modified) (2 diffs)
-
rb/vision/makefile (modified) (1 diff)
-
rb/vision/vision.c (modified) (1 diff)
-
setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/software/rb/gui/camera.py
r482 r484 32 32 gc = gtk.gdk.GC(drawable) 33 33 alloc = self.get_allocation() 34 self.pixbuf.render_to_drawable(35 drawable, gc,34 drawable.draw_pixbuf( 35 gc, self.pixbuf, 36 36 0, 0, # src_x, src_y, 37 37 alloc.x, alloc.x, -
trunk/software/rb/vision/__init__.py
r482 r484 18 18 print "done getting points" 19 19 self.controller.send("vision_points", data) 20 sleep(10) 20 sleep(1) 21 22 def key_press_cb(widget, event): 23 import gtk 24 if event.keyval in (gtk.keysyms.Escape, gtk.keysyms.q): 25 gtk.main_quit() 21 26 22 27 def test(): … … 28 33 image.set_from_pixbuf(pixbuf) 29 34 win.add(image) 35 win.connect("key-press-event", key_press_cb) 36 win.connect("destroy", gtk.main_quit) 30 37 win.show_all() 31 38 gtk.main() -
trunk/software/rb/vision/_vision.c
r482 r484 37 37 IplImage *rgb = cvCreateImage(size, image->depth, image->nChannels); 38 38 cvCvtColor(image, rgb, CV_BGR2RGB); 39 returngdk_pixbuf_new_from_data(39 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data( 40 40 (guchar*)rgb->imageData, 41 41 GDK_COLORSPACE_RGB, … … 48 48 NULL 49 49 ); 50 cvReleaseImageHeader(&rgb); 51 return pixbuf; 50 52 } 51 53 … … 75 77 76 78 IplImage *input = get_image(); 77 IplImage *transformed = transform_image(input, 0. 50);79 IplImage *transformed = transform_image(input, 0.25); 78 80 CvMat *classes = classifier_predict(classifier, transformed); 79 81 CvSeq *seq = get_points(classes); … … 88 90 PyList_Append(points, point); 89 91 } 92 93 GdkPixbuf *pixbuf = ipl_image_to_gtk_pixbuf(transformed); 94 PyObject *py_pixbuf = pygobject_new((GObject*)pixbuf); 95 90 96 cvReleaseMemStorage(&seq->storage); 91 92 GdkPixbuf *pixbuf = ipl_image_to_gtk_pixbuf(input);93 PyObject *py_pixbuf = pygobject_new((GObject*)pixbuf);97 cvReleaseImage(&input); 98 cvReleaseImage(&transformed); 99 cvReleaseMat(&classes); 94 100 95 101 return Py_BuildValue("(OO)", points, py_pixbuf); -
trunk/software/rb/vision/classify.c
r479 r484 90 90 } 91 91 92 void classifier_free(classifier_t *classifier) 93 { 94 cvReleaseMat(&classifier->train_input); 95 cvReleaseMat(&classifier->train_desired); 96 switch (classifier->type) { 97 case RB_DTREE: dtree_free(classifier->classifier); break; 98 case RB_HARD: break; 99 } 100 free(classifier); 101 } 102 92 103 void classifier_add_data(classifier_t *classifier, CvMat *input, CvMat *desired) 93 104 { -
trunk/software/rb/vision/classify.h
r479 r484 45 45 */ 46 46 classifier_t *classifier_new(int type); 47 void classifier_free(classifier_t *classifier); 47 48 48 49 -
trunk/software/rb/vision/classify_dtree.cpp
r479 r484 10 10 CvDTree *dtree = new CvDTree; 11 11 return dtree; 12 } 13 14 void dtree_free(CvCDTree *_dtree) 15 { 16 CvDTree *dtree = (CvDTree *)_dtree; 17 delete dtree; 12 18 } 13 19 … … 26 32 dtree->train(input, CV_ROW_SAMPLE, desired, 0, 0, var_type, NULL, 27 33 CvDTreeParams( 28 15, // Max depth29 50, // min sample count34 5, // 15, // Max depth 35 10, // 50, // min sample count 30 36 0, // regression accuracy: N/A here 31 37 false, // no not compute surrogate split 32 38 RB_NUM_CLASSES, // max number of categories (use sub-optimal algorithm for larger numbers) 33 20, // the number of cross-validation folds39 4, // 20, // the number of cross-validation folds 34 40 false, // use 1SE rule => smaller tree 35 41 true, // throw away the pruned tree branches -
trunk/software/rb/vision/classify_dtree.h
r479 r484 8 8 /* Decision tree classifier */ 9 9 CvCDTree *dtree_create(); 10 void dtree_free(CvCDTree *); 10 11 void dtree_train(CvCDTree *dtree, CvMat *input, CvMat *desired); 11 12 CvMat *dtree_predict(CvCDTree *dtree, CvMat *input); -
trunk/software/rb/vision/main.c
r482 r484 69 69 /* Display images */ 70 70 print_time("Displaying images"); 71 cvNamedWindow("input", 0);72 cvMoveWindow ("input", 100, 100);73 cvShowImage ("input", input);74 cvNamedWindow("transformed", 0);75 cvMoveWindow ("transformed", 100, 100);76 cvShowImage ("transformed", transformed);77 cvNamedWindow("colors", 0);78 cvMoveWindow ("colors", 100, 100);79 cvShowImage ("colors", colors);71 //cvNamedWindow("input", 0); 72 //cvMoveWindow ("input", 100, 100); 73 //cvShowImage ("input", input); 74 //cvNamedWindow("transformed", 0); 75 //cvMoveWindow ("transformed", 100, 100); 76 //cvShowImage ("transformed", transformed); 77 //cvNamedWindow("colors", 0); 78 //cvMoveWindow ("colors", 100, 100); 79 //cvShowImage ("colors", colors); 80 80 81 while (cvWaitKey(0) != XK_q);81 //while (cvWaitKey(0) != XK_q); 82 82 83 83 /* Release temp data */ … … 86 86 cvReleaseMat(&classes); 87 87 cvReleaseImage(&colors); 88 classifier_free(classifier); 88 89 89 90 return 0; -
trunk/software/rb/vision/makefile
r482 r484 1 1 CFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC --std=gnu99 -fgnu89-inline -O3 $(shell pkg-config --cflags opencv gsl) 2 #CFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 2 3 CPPFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 3 4 LDFLAGS = $(shell pkg-config --libs opencv gsl) -
trunk/software/rb/vision/vision.c
r479 r484 81 81 for(int x = 0; x < classes->cols; x+=10) { 82 82 for(int y = 0; y < classes->rows; y+=10) { 83 CvScalar class = cvGet2D(classes, y, x);84 int data[3] = { class.val[0], x, y};83 CvScalar klass = cvGet2D(classes, y, x); 84 int data[3] = {klass.val[0], x, y}; 85 85 CV_WRITE_SEQ_ELEM(data, writer); 86 86 } -
trunk/software/setup.py
r479 r484 30 30 'rb/vision/vision.c', 31 31 'rb/vision/classify.c', 32 'rb/vision/classify_hard.c' ,33 'rb/vision/classify_dtree.cpp'],32 'rb/vision/classify_hard.c'], 33 #'rb/vision/classify_dtree.cpp'], 34 34 libraries=['cv', 'highgui', 'gsl'], 35 extra_compile_args=['-I/usr/include/opencv -lcv -lhighgui -lgsl'] 35 extra_compile_args=['-I/usr/include/opencv -lcv -lhighgui -lgsl'], 36 language="c++", 36 37 ); 37 38

