mirror of
https://github.com/bspeice/libcvautomation
synced 2024-12-04 13:58:11 -05:00
Document and implement the "tolerance" setting better
This commit is contained in:
parent
157ecea655
commit
6d1e25686b
@ -64,6 +64,12 @@ void matchSubImage_a_location_center ( const char *rootImageFileName, cvautomati
|
||||
|
||||
/** \page libcv_search_methods Libcv Search Methods
|
||||
This page describes the methods libcv uses to search for a sub image in a root image.
|
||||
\section tolerance Tolerance Values
|
||||
Tolerance values are used to control how strict each of the following search methods are. Acceptable values are from \c INT_MIN to \c INT_MAX.
|
||||
|
||||
Additionally, each of the reference programs - \c cva-input and \c cva-match - have a "sane tolerance" built in. This is accessed by the "-o" switch, and allows you to specify a tolerance on scale of 1-100, where 1 is incredibly strict, and 100 is incredibly loose.
|
||||
\note The formula for calculating the sane tolerance is: \f$ T(x) = (10^{\frac{\log{INT\_MAX}}{\lambda}})^x \f$ where \f$ \lambda \f$ is the highest tolerance value (in our case, 100). Finally, we have to round down a little bit to ensure that we don't accidentally generate a value higher than \c INT_MAX. The formula used does mean that we will never be able to generate values lower than 0.
|
||||
\warning The "sane-tolerance" option doesn't know which search method you are using - Thus while 1 is an incredibly strict search for \ref SQDIFF and \ref SQDIFF_NORMED, it is fairly loose search for \ref CCORR, \ref CCORR_NORMED, \ref CCOEFF, and \ref CCOEFF_NORMED
|
||||
\section SQDIFF Squared Difference
|
||||
\code #define CV_TM_SQDIFF 0 \endcode
|
||||
Squared Difference is the default search method used by \c libcvautomation, as well as \c cva-match and \c cva-input.
|
||||
|
@ -262,14 +262,23 @@ typedef struct {
|
||||
* <li>First things first, run through the testing wrapper to make sure that everything is O.K.
|
||||
* <li>If you need to, some things you can do to tune the application test are as follows:
|
||||
* <ul>
|
||||
* <li>Set the \c SEARCH_METHOD
|
||||
* <ul>
|
||||
* <li>This value adjusts how libcvautomation searches for sub-images. See \ref libcv_search_methods for more information on accepted values, and how each works.
|
||||
* </ul>
|
||||
* <li>Set the \c TOLERANCE
|
||||
* <ul>
|
||||
* <li>This value adjusts how strict libcvautomation is when trying to find a sub-image. See \ref libcv_search_methods for more information on how to control how libcvautomation searches for images.
|
||||
* </ul>
|
||||
* <li>Set the \c CENTER
|
||||
* <li>Set \c USE_SANE_TOLERANCE
|
||||
* <ul>
|
||||
* <li>By default, the wrapper will use the center of an image as opposed to the upper-left corner to click on. To change this behavior, set: \code CENTER="" \endcode
|
||||
* <li>To set the behavior back to using center-based matching, set: \code CENTER="c" \endcode
|
||||
* <li>This value implements a more sane way of setting the tolerance value - Where normally the tolerance ranges from \c INT_MIN to \c INT_MAX, the sane tolerance accepts values of 1 - 100 (\f$ 1 \approx 0 \f$, and \f$ 100 \approx \c INT_MAX \f$)
|
||||
* <li>To enable sane tolerance, set: \code USE_SANE_TOLERANCE="<any_value>" \endcode
|
||||
* <li>To disable sane tolerance (the default) set: \code USE_SANE_TOLERANCE="" \endcode
|
||||
* <li>Set \c USE_CENTER
|
||||
* <ul>
|
||||
* <li>By default, the wrapper will use the center of an image as opposed to the upper-left corner to click on. To disable this behavior, set: \code USE_CENTER="" \endcode
|
||||
* <li>To set the behavior back to using center-based matching, set: \code USE_CENTER="<any_value>" \endcode
|
||||
* </ul>
|
||||
* <li>Set the \c OUTFILE and \c ERRFILE
|
||||
* <ul>
|
||||
|
@ -29,9 +29,13 @@ CVAINPUT=`which cva-input` || echo "Could not find the cva-input program..." &>2
|
||||
#Some program-wide configs
|
||||
SEARCH_METHOD=0 #CV_TM_SQDIFF
|
||||
TOLERANCE=2250000
|
||||
CENTER="--center"
|
||||
USE_SANE_TOLERANCE=""
|
||||
#Uncomment to enable sane tolerance matching
|
||||
#USE_SANE_TOLERANCE="yes"
|
||||
|
||||
USE_CENTER="yes"
|
||||
#Uncomment to disable center-of-image matching
|
||||
#CENTER=""
|
||||
#USE_CENTER=""
|
||||
|
||||
|
||||
#Quick trick to allow for easy redirection of output
|
||||
@ -142,7 +146,13 @@ click_i ()
|
||||
COMMAND_LINE+="-s 'i${center}mouseclick $x' "
|
||||
done
|
||||
|
||||
eval $CVAINPUT --tolerance $TOLERANCE --search-method $SEARCH_METHOD $COMMAND_LINE >> $OUTFILE
|
||||
if [ -n "$USE_SANE_TOLERANCE" ]; then
|
||||
TOLERANCE_OPTION="-o"
|
||||
else
|
||||
TOLERANCE_OPTION="-t"
|
||||
fi
|
||||
|
||||
eval $CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD $COMMAND_LINE >> $OUTFILE
|
||||
return $?
|
||||
} # ---------- end of function click_i ----------
|
||||
|
||||
@ -168,7 +178,18 @@ image_location ()
|
||||
done
|
||||
|
||||
#Find our sub-image
|
||||
MATCH=`$CVAMATCH -t $TOLERANCE $CENTER --x-root $COMMAND_LINE`
|
||||
if [ -n "$SANE_TOLERANCE" ]; then
|
||||
TOLERANCE_OPTION="-o"
|
||||
else
|
||||
TOLERANCE_OPTION="-t"
|
||||
fi
|
||||
if [ -n "$CENTER" ]; then
|
||||
USE_CENTER="--center"
|
||||
else
|
||||
USE_CENTER=""
|
||||
fi
|
||||
|
||||
MATCH=`$CVAMATCH $TOLERANCE_OPTION $TOLERANCE $USE_CENTER --x-root $COMMAND_LINE`
|
||||
RETURN_CODE=$?
|
||||
out "$MATCH"
|
||||
MATCH=`echo $MATCH | head -n1`
|
||||
@ -213,7 +234,7 @@ hover_xy ()
|
||||
|
||||
out "hover_xy: $X_LOC $Y_LOC"
|
||||
|
||||
$CVAINPUT -s "mousexy $X_LOC $Y_LOC" >> $OUTFILE
|
||||
eval $CVAINPUT -s "mousexy $X_LOC $Y_LOC" >> $OUTFILE
|
||||
} # ---------- end of function hover_xy ----------
|
||||
|
||||
#--- FUNCTION ----------------------------------------------------------------
|
||||
@ -241,7 +262,7 @@ hoverr_xy ()
|
||||
|
||||
out "hoverr_xy: $X_INC $Y_INC"
|
||||
|
||||
$CVAINPUT -s "mouserxy $X_INC $Y_INC" >> $OUTFILE
|
||||
eval $CVAINPUT -s "mouserxy $X_INC $Y_INC" >> $OUTFILE
|
||||
} # ---------- end of function hoverr_xy ----------
|
||||
|
||||
|
||||
@ -262,7 +283,7 @@ hover_i ()
|
||||
|
||||
for x in $@
|
||||
do
|
||||
if [ x$CENTER != "x" ]; then
|
||||
if [ -n $CENTER ]; then
|
||||
center="c"
|
||||
else
|
||||
center=""
|
||||
@ -272,7 +293,13 @@ hover_i ()
|
||||
|
||||
out "hover_i: $@"
|
||||
|
||||
eval $CVAINPUT --tolerance $TOLERANCE --search-method $SEARCH_METHOD $COMMAND_LINE >> $OUTFILE
|
||||
if [ -n $USE_SANE_TOLERANCE ]; then
|
||||
TOLERANCE_OPTION="-o"
|
||||
else
|
||||
TOLERANCE_OPTION="-t"
|
||||
fi
|
||||
|
||||
eval $CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD $COMMAND_LINE >> $OUTFILE
|
||||
return $?
|
||||
} # ---------- end of function hover_i ----------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user