Question #255601 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/255601

rrTenz proposed the following answer:
I was trying to implement this exact thing and created a work around
that is working for me.  You just need to create an image for numbers 0
through 9 and store them in the 'numImages' array. Make sure to click on
each image, go to the Matching Preview, and adjust the Similarity value.
Then you just need to call the function and pass in a region created by
"Create Region".  I just through the code together today, and I'm sure
it could be improved, but here is what I did:

val=[999,999,999,999,999,999,999,999,999,999]
xLoc=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]

#           0    1    2    3    4    5    6   7    8    9
numImages=[(Image_0),(Image_1),(Image_2),(Image_3),(Image_4),(Image_5),(Image_6),(Image_7),(Image_8),(Image_9)]
def numberReader(myRegion):
    i = 0
    #find all digits in the specified region
    for x in range(0, 10):
        try:
            numFound = myRegion.findAll(numImages[x])
            for num in numFound:
                #a digit was found
                xLoc[i] = num.x
                val[i] = x
                i += 1
        except FindFailed:
            doNothing = 0
            #print 'Did not find ' + `x`
    
    valConcat = 0
    #concatenate digits, starting with least significant and moving towards the 
left    
    for x in range(0, i):
        highestLoc = 0
        highestIdx = 0
        for y in range(0, i):
            if(xLoc[y] > highestLoc):
                highestLoc = xLoc[y]
                highestIdx = y
        pow = 1
        for p in range(0, x):
            pow *= 10
        newVal = val[highestIdx] * pow
        valConcat += (newVal)
        xLoc[highestIdx] = 0
    return valConcat

-- 
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     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to