Ignore:
Timestamp:
Dec 2, 2009, 4:44:00 PM (15 years ago)
Author:
Rick van der Zwet
Message:

Code presented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • liacs/mss/project/colour-tracking.c

    r19 r20  
    8787    int retval;
    8888    char arg1[4], arg2[4];
     89    int keycode;
     90    // Actually move the pointer to it's location
     91    int mouse_flag = 1;
     92    // XXX: Hack to have the pointer posted on the second screen.
     93    int ex_screen_flag = 0;
    8994       
    9095   
     
    169174        cvCopy(output,filter, NULL);
    170175        cvCircle(target, cvPoint(xmax, ymax), 10, CV_RGB(255,0,0),4, 8, 0);
    171         xdo_mousemove(xdo, ratio(xmax,width,screen_width),
    172             ratio(ymax,height,screen_height));
     176        // Set to pointer to new location
     177        if (mouse_flag) {
     178            if (ex_screen_flag) {
     179                xdo_mousemove(xdo, ratio(xmax,width,screen_width) + screen_width - 250,
     180                    ratio(ymax,height,screen_height));
     181            } else {
     182                xdo_mousemove(xdo, ratio(xmax,width,screen_width),
     183                    ratio(ymax,height,screen_height));
     184            }
     185        }
    173186                       
    174187
     
    181194                   
    182195               
    183         // wait for any to press to quit
    184         // Eeks! also HACK to make it refresh properly
    185         if (cvWaitKey(20) != -1) {
    186                 break;
    187         }
     196        // Process some keyboard input for handy selection
     197        // Eeks! also HACK to make it refresh properly
     198        keycode = cvWaitKey(20);
     199        if (keycode != -1) {
     200            printf("Keycode: %i\n", keycode);
     201            if (keycode == 'q') {
     202                        break;
     203            } else if (keycode == 'm') {
     204                mouse_flag =  (mouse_flag == 1) ? 0 : 1;
     205            } else if (keycode == 'e') {
     206                ex_screen_flag =  (ex_screen_flag == 1) ? 0 : 1;
     207
     208            }
     209            }
    188210    } //for each frame ...
    189211
Note: See TracChangeset for help on using the changeset viewer.