autopy-legacy
autopy-legacy copied to clipboard
Better define tolerance
I dont' think tolerance is really defined in the tutorial or the API doc. What are the valid ranges for tolerance values? 0.0 to 1.0? Or greater than 1 as well?
Based on testing, I'm assuming 0.0, the default, is must be exact match? And towards 1.0 means higher tolerance for partial or even no matches. At 1.0, for a test needle, testing with find bitmap against screen capture, it returns coordinates of (1,1) when the needle is not even present.
So would be helpful to clarify for users who are not well skilled in image recognition tools.
I was wondering about the same. Based on your finding, tolerance seems to indicate the amount of deviation from the colour that is still accepted as a match. Thus 1.0 would mean that 100% deviation is still OK, meaning that anything will pass.
Thanks for the description teukkam, that is helpful.
If you want the gory details, you can see in utils.c how it's calculated. The colours' Euclidean distance in the colourspace is calculated as a square root of the sums of each colour component delta (red, green and blue) which is compared against tolerance * 442, which means that at a tolerance of 1 or higher, anything will match even if the colour deltas exceed 256 which is the maximum.