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