Beispiel #1
0
    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]
        y = [s[1] for s in side]
        ax1.plot(x, y, color=colors[index])
    piece_data['sides'] = [s.tolist() for s in piece.sides]
  except:
    print 'could not find sides for "%s"' % filepath

  # Get length of each side and label.
  try:
    piece.find_side_lengths()
    piece_data['side_lengths'] = piece.side_lengths
  except: