← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #261815]: visible recognition too slow

 

Question #261815 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/261815

    Status: Open => Answered

RaiMan proposed the following answer:
see comments and try to understand by consulting the docs in parallel

checkboxreg=Region(670,391,46,204)

# beginning of loop

while True:
    wait("Stab.png",50)
    type("fff")

    #wait("O_Stab-2.png",10)
    # this saves one find and crashes anyways if not found
    click(wait("O_Stab-2.png",10))
    m_0_Stab = getLastMatch() # save for later

    #wait ("Begin.png",2)
    click (wait ("Begin.png",2))

    # does not make sense, since checkboxreg. does the same
    #setROI(checkboxreg) #setting the region defined previously to make scanning faster because of moving objects


# instaed you should use Pattern(img).targetOffset() using Preview
# this works, no matter where on the screen the Pattern is found
# example 
#    if checkboxreg.exists(Pattern(", Row_1-1.png").targetOffset(someX, someY), 10):
#        hover(checkboxreg.getLastMatch)

# but since your main problem is speed:

    end = time.time() + 10 # max 10 second
    while time.time() < end:
      if checkboxreg.exists("Row_1-1.png",0):
          hover(Location(760,411)) #next to row_1
  
      elif checkboxreg.exists("Row_2-1.png",0):
          hover(Location(760,463)) #next to row_2
  
      elif checkboxreg.exists("Row_3-1.png",0):
          hover(Location(760,519)) #next to #row_3
  
      elif checkboxreg.exists("Row_4-1.png",0):
          hover(Location(760,575)) #next to row_4

# now for max 10 seconds the 4 images are searched "quasi-parallel"

    # not needed now
    #setROI(SCREEN) #resetting recognition to whole screen

# also since the cycle above ends after some time i need to find a way
checking if the cycle has ended since there is a random duration
involved. preferably when another picture appears like the wait command
below, as it always shows up after the cycle is complete.

    wait("O_Stab_Collect.png", 55)
    #find("O_Stab-2.png") #doing this to move window to front again coz of overlaying items
    click(find("O_Stab-2.png"))
    # if "O_Stab-2.png" did not move meanwhile, this is much faster
    # click(m_0_Stab)
    
    # why the second click?
    #exists("O_Stab-2.png",10)
    #click ("O_Stab-2.png")
    #if needed, either
    click(getLastMatch()) #or
    # click(m_0_Stab)     

    wait (1)
    
# does not make sense with while True, since True never gets False
# while True shold have a ending condition inside (if something: break)
else:

    type("i")
    wait (1)
    type("i")
    wait (1)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.