sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #19404
Re: [Question #232881]: Finder - how to match multiple sub-images within a captured image
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.