0

I am using Sikulix.jar to search images in my project. My code is as follows:

Finder f;
Match m;
Points2D coords = new Point2D.Double(-1, -1);
try {
    f = new Finder(ImageIO.read(new File("my_large_image.png")));
    f.find(ImageIO.read("my_sub_image.png"));
    if (f.hasNext()) {
        m = f.next();
        coords.setLocation(m.getTarget().getX(), m.getTarget().getY());
    }
} catch (IOException e) {}

The image to be found is just a part of the large image. However the coords always returns (-1, -1). Any helps about the implementation? Thank you.

Update 11/25 I may found a solution but I do not know if it is correct. The image is found when I scale my testing large image down (from 1080*1920 to 540*960). But the similarity is 0.66.

Yi Chai
  • 145
  • 5
  • 14
  • This is quite an unusual way to use Sikuli methods. Is there a certain reason why you use it this way? – Eugene S Nov 23 '16 at 01:11
  • @EugeneS This is because I am trying to use Sikuli in my android automation system. Then the usual "Screen" way does not fit this situation... – Yi Chai Nov 23 '16 at 01:57
  • I see. Can you still work with Regions? – Eugene S Nov 23 '16 at 01:57
  • @EugeneS I can get it work by pass Pattern object with similarity value 0.5 into the find function. However the target result is far away from the correct position. – Yi Chai Nov 23 '16 at 14:24

1 Answers1

0

As just as a quick fix. You could hover the mouse on your matched part of image then grab the coordinates of the pointer.

  • Yeah I could do that manually, but I think Sikulix should do that for me ? – Yi Chai Nov 23 '16 at 00:52
  • I mean you can tell sikuli to hover(location) – Antiparticle Nov 24 '16 at 20:14
  • Aha, I have already tried that by using Screen click(). It works perfectly...I wonder why the finder does not work on my custom image? – Yi Chai Nov 25 '16 at 02:15
  • I'm not entirely sure either. Maybe you need to get "last match" then get the coordinates? I think your image doesn't stand out enough for sikuli to identify perhaps? I see earlier you said you're using .5 similarity? That's not enough to make it pick out a single target. – Antiparticle Dec 02 '16 at 04:00