Put in a warning about using waitfor without a tolerance value

This commit is contained in:
Bradlee Speice
2012-07-20 14:02:52 -04:00
parent bf0e01bb66
commit 77beb217d3
3 changed files with 16 additions and 0 deletions

View File

@ -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 )
{