def _main(): # start image and end image start_index = 1 end_index = 20 for input_path in input_paths: index = input_path.split('\\')[-1][:-4] if int(index) < start_index: continue if int(index) > end_index: break start = time.clock() print(input_path) print(time.ctime()) try: org, binary = body.pre_processing(input_path) corners_block, corners_img, corners_compo, compos_class, corners_text = body.processing(org, binary) save(index, org, binary, corners_block, corners_img, corners_compo, compos_class, corners_text) except: print('Bad Input', index + '\n') continue file.timer(start) print('Save ' + index + '\n')
def _main(): org, binary = body.pre_processing('input/dribbble/5.png') corners_block, corners_img, corners_compo, compos_class, corners_text = body.processing( org, binary, CNN) save(org, binary, corners_block, corners_img, corners_compo, compos_class, corners_text) file.timer(start)
line=-1) if is_ocr: draw_bounding, word = ocr.text_detection(org, img_clean) else: draw_bounding = org img_clean = draw.draw_bounding_box(img_clean, corners_compo, color=(255, 255, 255), line=-1) # *** Step 6 *** post-processing: remove img elements from original image and segment into smaller size if is_segment: seg.segment_img(img_clean, 600, 'output/segment') # draw results draw_bounding = draw.draw_bounding_box_class( draw_bounding, corners_block, ['block' for i in range(len(corners_block))]) draw_bounding = draw.draw_bounding_box_class( draw_bounding, corners_img, ['img' for j in range(len(corners_img))]) draw_bounding = draw.draw_bounding_box_class( draw_bounding, corners_compo, ['compo' for j in range(len(corners_compo))]) draw_boundary = draw.draw_boundary(boundary_rec, org.shape) # save results if is_save: cv2.imwrite('output/org.png', org) cv2.imwrite('output/labeled.png', draw_bounding) cv2.imwrite('output/boundary.png', draw_boundary) cv2.imwrite('output/gradient.png', binary) cv2.imwrite('output/clean.png', img_clean) end = file.timer(start)