mirror of
https://github.com/bspeice/libcvautomation
synced 2024-12-04 13:58:11 -05:00
Put in a warning about using waitfor without a tolerance value
This commit is contained in:
parent
bf0e01bb66
commit
77beb217d3
@ -194,6 +194,7 @@ Usage: \n\
|
||||
\t-o, --sane-tolerance:\tSet the tolerance using a scale of 1-100,\n\
|
||||
\t-s, --string:\t\tCommand string - see below.\n\
|
||||
\t-i, --timeout:\t\tSpecify the timeout to use when using the 'waitfor' function\n\
|
||||
\t\t\t\tPlease make sure to use the '-t' or '-o' options when using this.\n\
|
||||
\n\
|
||||
This program works kind of like a mini-language. All options\n\
|
||||
are parsed left-to-right, and executed right there. Thus, specifying \"--display\"\n\
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* Autoconf logic to select the correct OpenCV version */
|
||||
@cv_headers@
|
||||
@ -297,6 +298,7 @@ typedef struct {
|
||||
* TIMEOUT \endcode
|
||||
* These control how the "waitfor" function is used. By default, all image-matching functions will wait for an image to appear, and then click on it. This way, it won't click randomly if it can or can't find an image, and provides very easy error recognition. The functions will wait for a period of \c TIMEOUT seconds before complaining.
|
||||
* To disable waiting before performing an action, set \code USE_WAIT="" \endcode
|
||||
* \warning Without setting a tolerance value, the waitfor function becomes totally useless, as the first search will always find an image. <tt>Make sure to set the tolerance</tt> (or just leave it as the default value in the wrapper).
|
||||
*
|
||||
* \subsection appendix_output Output and Debugging
|
||||
* \code OUTFILE
|
||||
|
@ -802,6 +802,19 @@ cvaPoint xte_waitForImage_location ( Display *displayLocation, const char *fileN
|
||||
cvaPoint resultPoint;
|
||||
resultPoint.x = resultPoint.y = -1;
|
||||
|
||||
/* The next conditional bears some discussion. Due to the way template matching works,
|
||||
* if the tolerance is INT_MAX or INT_MIN (depending on the search method) you will
|
||||
* *always* get a result back. Thus, while your intentions may be good, you kill
|
||||
* the point of waiting until an image appears. Please tune your tolerance values. */
|
||||
if ((searchMethod == CV_TM_SQDIFF && tolerance == INT_MAX) ||
|
||||
(searchMethod == CV_TM_SQDIFF_NORMED && tolerance == INT_MAX) ||
|
||||
(searchMethod == CV_TM_CCORR && tolerance == INT_MIN) ||
|
||||
(searchMethod == CV_TM_CCORR_NORMED && tolerance == INT_MIN) ||
|
||||
(searchMethod == CV_TM_CCOEFF && tolerance == INT_MIN) ||
|
||||
(searchMethod == CV_TM_CCOEFF_NORMED && tolerance == INT_MIN) )
|
||||
|
||||
fprintf( stderr, "Passing a bad tolerance value to xte_waitForImage_location()...\n" );
|
||||
|
||||
int localTime = 0;
|
||||
while ( localTime < timeout )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user