muti region and color match

Asked by Ze-ping on 2017-02-23

Hello ,
I have a RegionA which include three regions [region1][region2][region3]

And [region1][region2][region3] ,each will change color (red,green,blue,black ).

If a I have to listen color change in [region1][region2][region3] ,how can i do it simply in Java?

class scanner {
    Region RegionA = new Region(0,0,1000,1000)
    Region Region1 = new Region(100,100,50,50)
    Region Region2 = new Region(100,200,50,50)
    Region Region3 = new Region(100,300,50,50)
    public string colorinRegion1 {
Match matchred = Region1 .exists(red.png path);
Match matchgreen= Region1 .exists(green.png path);
Match matchblue = Region1 .exists(blue.png path);
Match matchblack = Region1 .exists(black.png path);

    String color="";
 if (null != matchred){
  color="red";
 }
 else if (null != matchgreen){
  color="green";
 }.......and so on

So my question is , are there another clear way to do region setting and color matching?

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-02-23
Last reply:
2017-02-23
RaiMan (raimund-hocke) said : #1

If you want to set it up as a listener, best choice would be to use the observeInBackground.

define suitable color images:
Pattern black = new Pattern(black.png).exact() // wanted match > 0.99
... other colors

Region1.onAppear(black, new ObserverCallBack() { //... see docs

Region1.observeInBackground( //.. see docs

in the callback code you can do what you want.
If everything is time critical, you have to eventually implement additional threading.

I recommend version 1.1.1 and in doubt the javadocs.

Can you help with this problem?

Provide an answer of your own, or ask Ze-ping for more information if necessary.

To post a message you must log in.