piece_data['center'] = piece.center except: print 'could not find center for "%s"' % filepath # Find corner candidates with template matching. try: piece.template_corners() if args['--plot']: for cc in piece.candidate_corners: ax1.plot(cc[0], cc[1], '+r', markersize=8) except: print 'could not find corner candidates for "%s"' % filepath # Find the "true corners." try: piece.find_true_corners() if args['--plot']: corner_xs = [c[0] for c in piece.corners] corner_ys = [c[1] for c in piece.corners] ax1.plot(corner_xs, corner_ys, 'og', markersize=8) piece_data['corners'] = [c.tolist() for c in piece.corners] except: print 'could not find true corners for "%s"' % filepath # Determine the four sides: paths along the outline that connect corners. try: piece.find_sides() if args['--plot']: colors = ('r', 'g', 'b', 'cyan') for index, side in enumerate(piece.sides): x = [s[0] for s in side]