Beispiel #1
0
    if args['--plot']:
      ax0.plot(piece.outline[:, 0], -piece.outline[:, 1], color='green')
      ax1.plot(piece.outline[:, 0], piece.outline[:, 1], color='gray')
    piece_data['outline'] = piece.outline.tolist()
  except:
    print 'could not find contours for "%s"' % filepath

  # Set the raw image's axis limits to match the derived data's axis.
  if args['--plot']:
    ax0.axes.set_xlim(ax1.axes.get_xlim())
    y_min, y_max = ax1.axes.get_ylim()
    ax0.axes.set_ylim((-y_min, -y_max))

  # Find the center.
  try:
    piece.find_center()
    if args['--plot']:
      ax1.plot(piece.center[0], piece.center[1], '*b', markersize=8)
    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