[1.1.4] OpenCV: ScreenShot BufferedImage to Mat: intermittent error j < nsrcs && src[j].depth() == depth

Bug #1817962 reported by Krisjanis Berzins on 2019-02-27
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I am trying to figure out this intermittent error that sometimes shows up after the script has run for some time:

[error (27/02/2019, 17:38:38)] Error caused by: Traceback (most recent call last):
  File "C:\SikuliX\project.sikuli\project.py", line 884, in <module>
  File "C:\SikuliX\project.sikuli\project.py", line 822, in lookForExit
    if regionArrows.exists(arrRB,0.5) and Dir == "L":
 at org.opencv.core.Core.mixChannels_0(Native Method)
 at org.opencv.core.Core.mixChannels(Core.java:1740)
 at org.sikuli.script.Finder2.makeMat(Finder2.java:494)
 at org.sikuli.script.Finder2.makeMat(Finder2.java:477)
 at org.sikuli.script.Finder.setScreenImage(Finder.java:144)
 at org.sikuli.script.Finder.initScreenFinder(Finder.java:139)
 at org.sikuli.script.Finder.<init>(Finder.java:124)
 at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:2938)
 at org.sikuli.script.Region.checkLastSeenAndCreateFinder(Region.java:2899)
 at org.sikuli.script.Region.doFind(Region.java:2846)
 at org.sikuli.script.Region.access$300(Region.java:21)
 at org.sikuli.script.Region$RepeatableFind.run(Region.java:3109)
 at org.sikuli.script.Region$Repeatable.repeat(Region.java:3060)
 at org.sikuli.script.Region.exists(Region.java:2376)
 at jdk.internal.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
org.opencv.core.CvException: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.2) C:\build\3_4_winpack-bindings-win64-vc14-static\opencv\modules\core\src\channels.cpp:128: error: (-215:Assertion failed) j < nsrcs && src[j].depth() == depth in function 'cv::mixChannels'

This is running on Windows 7 64 bit
Standard SikuliX installation on 1.1.4 latest nightly build. No custom libraries or any fancy stuff. The "C:\build" does not exist on this machine, but not sure if that is a problem, it just refers to the original source file pre-compilation perhaps?

I've attached the image file thats being used in that search function. Note that it was saved as PNG using Paint after it was cropped from the original SikuliX captured file.

I don't see any other correlations with something else happening at the time these errors are thrown. They seem fairly random to me.

Initial research suggest something to do with OpenCV mixChannels not accepting the particular image format/colour depth or so on. But It could be because something else of course?

RaiMan (raimund-hocke) wrote :

It has nothing to do with the used image.

It is a problem with the screenshot taken from regionArrows, when trying to convert the shot's BufferedImage into an OpenCV Mat object as base for the search.

This might be caused internally by some image buffer access problems due to timing (buffer not yet completely filled on the Java image side, but already accessed by the OpenCV Mat logic).

This normally does not make problems, but might do so in overload situations.

I have not implemented any checks on such possible race situations.

I keep this as a bug with low prio to be watched

Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.4
summary: - intermittent error j < nsrcs && src[j].depth() == depth
+ [1.1.4] OpenCV: BufferedImage to Mat: intermittent error j < nsrcs &&
+ src[j].depth() == depth
summary: - [1.1.4] OpenCV: BufferedImage to Mat: intermittent error j < nsrcs &&
- src[j].depth() == depth
+ [1.1.4] OpenCV: ScreenShot BufferedImage to Mat: intermittent error j <
+ nsrcs && src[j].depth() == depth
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers