I had a situation where I needed to search a needle image at high frequency so I first located it from the whole screen and then spam-searched it again in that found Box() by using the found location as the region parameter in locate functions. To my surprise it couldn't find it there again. Then I lowered the confidence parameter in the locate functions (meaning it now needed also the OpenCV library) and it was only until 0.8 or lower that it found it again. The problem then was that one of the cases actually needed very high confidence level for my situation (it looked very similar most of the time but I needed to know when it only slightly changed). I then tried to increase the initial location Box() dimensions manually a few pixels each direction and it then worked at higher confidence levels again. So what I concluded was that there is somewhat inconsistency in this region parameter that is worth considering to be fixed. I think it is not exactly "one-off" problem as well, because when I first tried to increase the box by one pixel to each direction, it still failed. Kind of unexpected IMHO that the region that an image was found in cannot be expected to be used to subset initial haystack image to faster find the same needle image again...
If this is not possible then perhaps add a functionality/method to the Box() object that would allow it easily expand/shrink, as currently it is kind of annoying requiring duplicate code and recreation of tuples when doing it manually.
Note: I used pyautogui library but as far as I understood it very straightforward uses locate functions from this pysreeze library and the returned Box() object has type descriptions from this library as well.
https://github.com/asweigart/pyscreeze/blob/eeca245a135cf171c163b3691300138518efa64e/pyscreeze/__init__.py#L353
I had a situation where I needed to search a needle image at high frequency so I first located it from the whole screen and then spam-searched it again in that found
Box()
by using the found location as theregion
parameter inlocate
functions. To my surprise it couldn't find it there again. Then I lowered theconfidence
parameter in thelocate
functions (meaning it now needed also the OpenCV library) and it was only until 0.8 or lower that it found it again. The problem then was that one of the cases actually needed very high confidence level for my situation (it looked very similar most of the time but I needed to know when it only slightly changed). I then tried to increase the initial locationBox()
dimensions manually a few pixels each direction and it then worked at higher confidence levels again. So what I concluded was that there is somewhat inconsistency in thisregion
parameter that is worth considering to be fixed. I think it is not exactly "one-off" problem as well, because when I first tried to increase the box by one pixel to each direction, it still failed. Kind of unexpected IMHO that the region that an image was found in cannot be expected to be used to subset initial haystack image to faster find the same needle image again...If this is not possible then perhaps add a functionality/method to the
Box()
object that would allow it easily expand/shrink, as currently it is kind of annoying requiring duplicate code and recreation of tuples when doing it manually.Note: I used
pyautogui
library but as far as I understood it very straightforward useslocate
functions from thispysreeze
library and the returnedBox()
object has type descriptions from this library as well.