mirror of
https://github.com/bspeice/libcvautomation
synced 2025-05-14 12:11:29 -04:00
Set up cva-match to support multiple sub images
This commit is contained in:
parent
7a7b87babb
commit
84212eb006
@ -25,6 +25,13 @@
|
|||||||
|
|
||||||
void usage ();
|
void usage ();
|
||||||
|
|
||||||
|
struct list {
|
||||||
|
char *fileName;
|
||||||
|
struct list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct list basic_list;
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
CvPoint result_point;
|
CvPoint result_point;
|
||||||
@ -39,6 +46,9 @@ int main( int argc, char** argv )
|
|||||||
int useX = 0; /* bool useX = false; */
|
int useX = 0; /* bool useX = false; */
|
||||||
char *xDisplay;
|
char *xDisplay;
|
||||||
|
|
||||||
|
/* Set up the linked list for slave images */
|
||||||
|
basic_list *list_head = NULL, *list_curr = NULL;
|
||||||
|
|
||||||
/* Start getopt */
|
/* Start getopt */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -58,7 +68,7 @@ int main( int argc, char** argv )
|
|||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
|
|
||||||
int c = getopt_long (argc, argv, "hur:s:p:m:t:x:",
|
int c = getopt_long (argc, argv, "hur:s:p:m:t:x::",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
|
|
||||||
/* We're done with parsing options */
|
/* We're done with parsing options */
|
||||||
@ -83,7 +93,14 @@ int main( int argc, char** argv )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
sub_location = optarg;
|
if ( list_head == NULL )
|
||||||
|
{
|
||||||
|
list_head = (basic_list *) malloc (sizeof(basic_list));
|
||||||
|
list_curr = list_head;
|
||||||
|
}
|
||||||
|
list_curr->fileName = optarg;
|
||||||
|
list_curr->next = (basic_list *) malloc (sizeof(basic_list));
|
||||||
|
list_curr = list_curr->next;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -99,14 +116,12 @@ int main( int argc, char** argv )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
if (optarg) {
|
if ( optarg != NULL ) {
|
||||||
useX = 1;
|
useX = 1;
|
||||||
xDisplay = optarg;
|
xDisplay = optarg;
|
||||||
printf ("Using display %s", xDisplay);
|
|
||||||
} else {
|
} else {
|
||||||
useX = 1;
|
useX = 1;
|
||||||
xDisplay = "";
|
xDisplay = "";
|
||||||
printf ("Using display %s", xDisplay);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -121,6 +136,17 @@ int main( int argc, char** argv )
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure we have a linked list,
|
||||||
|
* and reset the linked list to go back through from the top */
|
||||||
|
if ( list_head == NULL )
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
list_curr = list_head;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
sub_location = list_curr->fileName;
|
||||||
|
|
||||||
if (useX)
|
if (useX)
|
||||||
result_point = matchSubImage_X11_location( xDisplay, sub_location, search_method, threshold );
|
result_point = matchSubImage_X11_location( xDisplay, sub_location, search_method, threshold );
|
||||||
else
|
else
|
||||||
@ -128,7 +154,14 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
if ( result_point.x != -1 && result_point.y != -1 )
|
if ( result_point.x != -1 && result_point.y != -1 )
|
||||||
/* Output the match location */
|
/* Output the match location */
|
||||||
printf ("%i%s%i\n", result_point.x, separator, result_point.y );
|
printf ("%s%s%i%s%i\n", list_curr->fileName, separator,
|
||||||
|
result_point.x, separator, result_point.y );
|
||||||
|
|
||||||
|
/* With the way we allocate the list, we ensure that we always
|
||||||
|
* have at least one element past the end of the list */
|
||||||
|
list_curr = list_curr->next;
|
||||||
|
|
||||||
|
} while ( list_curr->fileName != NULL );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -156,7 +189,7 @@ Usage: \n\
|
|||||||
\t-r, --root-image:\tLocation of the root image to compare against.\n\
|
\t-r, --root-image:\tLocation of the root image to compare against.\n\
|
||||||
\t-s, --sub-image:\tLocation of the sub-image to find in root.\n\
|
\t-s, --sub-image:\tLocation of the sub-image to find in root.\n\
|
||||||
\t-p, --separator:\tSeparator of the X and Y coordinates.\n\
|
\t-p, --separator:\tSeparator of the X and Y coordinates.\n\
|
||||||
\t-t, --threshold:\tSet how strict the match is - 50 is recommended lowest value.\n\
|
\t-t, --threshold:\tSet how strict the match is - 100 is recommended lowest value.\n\
|
||||||
\t\t\t\tNote: When using CCORR or CCOEFF threshold works in opposite direction,\n\
|
\t\t\t\tNote: When using CCORR or CCOEFF threshold works in opposite direction,\n\
|
||||||
\t\t\t\tso -50 is recommended highest value.\n\
|
\t\t\t\tso -50 is recommended highest value.\n\
|
||||||
\t-m, --search-method:\tSet which method is used to search for sub-images.\n\
|
\t-m, --search-method:\tSet which method is used to search for sub-images.\n\
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* =====================================================================================
|
|
||||||
*
|
|
||||||
* Filename: cva-match.h
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
*
|
|
||||||
* Version: 1.0
|
|
||||||
* Created: 06/21/2012 08:34:21 AM
|
|
||||||
* Revision: none
|
|
||||||
* Compiler: gcc
|
|
||||||
*
|
|
||||||
* Author: Bradlee Speice, bspeice@uncc.edu
|
|
||||||
* Organization: MOSAIC at University of North Carolina at Charlotte
|
|
||||||
*
|
|
||||||
* =====================================================================================
|
|
||||||
*/
|
|
||||||
#ifndef CVA_MATCH_H
|
|
||||||
#define CVA_MATCH_H
|
|
||||||
|
|
||||||
void usage ();
|
|
||||||
int main(int, char**);
|
|
||||||
|
|
||||||
#endif /* CVA_MATCH_H */
|
|
Loading…
Reference in New Issue
Block a user