How to get the area on screen which has difference with my base image

Asked by Paul K on 2020-03-14

I'm trying to detect location that does not match my original image. Is there some ready built-in method or some simple function(s) to find the coordinates that don't match base image.
i had couple bit silly ideas like:
0. there is some opposite method of exists() on screen: does not exist that returns region
1. define multiple regions (kind of grid) and consecutively compare them with multiple original images (looks too hard)
2. modify region size Region(x,y,x1,y1) via x1,y1 in cycle with some reasonable step and compare with original img of same dimentions (not sure should it be but or not)
3. Split region on halfs verticaly and horizontaly and compare with halfs of original image

What will be the right way?

Thanks in advance,
Paul

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2020-03-20
Last query:
2020-03-20
Last reply:
2020-03-20
RaiMan (raimund-hocke) said : #1

If I understand right:
- there is a region on screen, that should match your image (you say: original)
- but actually the region only partially matches your image (some parts are different), and hence you get a FindFailed
- now you want to know the parts of the region, that differ from your image

If you have the region (same size as the image) where the image matched before, you can try with findChanges().

Sorry, but I have to come back later.

More information would be helpful.

Paul K (keep88) said : #2

Thx, RaiMan!
I used Region.onChange() to operate changes on my screen that partially solved my task. On other hand when i try the Finder() expamples 1 and 2 from: https://sikulix-2014.readthedocs.io/en/latest/finder.html i get errors in "message" window of IDE:

[error (20.03.2020, 13:13:54)] script [ test ] stopped with error in line 2
[error (20.03.2020, 13:13:54)] java.lang.IllegalArgumentException ( java.lang.IllegalArgumentException: Finder: not possible with: 1584702832233.png )
[error (20.03.2020, 13:13:54)] --- Traceback --- error source first
line: module ( function ) statement
2: main ( <module> ) f = Finder("1584702832233.png")
[error] --- Traceback --- end --------------

tried to use Finder(<Region>) insted of Finder(<Image>) and it works ok. So i suggest improper usage of finder from my side, but didn't find working solution in docs.

Could you please also provide/(add to documentation) some example of findChanges() usage?

Windows 10 x64, sikuli x 2.0.3(updated to 2.0.4 - same result) + jython, oracle jdk.

Thanks in advance and have a nice day!

Paul K (keep88) said : #4

Thanks Manfred Hampl, that solved my question.