[request] want Pattern.anySize() and Pattern.anyColor() --- feature added 2018-06-25 build #28

Bug #878864 reported by Arthur Dias
40
This bug affects 9 people
Affects Status Importance Assigned to Milestone
SikuliX
Fix Committed
Critical
RaiMan

Bug Description

*************** implementation
as resize before search operation:
- Settings.AlwaysResize for general proportional resize
- Pattern.resize resize only for the given image

additionally:
- Settings.ImageCallback do what is needed with an image before a search op in a callback function

see docs: http://sikulix-2014.readthedocs.io/en/latest/scripting.html#Settings.AlwaysResize

----------------------------------------------------------------

as a general solution, Sikuli needs to know, how the image should be rescaled.

the same image is found in different screen resolutions by Sikuli though.

---------------------------------------------------------------------------
based on the original description of the planned Sikuli features:

anySize() was supossed to solve different resolutions problems.

But it is not yet available in Sikuli script.

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

Pattern().anySize()

is not implemented (neither in the Python nor in the Java API)

So you might post a request bug or rework this one as a request.

Currently you have to setup your own solution, to solve these kinds of problems.

summary: - AnySize() on sikuli IDE problem
+ Pattern.anySize() ???
RaiMan (raimund-hocke)
description: updated
Changed in sikuli:
importance: Undecided → Wishlist
summary: - Pattern.anySize() ???
+ [request] want Pattern.anySize() and Pattern.anyColor()
Revision history for this message
Macs (cymacs) wrote : Re: [request] want Pattern.anySize() and Pattern.anyColor()

Hi Tsung-Hsiang,

Do you have any suggestion on the implementation of Pattern().anySize()?

If my understanding is correct, the current implementation uses the opencv template matching API and the limitation of this is that the size of the pattern image should be equal or less than the size of the pattern on the screen.

What is your implementation idea for Pattern().anySize()? Do you plan to use the OpenSurf algorithm?

I can take a look at the implementation it if it is simple.

Regards,
Macs

Revision history for this message
Nicole Demers (nicole-a-demers) wrote :

I know this is a bit late, but here it goes:

There is an algorithm for image stretching that generates a larger image pattern from a smaller one that could then be used to match from for anySize(). The pixels in the smaller image are sent to their relative positions in the larger version of the image.

Imagine each [value] is a pixel:

Image pixels are pulled from (Source):
[red] [red]
[red] [blu]

Larger image pixels are drawn into:
[red] [red] [red]
[red] [red] [red]
[red] [red] [blu]
[red] [red] [blu]

or

[red] [red] [red] [red]
[red] [red] [red] [red]
[red] [red] [blu] [blu]
[red] [red] [blu] [blu]

The most important thing is to consistently round up or down every time when calculating the pixel to get your colour from.

Algorithm Steps:
1. Generate a new image, the destination, in the size you require
2. Iterate over destination's pixels, calculating the source pixel to get your colour value from
3. Set the colour value in destination based on the source calculation

This would generate an image that can be used to match whatever size you need.

If you don't know the size it might be possible to use template matching to find similar patterns to your search image on the screen then generate images in the correct size based on the template matches and try to find using a differently sized version of the pattern to match. The processing time might be a bit slow. (Very, very slow)

RaiMan (raimund-hocke)
Changed in sikuli:
importance: Wishlist → Undecided
status: New → Won't Fix
RaiMan (raimund-hocke)
description: updated
Changed in sikuli:
status: Won't Fix → In Progress
importance: Undecided → Wishlist
assignee: nobody → RaiMan (raimund-hocke)
tags: added: fkt-pattern
Revision history for this message
Vijayakumar (vijayakumar-mtech) wrote :

Hi,

Please let me know when this feature is available?

Regards,
Vijay

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

not in the roadmap currently.

Earliest in 2015 with 1.2+

Revision history for this message
Chathura (chathuragune) wrote :

I am constantly experiencing where I cannot roll out my script over many users who have different display sizes especially different laptop home screen sizes. How do we make the match screen resolution agnostic? This will considerably improve the usefulness of this program for everyone. I am constantly experiencing where when I go to project with significantly less resolution that my home screen, this scripts are failing.

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

The only thing I can do in the moment, to accept this as a request for version 2 (no target date currently).

@Chathura
Do you have an example for me including screenshots and the detailed environment description?

Changed in sikuli:
milestone: none → 2.0.0
importance: Wishlist → Medium
Revision history for this message
m.shams (mshams) wrote :

Actually I think these features are really important because, It's really hard to develop a complicated automation script that just works on the first developer PC.
The only solution that I've found is to use an image scaling routine as pre-processing by considering the first resolution and the current resolution.
It's just an idea but theoretically it should works. Have you any other idea?

RaiMan (raimund-hocke)
Changed in sikuli:
importance: Medium → High
milestone: 2.0.0 → 1.1.3
Revision history for this message
RaiMan (raimund-hocke) wrote :

@m.shams
Just decided, to take this feature back to version 1.1.3, since implementing a basic support is not so complex, as long as it is only about rescaling.

It can be implemented completely in the Pattern class with a callback pattern.

-- one rescale factor for all images
Pattern.setScale(factor) - you have to decide for a factor somehow in advance. After that all images are rescaled with the standard image resize internally before use.

-- action per image
Pattern.setScale(callback_function) - somewhere you have defined the callback_function, which is called with the actual Pattern object. You evaluate the situation and do one of the following:
- stop being called back (not needed)
- set a rescale factor to be used from now on (optionally stop being called back)
- do something with the image and tell the Pattern to reset the image to your new version (this would allow to do more than just rescaling: change color, recapture on the fly, ...)

Thanks for the reminder

Revision history for this message
AndyLv (maolinlv0604) wrote :

@Raiman, thanks a lot, I believe many people need this feature eagerly, Is it possible that you can give us a nightly build when you fix this bug?

RaiMan (raimund-hocke)
Changed in sikuli:
status: In Progress → Fix Committed
importance: High → Critical
summary: - [request] want Pattern.anySize() and Pattern.anyColor()
+ [request] want Pattern.anySize() and Pattern.anyColor() --- feature
+ added 2018-06-25 build #28
RaiMan (raimund-hocke)
description: updated
Revision history for this message
AndyLv (maolinlv0604) wrote :

@RaiMan, hello, I tried 【Latest available Build: 1.1.3-SNAPSHOT 2018-06-26_16:01 Travis Build 29 ,sikulixsetup-1.1.3-20180626.160145-28-forsetup.jar】,after setup, I gave it a try this morning. but it seemed to me that it still failed, error info is 【 if exists(Pattern("1530065699523.png").similar(0.9).anySize(),3600): AttributeError: 'Pattern' object has no attribute 'anySize' 】. could you give me some advice?

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

see the implementation information in the bug description above.

Revision history for this message
abuzer stream (abuzerstream) wrote :

Hi
Has this feature been added?
In 2.0.5, I get the error "Pattern object has no attribute anyColor".

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.