Beispiel #1
0
            def matchingChars(possibleC, possibleChars):
                listOfMatchingChars = []

                # if the char we attempting to find matches for is the exact same char as the char in the big list we are currently checking
                # then we should not include it in the list of matches b/c that would end up double including the current char
                # so do not add to list of matches and jump back to top of for loop
                for possibleMatchingChar in possibleChars:
                    if possibleMatchingChar == possibleC:
                        continue

                    # compute stuff to see if chars are a match
                    distanceBetweenChars = Functions.distanceBetweenChars(possibleC, possibleMatchingChar)

                    angleBetweenChars = Functions.angleBetweenChars(possibleC, possibleMatchingChar)

                    changeInArea = float(abs(possibleMatchingChar.boundingRectArea - possibleC.boundingRectArea)) / float(
                        possibleC.boundingRectArea)

                    changeInWidth = float(abs(possibleMatchingChar.boundingRectWidth - possibleC.boundingRectWidth)) / float(
                        possibleC.boundingRectWidth)

                    changeInHeight = float(abs(possibleMatchingChar.boundingRectHeight - possibleC.boundingRectHeight)) / float(
                        possibleC.boundingRectHeight)

                    # check if chars match
                    if distanceBetweenChars < (possibleC.diagonalSize * 5) and \
                            angleBetweenChars < 12.0 and \
                            changeInArea < 0.5 and \
                            changeInWidth < 0.8 and \
                            changeInHeight < 0.2:
                        listOfMatchingChars.append(possibleMatchingChar)

                return listOfMatchingChars
Beispiel #2
0
        def matchingChars(possibleC, possibleChars):
            listOfMatchingChars = []

            # se o caractere para o qual estamos tentando encontrar correspondências for exatamente o mesmo caractere que o caractere na grande lista que estamos verificando
            # então não devemos incluí-lo na lista de correspondências b / c que acabariam em dobro, incluindo o caractere atual
            # então não adicione à lista de correspondências e volte ao topo do loop for

            for possibleMatchingChar in possibleChars:
                if possibleMatchingChar == possibleC:
                    continue

                # calcular coisas para ver se os caracteres são uma correspondência
                distanceBetweenChars = Functions.distanceBetweenChars(
                    possibleC, possibleMatchingChar)

                angleBetweenChars = Functions.angleBetweenChars(
                    possibleC, possibleMatchingChar)

                changeInArea = float(
                    abs(possibleMatchingChar.boundingRectArea -
                        possibleC.boundingRectArea)) / float(
                            possibleC.boundingRectArea)

                changeInWidth = float(
                    abs(possibleMatchingChar.boundingRectWidth -
                        possibleC.boundingRectWidth)) / float(
                            possibleC.boundingRectWidth)

                changeInHeight = float(
                    abs(possibleMatchingChar.boundingRectHeight -
                        possibleC.boundingRectHeight)) / float(
                            possibleC.boundingRectHeight)

                # verifique se os caracteres correspondem
                if distanceBetweenChars < (possibleC.diagonalSize * 5) and \
                        angleBetweenChars < 12.0 and \
                        changeInArea < 0.5 and \
                        changeInWidth < 0.8 and \
                        changeInHeight < 0.2:
                    listOfMatchingChars.append(possibleMatchingChar)

            return listOfMatchingChars
    def matchingChars(possibleC, possibleChars):
        listOfMatchingChars = []

        for possibleMatchingChar in possibleChars:
            if possibleMatchingChar == possibleC:
                continue

            # compute stuff to see if chars are a match
            distanceBetweenChars = Functions.distanceBetweenChars(
                possibleC, possibleMatchingChar)

            angleBetweenChars = Functions.angleBetweenChars(
                possibleC, possibleMatchingChar)

            changeInArea = float(
                abs(possibleMatchingChar.boundingRectArea -
                    possibleC.boundingRectArea)) / float(
                        possibleC.boundingRectArea)

            changeInWidth = float(
                abs(possibleMatchingChar.boundingRectWidth -
                    possibleC.boundingRectWidth)) / float(
                        possibleC.boundingRectWidth)

            changeInHeight = float(
                abs(possibleMatchingChar.boundingRectHeight -
                    possibleC.boundingRectHeight)) / float(
                        possibleC.boundingRectHeight)

            # check if chars match
            if distanceBetweenChars < (possibleC.diagonalSize * 5) and \
                    angleBetweenChars < 12.0 and \
                    changeInArea < 0.5 and \
                    changeInWidth < 0.8 and \
                    changeInHeight < 0.2:
                listOfMatchingChars.append(possibleMatchingChar)

        return listOfMatchingChars