def fitter_main(args, fitter): world_points = gen_target.get_targets() optlist, _ = getopt.getopt(args[1:], "i:o:") in_file_name = None out_file_name = None for opt, param in optlist: if opt == "-i": in_file_name = param if opt == "-o": out_file_name = param if not in_file_name: raise Exception("Usage: %s -i <input image> [-o <output image>]" % args[0]) print "Loading image (black and white)" image = cv.LoadImage(in_file_name, False) print "Loading image (colour)" color_image = cv.LoadImage(in_file_name, True) print "Finding labelled circles" image_features = find_circles.find_labelled_circles(image, annotate_image=color_image, find_ellipses=True) print "Solving" R, T, pixel_scale = fitter.solve(world_points, image_features, pixel_scale=2986.3, annotate_image=color_image) print R, T, pixel_scale err = calc_reprojection_error(R, T, pixel_scale, world_points, image_features) print "Reprojection error: %f" % err draw_reprojected(R, T, pixel_scale, world_points, color_image) if out_file_name: cv.SaveImage(out_file_name, color_image)
in_file_name = None out_file_name = None for opt, param in optlist: if opt == "-i": in_file_name = param if opt == "-o": out_file_name = param if not in_file_name: raise Exception("Usage: %s -i <input image> [-o <output image>]" % sys.argv[0]) print "Loading image (black and white)" image = cv.LoadImage(in_file_name, False) print "Loading image (colour)" color_image = cv.LoadImage(in_file_name, True) print "Finding labelled circles" image_circles = find_circles.find_labelled_circles(image, annotate_image=color_image, centre_origin=True) print image_circles print "Solving" R = solve(world_circles, image_circles, pixel_scale=3182.4, annotate_image=color_image) print R if out_file_name: cv.SaveImage(out_file_name, color_image)
in_file_names = args.input_images out_file_names = ["calibrated-%u.png" % i for i in range(len(in_file_names))] print in_file_names if not in_file_names: raise Exception("Usage: %s -i <input image> [-o <output image>]" % sys.argv[0]) print "Loading images (black and white)" images = [cv.LoadImage(in_file_name, False) for in_file_name in in_file_names] print "Loading image (colour)" color_images = [cv.LoadImage(in_file_name, True) for in_file_name in in_file_names] print "Finding labelled circles" image_circles = [find_circles.find_labelled_circles(image, annotate_image=color_image, find_ellipses=True) for image, color_image in zip(images, color_images)] print image_circles for i, out_file_name in enumerate(out_file_names): cv.SaveImage(out_file_name, color_images[i]) print "Finding approximate fit" ps=3156. ellipse_fitter = fit_project_ellipse.EllipseProjectFitter() Ms = [] for color_image, features in zip(color_images, image_circles): R, T, ps = ellipse_fitter.solve(world_circles, features, pixel_scale=ps, annotate_image=None)