Add basic XTest functionality, clean up and refactor other sources

This commit is contained in:
Bradlee Speice
2012-06-26 14:07:03 -04:00
parent 62431b5a18
commit ca39bd90be
10 changed files with 699 additions and 44 deletions

View File

@ -45,10 +45,13 @@ int main( int argc, char** argv )
int search_method = CV_TM_SQDIFF;
int useX = 0; /* bool useX = false; */
int useCenter = 0;
char *xDisplay;
char *xDisplayLocation;
Display *display;
/* This line to suppress a compiler warning */
display = NULL;
/* Set the default display */
xDisplay = "";
xDisplayLocation = "";
/* Set up the linked list for slave images */
basic_list *list_head = NULL, *list_curr = NULL, *list_prev = NULL;
@ -124,10 +127,12 @@ int main( int argc, char** argv )
case 'x':
if ( optarg != NULL ) {
useX = 1;
xDisplay = optarg;
xDisplayLocation = optarg;
display = XOpenDisplay(xDisplayLocation);
} else {
useX = 1;
xDisplay = "";
xDisplayLocation = "";
display = XOpenDisplay(xDisplayLocation);
}
break;
@ -163,9 +168,9 @@ int main( int argc, char** argv )
sub_location = list_curr->fileName;
if (useX && useCenter)
result_point = matchSubImage_X11_location_center( xDisplay, sub_location, search_method, tolerance );
result_point = matchSubImage_X11_location_center( display, sub_location, search_method, tolerance );
else if (useX && !useCenter)
result_point = matchSubImage_X11_location( xDisplay, sub_location, search_method, tolerance );
result_point = matchSubImage_X11_location( display, sub_location, search_method, tolerance );
else if (!useX && useCenter)
result_point = matchSubImage_location_center( root_location, sub_location, search_method, tolerance );
else /* if (!useX && !useCenter) */
@ -188,6 +193,10 @@ int main( int argc, char** argv )
/* And free the final element */
free(list_curr);
/* Clean up X */
if (useX)
XCloseDisplay(display);
return 0;
}