[Python] How to compare the contents of two images using sikuli?

Discussão em 'Python' iniciado por Stack, Julho 29, 2025.

  1. Stack

    Stack Membro Participativo

    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")


    It is always giving pop up hi not hello... though i haven't changed the screen.

    I can understand that these two are two different images names that's why always the else block is working. But is it possible to compare these two images. Contents of two images where there is some difference between the two. Was unable to upload the code so have commented it.. Help if anyone knows.

    Continue reading...

Compartilhe esta Página