Пример #1
0
def pair_visualization(pairs, img, img_shape, show_method='line'):
    board = img.copy()
    if show_method == 'line':
        for id in pairs:
            pair = pairs[id]
            for p in pair:
                board = draw.visualize(board, p.compos_dataframe, img_shape, attr='pair', show=False)
    elif show_method == 'block':
        for id in pairs:
            pair = pairs[id]
            for p in pair:
                board = draw.visualize_block(board, p.compos_dataframe, img_shape, attr='pair', show=False)
    cv2.imshow('pairs', board)
    cv2.waitKey()
    cv2.destroyAllWindows()
Пример #2
0
 def visualize_block(self, img, img_shape, attr='class', name='board'):
     draw.visualize_block(img, self.compos, img_shape, attr, name)
Пример #3
0
import draw

name = 'data/9'
compos = DF_Compos(name + '.json', name + '.png')
img = compos.img.copy()
img_shape = compos.img_shape

# recognize repetition
compos_nontext = recog_repetition_nontext(compos, show=False)
compos_text = recog_repetition_text(compos, show=False)

# select all repetitive compos and group them by repetition
groups_nontext, no_groups_nontext = compos_nontext.cvt_groups('group_nontext', 'nontext')
groups_text, no_groups_text = compos_text.cvt_groups('group_text', 'text')
all_groups = groups_nontext + groups_text

# pair differnet repetition to search for possible combination
pairs, no_pairs = pair_matching_within_groups(all_groups)
df_pairs = pair_cvt_df(pairs)

# collect all results in a Dataframe
df_no_groups = no_groups_nontext.append(no_groups_text, sort=False)
df_no_pairs = groups_cvt_df(no_pairs)
df_all = df_no_groups.append(df_no_pairs, sort=False).append(df_pairs, sort=False)

# post processing
df_all = df_all.sort_index()
df_all[list(df_all.filter(like='group'))] = df_all[list(df_all.filter(like='group'))].fillna(-1).astype(int)
df_all['pair'] = df_all['pair'].fillna(-1).astype(int)
draw.visualize_block(img, df_all, img_shape, attr='pair')
Пример #4
0
 def visualize_block(self, gather_attr='class', name='board'):
     draw.visualize_block(self.img, self.compos_dataframe, self.img_shape,
                          gather_attr, name)