Beispiel #1
0
    def __init__(self, E, EC, TC, TH):
        self.E = E
        self.EC = EC
        self.TC = TC
        self.TH = TH
        # self.count = None
        # self.child_ctn_idxs = None

        self.LCI = 0
        # LCI = Largest Contour Index

        if len(EC) > 1:
            self.LCI = API.laegestContours(EC)

        # PCI = Parent's Contours Index in Tree Contours'
        self.PCI = 0

        for i, c in enumerate(self.TC):
            if np.array_equal(self.EC[self.LCI], c):
                self.PCI = i

        self.count, self.child_ctn_idxs = API.countInnerCtn(self.TC, self.TH, self.PCI)

        # RE SCHEDULE CHILD INDEXES AFTER COUNT CHILD INDEXES
        child_indexes, re_schedule_supper_child_index = API.reSchedulechild(self.child_ctn_idxs, self.TC)

        self.count = len(child_indexes)
        self.child_ctn_idxs = child_indexes
        self.re_schedule_supper_child_index = re_schedule_supper_child_index
Beispiel #2
0
 def labelSpecial(self, left_cnt_index):
     grand_child_count, grand_child_index = API.countInnerCtn(self.TC, self.TH, self.child_ctn_idxs[left_cnt_index])
     if grand_child_count == 0:
         self.E.addLBL(74)
         return self.E
     else:
         return self.E
Beispiel #3
0
    def dropdownSpecial(self, right_cnt_index):

        grand_child_count, grand_child_index = API.countInnerCtn(self.TC, self.TH, self.child_ctn_idxs[right_cnt_index])
        if len(grand_child_index) == 1:
            GCS, GCA = API.shape(self.TC[grand_child_index[0]])
            if GCS == "triangle":
                self.E.addDD(75)
            else:
                return self.E
Beispiel #4
0
    def imageSpecial(self):
        for cntIdx in self.child_ctn_idxs:
            super_child_count, super_child_idxs = API.countInnerCtn(self.TC, self.TH, cntIdx)
            if super_child_count == 1:

                child_shape, points = API.shape(self.TC[super_child_idxs[0]])
                if child_shape == "other":
                    self.E.addIMG(70)
                else:
                    continue
            else:
                continue
        return self.E
Beispiel #5
0
    def supperInnerCnt1Shape(self):
        for cntIdx in self.child_ctn_idxs:
            super_inner_count, super_inner_ctn_idxs = API.countInnerCtn(self.TC, self.TH, cntIdx)

            if super_inner_count == 1:
                child_shape, points = API.shape(self.TC[super_inner_ctn_idxs[0]])
                if child_shape == "rectangle" or child_shape == "square":
                    self.E.addBTN(80)
                    return self.E
                else:
                    self.E.addRB(80)
                    return self.E
            elif super_inner_count == 0:
                self.E.addTXT(80)
                return self.E
            else:
                return self.E