Changeset 19 for liacs


Ignore:
Timestamp:
Dec 2, 2009, 7:33:14 AM (15 years ago)
Author:
Rick van der Zwet
Message:

Checkerboard generation (test field)

Location:
liacs/mss/project
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • liacs/mss/project/Makefile

    r17 r19  
    33CFLAGS+= -I/usr/include/opencv  -lcxcore -lcv -lhighgui -lcvaux -lml -lX11 -lXtst
    44
    5 all: uinput
    6         sudo ./uinput
    7 
    85tracking: colour-tracking
    9         ./colour-tracking 1
     6        ./colour-tracking 1 `xrandr  | awk '/\*/ {print $$1}' | tr 'x' ' '`
    107
    118colour-tracking: xdo.o
  • liacs/mss/project/colour-tracking.c

    r17 r19  
    3131}
    3232
     33/* Convert the virtual mapping to screen size */
     34int 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
    3341int InitSystem(int argc, char *argv[]) {
    3442    // 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);
    3953    CvCapture *capture = cvCaptureFromCAM(cam_number);
    4054    int width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
     
    122136                                xmax = n;
    123137                                ymax = m;
    124                                 printf("Current value: %ix%i=%i\n", xmax, ymax, cvalue);
     138                                //printf("Current value: %ix%i=%i\n", xmax, ymax, cvalue);
    125139                        }
    126140                } else {
     
    155169        cvCopy(output,filter, NULL);
    156170        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));
    158173                       
    159174
     
    192207   retval = InitSystem(argc, argv);
    193208   xdo_free(xdo);
    194 }
     209   return(retval);
     210}
Note: See TracChangeset for help on using the changeset viewer.