Python 如何使用sikuli比较两幅图像的内容?

Python 如何使用sikuli比较两幅图像的内容?,python,sikuli,Python,Sikuli,它总是弹出“你好”而不是“你好”。。。虽然我没有改变屏幕 我可以理解这两个是两个不同的图像名称,这就是为什么else块总是工作的原因。但是有没有可能比较这两幅图像呢。两个图像之间存在差异的内容。 无法上载代码,因此已对其进行了注释。。如果有人知道,请提供帮助。您似乎在比较包含文件名的字符串,而不是图像内容本身。尝试添加一些语句,如print(img)和print(img2),以了解发生了什么,并阅读有关如何实际比较图像的文档。是的,我也尝试过,它提供了img的信息,但我希望内容有所不同 impo

它总是弹出“你好”而不是“你好”。。。虽然我没有改变屏幕

我可以理解这两个是两个不同的图像名称,这就是为什么else块总是工作的原因。但是有没有可能比较这两幅图像呢。两个图像之间存在差异的内容。
无法上载代码,因此已对其进行了注释。。如果有人知道,请提供帮助。

您似乎在比较包含文件名的字符串,而不是图像内容本身。尝试添加一些语句,如
print(img)
print(img2)
,以了解发生了什么,并阅读有关如何实际比较图像的文档。是的,我也尝试过,它提供了img的信息,但我希望内容有所不同
import shutil
import os
wait(5)
dir = os.path.dirname(getBundlePath()) # the folder, where your script is stored
img = capture(SCREEN) # snapshots the screen
shutil.move(img, os.path.join(dir, "shot.png")) # to make it persistent
wait(10)
dir = os.path.dirname(getBundlePath()) # the folder, where your script is stored
img2 = capture(SCREEN) # snapshots the screen
shutil.move(img2, os.path.join(dir, "shot2.png")) # to make it persistent
if img == img2:
    popup("hello")
else:
    popup("hi")
imagePath1 = capture()  #snapshots the screen
image1 = exists(imagePath1)  #Create a Match object
imagePath2 = capture()  #snapshots the screen
image2 = Pattern(imagePath2)  #Create a Matach Object
myRegion = Region(image1)  #make new region from the match object
if myRegion.exists(image2): #look in the region
    print "hello" #yeah it's in the region of the screen
else:
    print "hi"  #nope not there....
imagePath1 = capture('Match obj take large picture') # snapshots the screen
matchObj1 = exists(imagePath1) #Make match object

imagePath2 = capture('Match obj take large picture') # snapshots the screen
matchObj2 = exists(imagePath2) #Make match object

imagePath3 = capture('Match obj take large picture') # snapshots the screen
matchObj3 = exists(imagePath3) #Make match object

imagePath4 = capture('Target, take small picture') # snapshots the screen 
patternIwant = Pattern(imagePath4) #Make a pattern object search against

matchList = [matchObj1, matchObj2, matchObj3]

for m in matchList:
    arg = m.exists(patternIwant)
    if arg != None:
        print 'image score  ', arg.getScore()
    else:
        print 'no match'
    if m.exists(patternIwant):
        print "hello"
    else:
        print "hi"