def main(argv): filters = [] features = featuresfirststep.two_measure_features classifier = featuresfirststep.highest_on_left step_size = 1 # Process command line options. Anything remaining will be considered # to be filters for features. for arg in argv: if arg == "--three-measures": features = featuresfirststep.measure_features elif arg == "--all-features": features = featuresfirststep.all_features elif arg == "--highest": # Default pass elif arg == "--nearest": classifier = featuresfirststep.nearest_on_left elif arg == "--high-and-near": classifier = featuresfirststep.highest_and_near_on_left elif arg == "--double-step": step_size = 2 else: filters.append(arg) scenes = load_scenes() # Print the contents of the ARFF file to screen (use output # redirection to save to file) print get_arff_header(features(filters)) print "@DATA" instances = get_instances(scenes, classifier, features(filters), step_size) for instance in instances: print instance
def main(argv): scenes = load_scenes() # Make sure that the number of steps is appropriate. if steps < max(len(scene.maxima) for scene in scenes): print ("Warning - number of steps smaller than the number of lens " "positions in the largest scene.") # Calculate various statistics. lens_positions = [float(i) / (steps - 1) for i in range(steps)] print_statistics(scenes, lens_positions, probability_left_peak) print_statistics(scenes, lens_positions, probability_not_left_peak) print_statistics(scenes, lens_positions, probability_right_peak) print_statistics(scenes, lens_positions, probability_not_right_peak) print_statistics(scenes, lens_positions, probability_highest_left) print_statistics(scenes, lens_positions, probability_highest_right) print_statistics(scenes, lens_positions, probability_most_left) print_statistics(scenes, lens_positions, probability_most_right) print_statistics(scenes, lens_positions, probability_nearest_left) print_statistics(scenes, lens_positions, probability_nearest_right) print_statistics(scenes, lens_positions, probability_nearhighest_left) print_statistics(scenes, lens_positions, probability_nearhighest_right)
def main(argv): params = featuresturn.ParameterSet() # Process command line options. for arg in argv: if arg == "--closest-peak": params.peakHandling = featuresturn.PeakHandling.CLOSEST elif arg == "--backtrack-faster": params.backtrackHandling = featuresturn.BacktrackHandling.FASTER scenes = load_scenes() json_file = create_json(scenes, params) print json_file
def main(argv): # Parse script arguments try: opts, _ = getopt.getopt(argv, "d:lv", ["double-step", "closest-peak", "backtrack-faster", "use-weights", "show-random-sample", "leave-out="]) except getopt.GetoptError: print_script_usage() sys.exit(2) features = all_features step_size = 1 show_random_sample = False leave_out = "" params = ParameterSet() # Process command line options. Anything remaining will be considered # to be filters for features. for opt, arg in opts: if opt in ("-d", "--double-step"): step_size = 2 elif opt in ("-lv", "--leave-out"): leave_out = arg elif opt == "--closest-peak": params.peakHandling = PeakHandling.CLOSEST elif opt == "--backtrack-faster": params.backtrackHandling = BacktrackHandling.FASTER elif opt == "--use-weights": params.outlierHandling = OutlierHandling.WEIGHTING params.uniformSamplingRate = 0.10 elif opt == "--show-random-sample": show_random_sample = True else: print_script_usage() sys.exit(2) random.seed(seed) scenes = load_scenes(folder="focusraw/", excluded_scenes=["cat.txt", "moon.txt", "projector2.txt", "projector3.txt", leave_out]) if show_random_sample: simulate_samples(scenes, features(), step_size, params) else: simulate_full(scenes, features(), step_size, params)
def main(argv): scenes_folder = "focusraw/" scenes = load_scenes(folder=scenes_folder) ratio1 = [ ratio(scene.fvalues[0], scene.fvalues[8]) for scene in scenes ] ratio2 = [ ratio(scene.fvalues[8], scene.fvalues[16]) for scene in scenes ] first_maxima = [ scene.maxima[0] for scene in scenes ] print "library(plotrix)" rtools.print_array_assignment("ratio1", ratio1) rtools.print_array_assignment("ratio2", ratio2) rtools.print_array_assignment("first_maxima", first_maxima) print "plot(ratio1, ratio2, xlim=c(-0.070,0.030), ylim=c(-0.070,0.010))" print "# To avoid overlapping labels" print "thigmophobe.labels(ratio1,ratio2,labels=first_maxima,cex=1.0)"
def main(): scenes_folder = "focusraw/" scenes = load_scenes(folder=scenes_folder, excluded_scenes=["cat.txt", "moon.txt"]) xs = [] ys = [] for scene in scenes: for maxima in scene.maxima: xs.append(float(maxima) / scene.step_count) ys.append(scene.fvalues[maxima]) # For alpha blending print "library(scales)" print "plot(-1, -1, xlim=c(0,1), ylim=c(0,1))" for x, y in zip(xs, ys): print "segments(%f, 0, %f, %f, col=alpha(\"black\", 0.5))" % (x, x, y) return
def main(argv): # Parse script arguments try: opts, _ = getopt.getopt(argv, "", [ "lowlight", "low-light", "lowlightgauss", "low-light-gauss", "scene-to-print=" ]) except getopt.GetoptError: print_script_usage() sys.exit(2) scene_to_print = None scenes_folder = "focusraw/" for opt, arg in opts: if opt in ("--lowlight", "--low-light"): scenes_folder = "lowlightraw/" elif opt in ("--lowlightgauss", "--low-light-gauss"): scenes_folder = "lowlightgaussraw/" elif opt == "--scene-to-print": scene_to_print = arg else: print_script_usage() sys.exit(2) random.seed(seed) scenes = load_scenes(folder=scenes_folder, excluded_scenes=["cat.txt", "moon.txt", "projector2.txt", "projector3.txt"]) search_perfect(scenes) print "\n" search_standard(scenes, scene_to_print) print "\n" search_sweep(scenes, False) print "\n" search_sweep(scenes, True) print "\n" search_full(scenes)
def main(argv): # Parse script arguments try: opts, _ = getopt.getopt(argv, "d:uo", ["left-right-tree=", "lowlight", "low-light", "lowlightgauss", "low-light-gauss", "action-tree=", "double-step", "backlash", "noise", "specific-scene=", "perfect-file=", "use-only="]) except getopt.GetoptError: print_script_usage() sys.exit(2) params = BenchmarkParameters() specific_scene = None use_only_file = None scenes_folder = "focusraw/" for opt, arg in opts: if opt in ("-d", "--double-step"): params.step_size = 2 raise Exception("Simulator does not support double step size yet.") elif opt in ("-uo", "--use-only"): use_only_file = arg elif opt in ("--lowlight", "--low-light"): scenes_folder = "lowlightraw/" elif opt in ("--lowlightgauss", "--low-light-gauss"): scenes_folder = "lowlightgaussraw/" elif opt == "--left-right-tree": params.left_right_tree = evaluatetree.read_decision_tree( arg, featuresfirststep.all_features_dict()) elif opt == "--action-tree": params.action_tree = evaluatetree.read_decision_tree( arg, featuresturn.all_features_dict()) elif opt == "--specific-scene": specific_scene = arg elif opt == "--perfect-file": params.perfect_classification = load_classifications(arg) elif opt == "--backlash": params.backlash = True elif opt == "--noise": params.noise = True else: print_script_usage() sys.exit(2) random.seed(seed) # Make sure simulator has everything it needs. if params.missing_params(): print_script_usage() sys.exit(2) scenes = load_scenes(folder=scenes_folder, excluded_scenes=["cat.txt", "moon.txt", "projector2.txt", "projector3.txt"]) if use_only_file: scenes = [scene for scene in scenes if scene.filename == use_only_file] if specific_scene is None: benchmark_scenes(params, scenes) else: benchmark_specific(params, scenes, specific_scene)