sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #30085
[Bug 1411151] [NEW] [request] Java: want a helper feature, to dynamically access and use the image and pattern definitions from a SikuliX script
Public bug reported:
motivated by the related question
https://answers.launchpad.net/sikuli/+question/260722
this is taken from comment #2:
This is an approach, to efficiently combine Java coding with SikuliX
features and the SikuliX IDE support.
- have the complete image handling in the IDE, just setting up scripts only containing images
such a script will simply be a list of image file names.
The images are then available in the folder you-name-it.sikuli
- now you code in Java and access the images using setBundlePath() or more efficiently using the ImagePath features.
For these high level features some useable docs are available (start here: http://sikulix.com).
One caveat:
In the IDE you have the Preview feature, that lets you adjust the minimum similarity and the targetOffset resulting in a script code with this template:
Pattern("some-image.png").similar(n.nn).targetOffset(x, y) or
Pattern("some-image.png").exact().targetOffset(x, y) (which is a shortcut for similar(0.99))
So if you use the IDE Preview feature in this case, you will not have
access in your Java code to the Pattern definitions, only the images and
would have to define the Patterns on the Java level again (at least
copy&paste could be used).
A helper in this situation would be some Java feature like this:
a class, that creates some image/pattern container, that analyses the script.py and allows to dynamically access the definitions:
ImageContainer myImages = new ImageContainer("path-to-some.sikuli")
and then use this:
Screen score = new Screen()
Match m = scr.find(myImages.get("somenameXYZ"))
where for the sake of simplicity ImageContainer.get() should simply
return a dynamically created Pattern object in any case.
the script path-to-some.sikuli content:
somename1 = "someImage.png"
somename2 = Pattern("some-image.png").similar(n.nn).targetOffset(x, y)
... and more
which would be easy to scan using pattern matching together with some
container map to store the attributes.
I guess the whole class will have about 20 - 30 lines of code and could
even be used to reuse the image and pattern definitions in existing
scripts, that are migrated to Java (in which case the ref-names might be
the line number of the line the image ore pattern is defined if no name
= is used.
I am just wondering, why not already someone has done and talked about
this ;-)
** Affects: sikuli
Importance: Medium
Assignee: RaiMan (raimund-hocke)
Status: In Progress
** Changed in: sikuli
Status: New => In Progress
** Changed in: sikuli
Importance: Undecided => Medium
** Changed in: sikuli
Assignee: (unassigned) => RaiMan (raimund-hocke)
** Changed in: sikuli
Milestone: None => 2.0.0
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1411151
Title:
[request] Java: want a helper feature, to dynamically access and use
the image and pattern definitions from a SikuliX script
Status in Sikuli:
In Progress
Bug description:
motivated by the related question
https://answers.launchpad.net/sikuli/+question/260722
this is taken from comment #2:
This is an approach, to efficiently combine Java coding with SikuliX
features and the SikuliX IDE support.
- have the complete image handling in the IDE, just setting up scripts only containing images
such a script will simply be a list of image file names.
The images are then available in the folder you-name-it.sikuli
- now you code in Java and access the images using setBundlePath() or more efficiently using the ImagePath features.
For these high level features some useable docs are available (start here: http://sikulix.com).
One caveat:
In the IDE you have the Preview feature, that lets you adjust the minimum similarity and the targetOffset resulting in a script code with this template:
Pattern("some-image.png").similar(n.nn).targetOffset(x, y) or
Pattern("some-image.png").exact().targetOffset(x, y) (which is a shortcut for similar(0.99))
So if you use the IDE Preview feature in this case, you will not have
access in your Java code to the Pattern definitions, only the images
and would have to define the Patterns on the Java level again (at
least copy&paste could be used).
A helper in this situation would be some Java feature like this:
a class, that creates some image/pattern container, that analyses the script.py and allows to dynamically access the definitions:
ImageContainer myImages = new ImageContainer("path-to-some.sikuli")
and then use this:
Screen score = new Screen()
Match m = scr.find(myImages.get("somenameXYZ"))
where for the sake of simplicity ImageContainer.get() should simply
return a dynamically created Pattern object in any case.
the script path-to-some.sikuli content:
somename1 = "someImage.png"
somename2 = Pattern("some-image.png").similar(n.nn).targetOffset(x, y)
... and more
which would be easy to scan using pattern matching together with some
container map to store the attributes.
I guess the whole class will have about 20 - 30 lines of code and
could even be used to reuse the image and pattern definitions in
existing scripts, that are migrated to Java (in which case the ref-
names might be the line number of the line the image ore pattern is
defined if no name = is used.
I am just wondering, why not already someone has done and talked about
this ;-)
To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1411151/+subscriptions
Follow ups
References