← Back to team overview

sikuli-driver team mailing list archive

[Question #676753]: find(image_path) always gives template size error

 

New question #676753 on Sikuli:
https://answers.launchpad.net/sikuli/+question/676753

I am trying to compare screenshots of the phone before and after a click. Ideally, after a click, I would wait for a moment to see if there is any change in UI, and if it detects a change then i would take a screenshot of it. 

This is the function that i coded out .


def observe_and_click(phone_region, pixel_region, handler, observe_time):
    global i 
    path = capture(phone_region,"/Users/ongyichong/SikuliX/Scripts","temp") # capture the current screenshot before click
    pixel_region.click() # make pixel click on region 
    wait(0.5)  # wait for UI transitions if any  
    try:
        match = phone_region.find(path) # find a match for this
        #path_1 = capture(phone_region,"/Users/ongyichong/SikuliX/Scripts",str(i))
        print("similarity: " + str(match.getScore()))
    except FindFailed or CvException:  
        # screenshots are dissimilar, take screenshot 
        path_1 = capture(phone_region,"/Users/ongyichong/SikuliX/Scripts",str(i))
        i += 1

I dont know why the line match = phone_region.find(path) always throws this error:
/Users/raimundhocke/SikuliX/OpenCV/opencv-3.4.2/modules/imgproc/src/templmatch.cpp:1107: error: (-215:Assertion failed) _img.size().height <= _templ.size().height &
& _img.size().width <= _templ.size().width in function 'matchTemplate'

Since I am using sikuli's capture function the image captured should be of similar pixels. Why there be a mismatch in the template size ? 

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