[request] Java: want a helper feature, to dynamically access and use the image and pattern definitions from a SikuliX script

Bug #1411151 reported by RaiMan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
In Progress
Medium
RaiMan

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

RaiMan (raimund-hocke)
Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 2.0.0
Revision history for this message
NoBugs! (luke32j) wrote :

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

Wouldn't it be better to just have a Jython-IDE-instance runner that could run specific .sikuli project as needed? A script to rewrite python into Java code sounds hacky. How would it handle imports? for-in loops? ifs and try-catch?

Revision history for this message
RaiMan (raimund-hocke) wrote :

--- that could run specific .sikuli project as needed?
that is not the point here.
For this we have the ScriptRunner feature already.

the here mentioned "container" class is only about prepared images and image related specs (Pattern)

RaiMan (raimund-hocke)
Changed in sikuli:
milestone: 2.0.0 → 2.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

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