Switching Regoins

Asked by Jeremy

This is a bit complicated.

In my program, I'm trying to look at three cards.
One card have a C another has a UC and another has a R.

I did a find all, to get all of the cards.

I did this to get all of the sizes of the cards:
         Rectangle left_side_size = new Rectangle(left_most_button.getX(),left_most_button.getY()
           ,left_most_button.getW(),left_most_button.getH()*2);
         Rectangle right_side_size = new Rectangle(right_most_button.getX(),right_most_button.getY()
           ,right_most_button.getW(),right_most_button.getH()*2);
         Rectangle middle_size = new Rectangle(middle_Button.getX(),
           middle_Button.getY()
           ,middle_Button.getW(),middle_Button.getH()*2);
   System.out.println("setting sizes");

I did this to verify the sizes are good:
         TakeScreenShot m_screenie = new TakeScreenShot(left_side_size);
         m_screenie.shot("left");
         TakeScreenShot m_screenie2 = new TakeScreenShot(right_side_size);
         m_screenie2.shot("right");
         TakeScreenShot m_screenie3 = new TakeScreenShot(middle_size);
         m_screenie3.shot("middle");

My screenshots are correct.
I do this to set the new region.
             if (current_card_count == 0)
              s.setROI(left_side_size);
             if (current_card_count == 1)
              s.setROI(right_side_size);
             if (current_card_count == 2)
              s.setROI(middle_size);

I tried set rect as well, but that didn't seem to work.

My goal is to start off with the most powerful card first, so I need to scan each card. Next, I need to compare each one to see which is the most powerful. I think I have the code right, but nothing is happening.

Let me know if you have any questions or comments.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

with Sikuli(X) you should always work with Regions:

Region left_side = left_most_button.below(left_most_button.h).union(left_most_button);
// .. and the others similar

// to make the regions visible
left_side.highlight(2)
// ... and the others

to use setROI is not recommended, since it restricts the screen search area as long as you reset it, which might lead to strange situations.

... and setROI does nothing else.

you can now use the set regions, to do something with them:
Match m = left_side.find(some_image);
m.click();

....

Can you help with this problem?

Provide an answer of your own, or ask Jeremy for more information if necessary.

To post a message you must log in.