Changeset 19 for liacs/mss/project/colour-tracking.c
- Timestamp:
- Dec 2, 2009, 7:33:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
liacs/mss/project/colour-tracking.c
r17 r19 31 31 } 32 32 33 /* Convert the virtual mapping to screen size */ 34 int ratio (const int size, const int current_size, const int orig_size) { 35 double t = (double)size / current_size; 36 t *= orig_size; 37 // printf("%i/%i -> %i\n", size, current_size, (int)t); 38 return((int)t); 39 } 40 33 41 int InitSystem(int argc, char *argv[]) { 34 42 // Don't care which camera to use. Use specified number elsewise 35 int cam_number = -1; 36 if (argc > 1) 37 cam_number = atoi(argv[1]); 38 printf("Using camera %i\n", cam_number); 43 if (argc < 3) { 44 printf("Usage: %s <cam number> <screen width> <screen height>\n", 45 argv[0]); 46 return(64); 47 } 48 const int cam_number = atoi(argv[1]); 49 const int screen_width = atoi(argv[2]); 50 const int screen_height = atoi(argv[3]); 51 printf("INFO Using camera %i\n", cam_number); 52 printf("INFO Screen size %ix%i\n", screen_width, screen_height); 39 53 CvCapture *capture = cvCaptureFromCAM(cam_number); 40 54 int width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); … … 122 136 xmax = n; 123 137 ymax = m; 124 printf("Current value: %ix%i=%i\n", xmax, ymax, cvalue);138 //printf("Current value: %ix%i=%i\n", xmax, ymax, cvalue); 125 139 } 126 140 } else { … … 155 169 cvCopy(output,filter, NULL); 156 170 cvCircle(target, cvPoint(xmax, ymax), 10, CV_RGB(255,0,0),4, 8, 0); 157 xdo_mousemove(xdo,xmax,ymax); 171 xdo_mousemove(xdo, ratio(xmax,width,screen_width), 172 ratio(ymax,height,screen_height)); 158 173 159 174 … … 192 207 retval = InitSystem(argc, argv); 193 208 xdo_free(xdo); 194 } 209 return(retval); 210 }
Note:
See TracChangeset
for help on using the changeset viewer.