get count of similar images

Asked by Maniraj

Hi,

I am finding image inside region, in that region more that 1 similar images are there, there is any way to get count of all similar images inside that region.

Note: i am taking screenshot and inside that screenshot comparing the image, not comparing images on screen.

Help me out.

thank you.

Question information

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

what you say is not consistent:
--- finding image inside region, in that region more that 1 similar images are there
--- i am taking screenshot and inside that screenshot comparing the image

... would be easier to understand if you post some snippet of code.

In any case use
findAll()

Revision history for this message
Maniraj (aathimaniraj) said :
#2

Hai,

public static boolean findInWholePage(WebDriver driver,String imageName,ExtentTest etest) throws IOException, FindFailed, InterruptedException
  {
    String expectedimg = "imagepath" // path of image.
    URL file_url = new URL(expectedimg);
    String uniqueID = UUID.randomUUID().toString();
    String actualimage = uniqueID+imageName;
    BufferedImage regionsetimage = screenCapture(driver,actualimage); // using selenium I am taking whole page screenshot and storing as buffered image.
    Finder window = new Finder(regionsetimage);
    Pattern testImage = new Pattern(file_url);
    window.find(testImage.similar((float) 0.99)); //.exact()
    Match found = null;
    if (window.hasNext())
    {
      found = window.next();
      //System.out.println(imageName + " Image found");
      etest.log(LogStatus.PASS,"Expected: "+ expected + "Actual" + actual);
      return true;
    }
    else
    {
      System.out.println(imageName + " Image Not found");
      etest.log(LogStatus.FAIL,"Expected: "+ expected + "Actual" + actual);
      return false;
    }
  }

In this inside my region (that means whole page Screenshot taken in runtime), I have more than 1 similar images. In this scenario can I get count of all that similar images ?

... would be easier to understand if you post some snippet of code.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

supposing it is SikuliX 1.1.1 or even 1.1.2, then this should do what you want:

window.findAll(testImage.similar((float) 0.99)); //.exact()
while (window.hasNext()) {
    nextMatch = window.next();
....

the matches are delivered with decreasing score.

Revision history for this message
Maniraj (aathimaniraj) said :
#4

Thanks raiman. i will check.