Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-23 Thread RaiMan
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

Assignee: None = RaiMan

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-23 Thread RaiMan
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

Status: Open = Answered

RaiMan proposed the following answer:
This is principally not possible with the current implementation: you
can only use one level of find operations  with a Finder() and you
cannot restrict the Finders find operation to a subregion of the given
image.

With this sequence of primary and secondary find operations on a real
screen, with every find, there will be made a new screenshot and
internally a new Finder(screenshot) for the respective area/subarea.

This does not happen in your Finder based solution with
current_match.find( field1 ) (which should be current_match.exists( field1 ), 
to make the if work ;-)

current_match is a region in the image, relative to its top left corner,
but with current_match.find( field1 ) it is used as coordinates relative
to the screen (the match currently does not know, that it was made
from a Finder(image).find() operation).

So if you want to solve this with a captured image, then you have to use
Finder().findAll() for all objects and compare their coordinates, to
find out, wether one match lies inside of another match (version 1.0.0
has the respective functions like region.contains(another_region) )

I think your approach is very interesting and Sikuli should have the 
possibility, to use a stored image the same way it uses a screen.
I put it on the request list: use image as a virtual screen

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-23 Thread RaiMan
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

Linked to bug: #1203989
https://bugs.launchpad.net/bugs/1203989
[request] use a saved image the same way as a screen (virtual screen)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-23 Thread Ryan Paterson
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

Ryan Paterson posted a new comment:
Thank you for your quick response!

I looked through the source code and noticed the following Finder constructor:
  public Finder(String imageFilename, Region region) throws IOException

I tried to use it with the following (modified) algorithm with no luck:

full_block = Pattern( image1.png ).similar(0.70) # image of block to find
field1 = Pattern(subimage1.png).similar(0.95) # a sub-image of image1.png, 
can uniquely identify the block
field2 = Pattern(subimage2.png) # sub-image of image1.png, a field to ignore, 
we won't do anything with it
field3 = Pattern(subimage3.png).similar(0.95) # sub-image of image1.png, 
important field (can exist in multiple blocks, but we're checking to see if it 
exists in this block)

f = Finder( path\previouslyCapturedImage.png )
f.findAll(full_block) # search previouslyCapturedImage.png, will return 
multiple matches
matches = []
while f.hasNext():
  matches.append(f.next())
f.destroy()

for current_match in matches: # Matches should now contain multiple Match 
objects which inherit from Region
  f2 = Finder(path\previouslyCapturedImage.png, current_match) # Would 
hopefully act as only the area defined by current_match
  if f2.find(field1): # Pseudo code if statement, field1 is high-similarity 
and unique so it should only exist in one of the matches
 if f2.find(field3): 
 print Correct Information Found
 else:
 print Incorrect Information Found
 break
  else:
 # no match on unique identifier field 1, this means current_match 
is a different block, so skip to the next one
 continue
 f2.destroy()

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-23 Thread RaiMan
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

RaiMan proposed the following answer:
Yes, there is such a constructor,but this is not used as you think and
does not work like you thought it would work (it is only used, to
recalculate the matches back to screen coordinates, that are used with a
restricted find on a screen's smaller region).

As I said, on a given image it is currently not possible to restrict the
search to a region within the given image.

The easiest way, to solve your problem would be, to display the image
with a viewer on the screen and act on it normally.

The other more complex method would be to make findAll for all patterns
with your Finder(image) and compare the match coordinates.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image --- currently not possible

2013-07-23 Thread RaiMan
Question #232881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232881

Summary changed to:
Finder - how to match multiple sub-images within a captured image --- currently 
not possible

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


[Sikuli-driver] [Question #232881]: Finder - how to match multiple sub-images within a captured image

2013-07-22 Thread Ryan Paterson
New question #232881 on Sikuli:
https://answers.launchpad.net/sikuli/+question/232881

Attempting to scan a previously saved screen capture.  The screen capture 
contains multiple (similar) blocks of data.  Each block contains three fields. 
Field 1 is a unique identifier, Field 2 will vary and must be ignored, Field 3 
contains the content that will pass/fail this test step, but that content can 
also appear in other blocks of data.  

Desired Algorithm Pseudo Code:
full_block = Pattern( image1.png ).similar(0.70) # image of block to find
field1 = Pattern(subimage1.png).similar(0.95) # a sub-image of image1.png, 
can uniquely identify the block
field2 = Pattern(subimage2.png) # sub-image of image1.png, a field to ignore, 
we won't do anything with it
field3 = Pattern(subimage3.png).similar(0.95) # sub-image of image1.png, 
important field (can exist in multiple blocks, but we're checking to see if it 
exists in this block)

f = Finder( path\previouslyCapturedImage.png )
f.findAll(full_block) # search previouslyCapturedImage.png, will return 
multiple matches 
while f.hasNext():
  current_match = f.next() 
  if current_match.find( field1 ):
# We've uniquely the block, check unique identifier field1
if current_match.find(field3):
   print Correct information found!
else:
   print Incorrect information found!
# We can exit now because we found unique identifier field1
break
  else:
# no match on unique identifier field 1, this means current_match 
is a different block, so skip to the next one
continue

This style of code works when using the Screen as the target of the find 
commands, but doesn't appear to work when using a previously saved image of the 
screen as the target. Any ideas on how to accomplish something similar? If my 
example isn't clear enough please let me know.
  


-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp