def read_ground_truth_annotations(self): if True: path = self.options.ground_truth_path basepath, extension = os.path.splitext(path) if extension == ".idl": idl_data = open_idl_file(path) self.ground_truth = idl_data_to_detections(idl_data) elif extension == ".data_sequence": self.ground_truth = list(open_data_sequence(path)) else: raise Exception("Unknown filename extension '%s' in file %s" % \ (extension, path)) if False: # should be false, this offset is already compensated somewhere else # we skip the first frame, since doppia code skip the first frames too self.ground_truth = self.ground_truth[1:] if self.stereo_rectification: self.ground_truth = rectify_left_detections(self.stereo_rectification, self.ground_truth) if self.options.adjust_width: self.ground_truth = adjust_detections_width(self.ground_truth) print("Read ground truth from", self.options.ground_truth_path) else: sys.path.append("../stixels_motion_evaluation") from stixels_motion_evaluation import read_ground_truth self.options.stereo_rectification = self.stereo_rectification self.ground_truth = read_ground_truth(self.options) # self.stereo_rectification = self.options.stereo_rectification return
def read_data_sequences(self): self.data_sequences = dict() paths = [] paths += [os.path.join(path, "detections.data_sequence") for path in self.options.recordings_paths] paths += self.options.detections_paths for path in paths: basename, extension = os.path.splitext(path) path_pieces = os.path.normpath(os.path.abspath(basename)).split(os.sep) if extension == ".data_sequence": recording_name = path_pieces[-2] # the folder name data_sequence = list(open_data_sequence(path)) elif extension == ".idl": recording_name = path_pieces[-1] # the filename, without extension idl_data = open_idl_file(path) data_sequence = idl_data_to_detections(idl_data) if True: # we skip the first frame, since doppia code skip the first frames too # if from idl, we assume it does not come from doppia code data_sequence = data_sequence[1:] if self.stereo_rectification: # if idl, we assume, undistorted, non rectified data data_sequence = rectify_left_detections(self.stereo_rectification, data_sequence) else: raise Exception("Unknown filename extension '%s' in file %s" % \ (extension, path)) if self.options.adjust_width: data_sequence = adjust_detections_width(data_sequence) print("Read data for", recording_name) self.data_sequences[recording_name] = data_sequence return
sys.path.append("../stixels_evaluation") sys.path.append("../helpers") import pylab #from detections_pb2 import Detections, Detection #from data_sequence import DataSequence from idl_parsing import open_idl_file from idl_to_detections_sequence import idl_data_to_detections dalal_idl_path = "/home/rodrigob/code/ethz_svn/projects/data/gt_and_idl/bahnhof/dalal-raw-undist.idl" ground_truth_idl_path = "/home/rodrigob/data/bahnhof/annotations/bahnhof-annot.idl" print("Reading data...") idl_data = open_idl_file(dalal_idl_path) dalal_detections = idl_data_to_detections(idl_data) idl_data = open_idl_file(ground_truth_idl_path) ground_truth_detections = idl_data_to_detections(idl_data) print("Computing ...") def compute_heights(detections_sequence): heights = [] for detections in detections_sequence: for detection in detections.detections: bb = detection.bounding_box height = bb.max_corner.y - bb.min_corner.y heights.append(height) return heights dalal_heights = compute_heights(dalal_detections)
sys.path.append("../stixels_evaluation") sys.path.append("../helpers") import pylab #from detections_pb2 import Detections, Detection #from data_sequence import DataSequence from idl_parsing import open_idl_file from idl_to_detections_sequence import idl_data_to_detections dalal_idl_path = "/home/rodrigob/code/ethz_svn/projects/data/gt_and_idl/bahnhof/dalal-raw-undist.idl" ground_truth_idl_path = "/home/rodrigob/data/bahnhof/annotations/bahnhof-annot.idl" print("Reading data...") idl_data = open_idl_file(dalal_idl_path) dalal_detections = idl_data_to_detections(idl_data) idl_data = open_idl_file(ground_truth_idl_path) ground_truth_detections = idl_data_to_detections(idl_data) print("Computing ...") def compute_heights(detections_sequence): heights = [] for detections in detections_sequence: for detection in detections.detections: bb = detection.bounding_box height = bb.max_corner.y - bb.min_corner.y heights.append(height) return heights