[2.0.4] CvException "Sizes of input arguments do not match" with observeInBackground and automasked images --- GitHub #347

Bug #1856719 reported by Gilles Carry
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SikuliX
Invalid
High
RaiMan

Bug Description

now tracked in GitHub: https://github.com/RaiMan/SikuliX1/issues/347

------------------------------------------------------------------------
Hello,

I'm using SikuliX-2.0.1 on Windows 7, Java 8.

I'm trying to setup an "answer all" machine to get rid of unexpected popups in the middle of a procedure rollout.
To reproduce the issue, consider the following simple example:
(get image files in attachements)
(use this program to match images rdp_connect_anyway.png and rdp_connection.png)

def clickNoHandler(event):
    event.match.click("1576165706268.png") # "No" button
    event.repeat()

def clickYesHandler(event):
    event.match.click("1576166585508.png") # "Yes" button
    event.repeat()

def clickConnectHandler(event):
    event.match.below().click("1576589919586.png") # "Connect" button
    event.repeat()

def answerAll():
    onAppear(Pattern("1576166492962.png").exact(), clickYesHandler) # Image without a mask
    onAppear("1576589851448.png", clickConnectHandler) # Image without a mask
    onAppear(Pattern("1573829195078.png").exact().targetOffset(2,6), clickNoHandler) # Image WITH an automask
    observeInBackground()

answerAll()
popup("Terminate")

When started from the IDE, popup "Terminate" appears and nothing happens. After having stopped the program (clicking on the popup), message pan shows:
Exception in thread "Thread-37" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.2) C:\build\3_4_winpack-bindings-win64-vc14-static\opencv\modules\core\src\arithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
]
        at org.opencv.core.Core.multiply_2(Native Method)
        at org.opencv.core.Core.multiply(Core.java:1831)
        at org.sikuli.script.Finder$FindInput2.setAttributes(Finder.java:1419)
        at org.sikuli.script.Finder$Finder2.find(Finder.java:614)
        at org.sikuli.script.Finder.find(Finder.java:280)
        at org.sikuli.script.support.Observer.checkPatterns(Observer.java:217)
        at org.sikuli.script.support.Observer.update(Observer.java:366)
        at org.sikuli.script.Region.observeDo(Region.java:3809)
        at org.sikuli.script.Region.access$700(Region.java:23)
        at org.sikuli.script.Region$ObserverThread.run(Region
.java:3876)
        at java.lang.Thread.run(Unknown Source)

I even tried with Sikulix-2.1.0 (built from commit 696314e322a07cc47319e9cf5a4a500ca838f0fc) and got roughly the same thing. (with opencv 4.1.1, obiously)
Exception in thread "Thread-35" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.1.1) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\core\src\arithm.cpp:663: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
]
        at org.opencv.core.Core.multiply_2(Native Method)
        at org.opencv.core.Core.multiply(Core.java:4382)
        at org.sikuli.script.Finder$FindInput2.setAttributes(Finder.java:1444)
        at org.sikuli.script.Finder$Finder2.find(Finder.java:628)
        at org.sikuli.script.Finder.find(Finder.java:280)
        at org.sikuli.script.support.Observer.checkPatterns(Observer.java:217)
        at org.sikuli.script.support.Observer.update(Observer.java:366)
        at org.sikuli.script.Region.observeDo(Region.java:3807)
        at org.sikuli.script.Region.access$600(Region.java:22)
        at org.sikuli.script.Region$ObserverThread.run(Reg
ion.java:3874)
        at java.lang.Thread.run(Unknown Source)

Commenting out third onAppear() line (the one with masked image) everything works perfectly. (though sometimes it is necessary the restart the IDE to recover from previous errors)

Masked image was created by deleting part of the picture. Note that using pattern matching outside of the observeInBackground context works perfectly with this image.

Thank-you for reading.

Revision history for this message
Gilles Carry (carryg) wrote :
Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [2.0.1] CvException "Sizes of input arguments do not match" with observeInBackground and automasked images

Thanks for the complete information.
I have to check.

Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 2.0.2
summary: - CvException "Sizes of input arguments do not match" with
+ [2.0.1] CvException "Sizes of input arguments do not match" with
observeInBackground and automasked images
Revision history for this message
Marcos Vinícius (marcosvrs) wrote :
Download full text (3.6 KiB)

Hi,
Any news? Same occurring here.

Sikulix
2.0.4-2020-03-14_08:01/Mac10.15.4/Java14(64)14.0.1+7

Darwin MAC 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

Following the error tracer:
[error] script [ Training ] stopped with error in line 66
[error] Error caused by: Traceback (most recent call last):
  File "/Users/User/Desktop/Training.sikuli/Training.py", line 66, in <module>
    dashboard.observe()
  File "/Users/User/Library/Application Support/Sikulix/Lib/sikuli/Region.py", line 59, in observe
    return self.observeInLine(waitTime);
]
 at org.opencv.core.Core.multiply_2(Native Method)
 at org.opencv.core.Core.multiply(Core.java:1831)
 at org.sikuli.script.Finder$FindInput2.setAttributes(Finder.java:1409)
 at org.sikuli.script.Finder$Finder2.find(Finder.java:579)
 at org.sikuli.script.Finder.find(Finder.java:219)
 at org.sikuli.script.support.Observer.checkPatterns(Observer.java:217)
 at org.sikuli.script.support.Observer.update(Observer.java:366)
 at org.sikuli.script.Region.observeDo(Region.java:3633)
 at org.sikuli.script.Region.observeInLine(Region.java:3604)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.inte
rnal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:564)
org.opencv.core.CvException: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.2) /Users/raimundhocke/SikuliX/OpenCV/opencv-3.4.2/modules/core/src/arithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'
]

Code:
Settings.MoveMouseDelay = 0.0
running = True
game = switchApp("Game.app")

def abort():
    global game
    global running
    stopObserver()
    type(Key.F4)
    wait(1)
    game.closeByKey()
    running = False

def runHotkey():
    global running
    stopObserver()
    running = False

def healing(event):
    if game.hasWindow():
        type(Key.F1)
        wait(1.1)
    event.repeat()

def mana(event):
    abort()
    wait(2)
    event.repeat()

def refilSmallStone(event):
    if not exists(Pattern("1589224230463.png").exact()):
        if game.hasWindow():
            type(Key.F8)
            wait(2)
    else:
        abort()
    event.repeat()

def eatFood(event):
    if not exists(Pattern("1589224208704.png").exact()):
        if game.hasWindow():
            type(Key.F12)
            wait(2)
    else:
        abort()
    event.repeat()

def attack(event):
    if game.hasWindow():
        with Region(1263,436,177,464) as attackList:
            if not attackList.exists(Pattern("1589131763363.png").exact()):
                Location(1314, 481).click()
                attackList.hover("1589223525078.png")
    wait(2)
    event.repeat()

Env.addHotkey(Key.ESC, KeyModifier.CMD, runHotkey)
with Region(1261,120,179,780) as dashboard:
    dashboard.on...

Read more...

Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [2.0.4] CvException "Sizes of input arguments do not match" with observeInBackground and automasked images

@marcos
Sorry, but obviously I lost this one.

Could you send me a screenshot and the offending image to sikulix---at---outlook---dot---com?

Would be helpful.

Changed in sikuli:
milestone: 2.0.2 → 2.0.5
summary: - [2.0.1] CvException "Sizes of input arguments do not match" with
+ [2.0.4] CvException "Sizes of input arguments do not match" with
observeInBackground and automasked images
RaiMan (raimund-hocke)
description: updated
description: updated
Revision history for this message
RaiMan (raimund-hocke) wrote :
summary: [2.0.4] CvException "Sizes of input arguments do not match" with
- observeInBackground and automasked images
+ observeInBackground and automasked images --- GitHub #347
Revision history for this message
Marcos Vinícius (marcosvrs) wrote :

@raimund-hocke

The problem is that this error is intermittent.
I tried to deactivate listener by listener to find out which one was causing the error, but they all worked separately. Only when I call them together does the error occur.
Maybe the problem is exactly executing the functions in parallel?
How can I help you with the screenshots in that case?

RaiMan (raimund-hocke)
Changed in sikuli:
status: In Progress → Fix Committed
importance: Medium → High
RaiMan (raimund-hocke)
Changed in sikuli:
status: Fix Committed → In Progress
RaiMan (raimund-hocke)
Changed in sikuli:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.