Example #1
0
    def validateWordWithAllViews(self, tv, ocrTextWrapper):
        ocrBound = ocrTextWrapper.bound()
        for view in self.mViews:
            # woa this word is big and have a lot of children, not good
            # this may okay with url or special texts
            if (RectUtil.contains(ocrBound, view.bound())
                    and len(view.getChildren()) > 0):
                tv.scalar = ColorUtil.getScalar(CColor.Cyan)
                tv.valid = False
                tv.log = "This word is big and have a lot of children"
                return

            # the box may has the word is too small compare with the word
            # itself.
            # If the word a children view which only have on child, we need
            # to verify if:
            # (1) This child view did not intersect with any other views
            # (2) This child view really small compare to the word bound
            if RectUtil.contains(ocrBound, view.bound()) and len(
                    view.getChildren()) == 0:
                # make sure this view did not intersect with other view,
                # include is accepted in this case
                hasIntersection = False
                for otherView in self.mViews:
                    if otherView != view and RectUtil.intersectsNotInclude(
                            ocrBound, otherView.bound()):
                        hasIntersection = True
                        break

                if (not hasIntersection):
                    if (RectUtil.dimesionSmallerThan(view, ocrTextWrapper,
                                                     0.8)):
                        # this is wrong, ignore this word
                        tv.scalar = CColor.Black
                        tv.valid = False
                        tv.log = "The box may has the word is too small compare with the word itself"
                        return

            # same here: the box may has the word is too big compare to the
            # word itself we also make sure that this view may also have
            # other view but it so tiny will be ignore when layout
            # itself and there is only one word in here
            if (self.areChildrenIsTooSmall(self.mDipCalculator, view)
                    and RectUtil.contains(view.bound(), ocrBound)):
                if (RectUtil.dimesionSmallerThan(ocrTextWrapper, view, 0.8)):
                    # this is wrong, ignore this word
                    tv.scalar = CColor.Pink
                    tv.valid = False
                    tv.log = "The box may has the word is too big compare to the word, and there is only one word in here. This view may also have other view but it so tiny"
                    return
Example #2
0
    def accept(self, ocr):
        # Count to see how may child view this word have, if it only have
        # one child view. Test:
        # (1) This word is not messy. Mean that it did not
        # "intersect not include" with other views (except the child view)
        # (2) If the child view is too small compare with it
        foundChildRects = RectUtil.findChildRect(ocr.rect, self.mViews)
        if len(foundChildRects) == 1:
            rectView = foundChildRects[0]
            newList = []
            if rectView in newList:
                newList.remove(rectView)
            findIntersectNotIncludeRect = RectUtil.findIntersectNotIncludeRect(
                ocr, newList)
            if len(findIntersectNotIncludeRect) == 1:
                iRect = findIntersectNotIncludeRect[0]
                if RectUtil.dimesionEqual(
                        ocr, iRect, 0.2) and RectUtil.dimesionSmallerThan(
                            rectView, ocr, 0.8):
                    # this is wrong, ignore this word
                    # DarkSalmon
                    # http:#www.w3schools.com/tags/ref_color_tryit.asp?color=DarkSalmon
                    tv = TextValidator.TextValidator(
                        ocr, (233, 150, 122), False,
                        "This word only have one child view, and the child view is too small compare with it"
                    )
                    return tv

        return None
    def accept(self, ocr):
        #        return None
        bound = ocr.bound()
        for view in self.mViews:
            # the box may has the word is too small compare with the word
            # itself.
            # If the word a children view which only have on child, we need
            # to verify if:
            # (1) This child view did not intersect with any other views
            if RectUtil.contains(bound, view.bound()) and len(
                    view.mChildren) == 0:
                # make sure this view did not intersect with other view,
                # include is accepted in this case
                hasIntersection = False
                for otherView in self.mViews:
                    if otherView != view and RectUtil.intersectsNotInclude(
                            bound, otherView.bound()):
                        hasIntersection = True
                        break

                if not hasIntersection:
                    if RectUtil.dimesionSmallerThan(
                            view, ocr, 0.8):  # this is wrong, ignore this word
                        tv = TextValidator(
                            ocr, CColor.Black, False,
                            "The box may has the word is too small compare with the word itself"
                        )
                        return tv
        return None
    def accept(self, ocr):
        bound = ocr.bound()
        for view in self.mViews:
            #            // the box may has the word is too small compare with the word
            #            // itself.
            #            // If the word a children view which only have on child, we need
            #            // to verify if:
            #            // (2) This child view really small compare to the word bound
            #            // same here: the box may has the word is too big compare to the
            #            // word itself we also make sure that this view may also have
            #            // other view but it so tiny will be ignore when layout
            #            // itself and there is only one word in here
            if TextProcessorUtil.areChildrenIsTooSmall(
                    self.mDipCalculator, view) and RectUtil.contains(
                        view.bound(), bound):
                if RectUtil.dimesionSmallerThan(ocr, view, 0.8):
                    # this is wrong, ignore this word
                    tv = TextValidator(
                        ocr, CColor.Pink, False,
                        "The box may has the word is too big compare to the word, and there is only one word in here. This view may also have other view but it so tiny"
                    )
                    return tv

        return None