def findSubimageClickLocation(subImage,device): path=os.getcwd() referenceImageFilename = rename2ReferenceImg(subImage) ScreenCaptureDevice(referenceImageFilename,device) subImgPathed = path +"\\"+ pathimage +"\\"+ subImage referenceImgPathed = path +"\\"+ pathimage +"\\"+referenceImageFilename ''' start = time.clock() print "> Start Time: %s" % start ''' referenceImgSikuli = Finder(referenceImgPathed) subImgSikuli = referenceImgSikuli.find(subImgPathed) if referenceImgSikuli.hasNext(): # time elapse 46ms to find the url box-star subImgLocation = referenceImgSikuli.next() # Format: 'Match[420,71 17x18 score=1.00 target=center]' return True, subImgLocation.getX(), subImgLocation.getY() else: # time elase 100ms to not find the url box-star return False, 0, 0 '''
def compareImgsSikuli(referenceImg,capturedImg): # reference img has to be bigger than captured img ''' NOTE from SIkuli: The default minimum similarity is 0.7. when using hasNext() or Next() To compare at a lower score use: f.find(client-image, 0.3) so even "very" different images might match and you can decide further using the above score. ''' path = os.getcwd() referenceImgPathed = path + "\\" + pathimage + "\\" + referenceImg capturedImgPathed = path + "\\" + pathimage + "\\" + capturedImg refImg = Finder(referenceImgPathed) refImg.find(capturedImgPathed) if refImg.hasNext(): score = refImg.next().getScore() return score else: #print "didn't find it" return 0
finder = None cropped_images = [] for crop_filename in image_filenames: crop_basename = splitext(basename(crop_filename))[0] # print "crp {} vs img {}".format(crop_basename, image_basename) if image_filename is not crop_filename: if crop_basename.startswith(image_basename): #print "base match" cropped_images.append(crop_filename) print cropped_images for cropped_image in cropped_images: print "cropped_image " + cropped_image if finder is None: finder = Finder(image_filename) print "matching {} in {}".format(cropped_image, image_filename) # match cropped_image in image_filename finder.findAll(cropped_image) matches = sorted((m for m in finder), key=lambda m:m.getScore()) l = len(matches) print "found {} matches".format(l) if l == 1: m = matches[0] name = splitext(basename(cropped_image))[0] image_dict[name] = { 'filename': relpath(cropped_image, getBundlePath()), 'source_filename': relpath(image_filename, getBundlePath()), 'source': image_basename, 'x': m.getX(),