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

Description changed to:
So this is an example of the code I'm working with, the real code has
twenty images, but I've simplified it to three.

mySimilarity = 0.86
count = 0
main_address = r"C:\Users\USER_ADDRESS\4thloop"
while True:# Searching......at the 4th loop. LAST ADDED 13 04 2018
  while (count < 10): # Reduce the Match by 9 percent.
        if 
exists(Pattern(Pattern("1519473664449.png").targetOffset(1,-22)).similar(mySimilarity)):
          print('found 1st image at similarity %f') % mySimilarity
          first_image_used =  main_address + r"\first_image_used.txt"
          file = open(first_image_used)
          current_amount_of_times_image_used = file.read()
          file.close()
          new_current_amount_of_times_image_used = int(1) + 
int(current_amount_of_times_image_used)
          print('Number of times this image has been found %f') % 
new_current_amount_of_times_image_used
          text = str(new_current_amount_of_times_image_used)
          f = open(first_image_used, 'w')
          f.write(text)
          f.flush()
          f.close()
          break
        elif 
exists(Pattern(Pattern("1525270211713.png").targetOffset(1,-21)).similar(mySimilarity)):
          print('found 2nd image at similarity %f') % mySimilarity
          second_image_used =  main_address + r"\second_image_used.txt"
          file = open(second_image_used)
          current_amount_of_times_image_used = file.read()
          file.close()
          new_current_amount_of_times_image_used = int(1) + 
int(current_amount_of_times_image_used)
          print('Number of times this image has been found %f') % 
new_current_amount_of_times_image_used
          text = str(new_current_amount_of_times_image_used)
          f = open(second_image_used, 'w')
          f.write(text)
          f.flush()
          f.close()
          break
        elif 
exists(Pattern(Pattern("1525274687366.png").targetOffset(1,-22)).similar(mySimilarity)):
          print('found 3rd image at similarity %f') % mySimilarity
          third_image_used =  main_address + r"\third_image_used.txt"
          file = open(third_image_used)
          current_amount_of_times_image_used = file.read()
          file.close()
          new_current_amount_of_times_image_used = int(1) + 
int(current_amount_of_times_image_used)
          print('Number of times this image has been found %f') % 
new_current_amount_of_times_image_used
          text = str(new_current_amount_of_times_image_used)
          f = open(third_image_used, 'w')
          f.write(text)
          f.flush()
          f.close()
          break
        else:
          count = count + 1
          mySimilarity = mySimilarity - 0.01 # reduce by 1%
          print('mySimilarity is %f') % mySimilarity
          if count > 8:
                print('none of the images found.')
                popup('none of the images found.')
          continue # retry from the beginning
  break

When "none of the images found" is printed excessively I go looking for the 
corresponding text file with a zero in it, I replace the image, then start the 
program over from the beginning, all up that wastes about 10 minutes.
So I've discovered the screen capture feature, so I figure I can automate the 
process by having a new screenshot taken of images as they are found, but I'm 
not sure how to return the dimensions of a found image.
Once I know how to return the dimensions of a found image I can update the 
least recognized images.
Hope that made sense.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to