def print_R_script(scene, tree, classifier, step_size): print "# " + scene.filename + "\n" # Some R functions for plotting. print "library(scales)" # for alpha blending rtools.print_plot_focus_measures(scene.fvalues) # The correct classifications. classes = [ "left" if classifier(scene, lens_pos) else "right" for lens_pos in range(2 * step_size, scene.step_count) ] # What we actually get. results = [] for lens_pos in range(2 * step_size, scene.step_count): initial_positions = featuresfirststep.first_three_lens_pos( lens_pos, step_size) first, second, third = scene.get_focus_values(initial_positions) norm_lens_pos = float(lens_pos) / (scene.step_count - 1) evaluator = featuresfirststep.firststep_feature_evaluator( first, second, third, norm_lens_pos) evaluation = evaluatetree.evaluate_tree(tree, evaluator) results.append(evaluation) rtools.print_classification_points(classes, results, ["left", "right"]) print "# Plot me!\n"
def _get_first_direction(self): """Direction in which we should start sweeping initially.""" first, second, third = self.camera.get_fvalues( self.camera.visited_positions[-3:]) norm_lens_pos = float(self.initial_pos) / (self.scene.step_count - 1) evaluator = featuresfirststep.firststep_feature_evaluator( first, second, third, norm_lens_pos) return Direction(evaluatetree.evaluate_tree( self.params.left_right_tree, evaluator))
def print_R_script(scene, tree, step_size): print "# " + scene.filename + "\n" # Some R functions for plotting. print "library(scales)" # for alpha blending rtools.print_plot_focus_measures(scene.fvalues) classes = [] results = [] for lens_pos in range(2 * step_size, scene.step_count): # The correct classification. go_left = featuresfirststep.nearest_on_left(scene, lens_pos) initial_positions = featuresfirststep.first_three_lens_pos( lens_pos, step_size) if go_left: initial_positions.reverse() last_pos = initial_positions[-1] if scene.distance_to_closest_left_peak(last_pos) <= 15: classes.append("fine") else: classes.append("coarse") else: last_pos = initial_positions[-1] if scene.distance_to_closest_right_peak(last_pos) <= 15: classes.append("fine") else: classes.append("coarse") # The classification obtained by evaluating the decision tree. first, second, third = scene.get_focus_values(initial_positions) norm_lens_pos = float(lens_pos) / (scene.step_count - 1) evaluator = featuresfirststep.firststep_feature_evaluator( first, second, third, norm_lens_pos) evaluation = evaluatetree.evaluate_tree(tree, evaluator) results.append(evaluation) rtools.print_classification_points(classes, results, ["coarse", "fine"]) print "# Plot me!\n"