sikulix: Want co-ordinates of text in a image given

Asked by Bhuvaneshwaran I on 2019-12-09

I'm using sikulix for identifying image and give it's coordinates to selenium in order to click it. i want the same to be done for text. Text recognition is possible for a screen but i could not do it for an image. I' creating finder object and feeding with image where text/image should be found. if i use findall method of finder it throws error as there will be no screen for the finder object.

is there anyway to acheive this?

Question information

Language:
English Edit question
Status:
Expired
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-12-10
Last reply:
2019-12-26
Bhuvaneshwaran I (buvnswrn) said : #1

 public static Point getPositionOfImage(String screenPath,String filePath) {
  Point position=new Point();
  Finder finder=new Finder(screenPath);
  finder.findAll(filePath);
  if(finder.hasNext()) {
   Match match=finder.next();
   position.x=match.getX();
   position.y=match.getY();
   return position;
  }
  return null;
 }

 public static Point getPositionOfText(String screenPath, String text) throws FindFailed {
  Point position =new Point();
  Finder finder=new Finder(screenPath);
  Region r=finder.getRegion();
  r.existsText(text);
// Screen s=new Screen();
// IScreen sc=new IScreen("");
  Settings.SwitchToText=true;
// Match r=s.findText(text);
  finder.findText(text);
  if(finder.hasNext()) {
   Match match=finder.next();
   position.x=match.getX();
   position.y=match.getY();
   return position;
  }
  return null;
 }

RaiMan (raimund-hocke) said : #2

The text/OCR features currently do not work or are not available with a Finder object.

You have to make the image visible on the screen and use the normal Region methods.

Bhuvaneshwaran I (buvnswrn) said : #3

I'm able to identify the match in Screen. But,I'm not using Screen because it cause issues when using with selenium (cannot run many tests in parallel). So i'm taking a screenshot of the web driver and identify image to be identified in the screenshot and providing co ordinates to selenium in order to enable it to click. I want the same to be done for text. i'm using finder object to take screenshot as input and find the given image in that. Is there anyway to achieve the same using Region method / any other methods.

Also,I can see that in finder object if can provide my image to the below line it will resolve my issue,

Finder Class-Line 661: BufferedImage bimg = where.getScreen().capture(where).getImage();

Launchpad Janitor (janitor) said : #4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.