Search code examples
pythonsikuliregions

Sikulli: Passing Regions to setROI() function


Lets say that in Sikulli I create a region called myRegion and pass it to setROI().Would using find(pictureIWantToFind) be just as fast as if I didn't use setROI() and instead called find(myRegion.inside().exists(pictureIWantToFind))?

Also, setROI() will continue to use that region of interest until you tell it otherwise such as with setROI(SCREEN)?


Solution

  • As you have it stated, yes, I believe that using SetROI() would be slightly faster than find(myRegion.inside().exists(PictureYouWantToFind)--just marginally.

    -BUT-

    1. Because the find() operation is a method of the Region class, instead of calling find(myRegion.inside().exists(myPic)), you can accomplish the same thing a little more simply this way: myRegion.find(myPic)

    2. The default ROI is the whole screen referenced with the reserve word "SCREEN". So, find(myPic) is the same as SCREEN.find(myPic). Passing myRegion to setROI(), as in setROI(myRegion), redefines SCREEN so that now SCREEN = myRegion. If you choose to use setROI() be aware--all following Region operations (such as wait() or exists()) would act on myRegion and not on the whole screen, until you redefine it as such, as per this answer in the Sikuli forums.

    In sum, myRegion.find(myPic) will allow you to search the smaller ROI, without renaming SCREEN.