Ejemplo n.º 1
0
def nesting_inspection(org, grey, compos, ffl_block):
    '''
    Inspect all big compos through block division by flood-fill
    :param ffl_block: gradient threshold for flood-fill
    :return: nesting compos
    '''
    nesting_compos = []
    for i, compo in enumerate(compos):
        if compo.height > 50:
            replace = False
            clip_org = compo.compo_clipping(org)
            clip_grey = compo.compo_clipping(grey)
            n_compos = blk.block_division(clip_grey,
                                          org,
                                          grad_thresh=ffl_block,
                                          show=False)
            Compo.cvt_compos_relative_pos(n_compos, compo.bbox.col_min,
                                          compo.bbox.row_min)

            for n_compo in n_compos:
                if n_compo.redundant:
                    compos[i] = n_compo
                    replace = True
                    break
            if not replace:
                nesting_compos += n_compos
    return nesting_compos
Ejemplo n.º 2
0
def nesting_inspection(org, grey, compos):
    nesting_compos = []
    for i, compo in enumerate(compos):
        if compo.height > 50:
            replace = False
            clip_org = compo.compo_clipping(org)
            clip_grey = compo.compo_clipping(grey)
            n_compos = blk.block_division(clip_grey, org, show=False)
            Compo.cvt_compos_relative_pos(n_compos, compo.bbox.col_min,
                                          compo.bbox.row_min)

            for n_compo in n_compos:
                if n_compo.redundant:
                    compos[i] = n_compo
                    replace = True
                    break

            if not replace:
                nesting_compos += n_compos
            # cv2.imshow('clip', clip_org)
            # cv2.waitKey()
    return nesting_compos