def mouseHandler(self, event, x, y, flags, param): if event == cv2.EVENT_LBUTTONUP: if self.markings == None: self.markings = np.array([x, y])[np.newaxis] else: self.markings = np.vstack([self.markings, [x, y]]) pix = np.array([x, y, 1]) mk1_t = mk2_to_mk1(self.t, self.gps_times_mk1, self.gps_times_mk2) xform = self.imu_transforms_mk1[mk1_t] v = self.back_projector.calculateBackProjection(xform, pix) l0 = self.back_projector.calculateBackProjection(xform) l = l0 - v best_model = (np.inf, 0, 0) for i, plane in enumerate(self.planes): pt = self.back_projector.calculateIntersection(l0, l, plane) d = np.linalg.norm(pt - plane[3:]) if d < best_model[0]: best_model = (d, i, pt) print best_model[-1] if self.lanes == None: self.lanes = best_model[-1] else: self.lanes = np.vstack((self.lanes, best_model[-1]))
run = remote_run.split('/')[-2] driverseat_run = driverseat_folder + run + '/' imu_transforms, gps_times_mk1 = get_transforms( remote_run, run, 'mark1') _, gps_times_mk2 = get_transforms(remote_run, run, 'mark2') print driverseat_run json_name = 'gps.json' json_gps_name = driverseat_run + json_name zip_gps_name = json_gps_name + '.zip' if not os.path.isfile(json_gps_name): print '\tExporting ' + json_name gps_data = [] for i in xrange(0, gps_times_mk2.shape[0], sub_samp): mk1_i = mk2_to_mk1(i, gps_times_mk1, gps_times_mk2) imu_xform = imu_transforms[mk1_i, :, :] gps_data.append(imu_xform.tolist()) with open(json_gps_name, 'w') as json_gps_file: json.dump(gps_data, json_gps_file) if not os.path.isfile(zip_gps_name): print '\tZipping...' data = '\n'.join( [x for x in open(json_gps_name, 'r').readlines()]) json_zip = ZipFile(zip_gps_name, 'w', ZIP_DEFLATED) json_zip.writestr(json_name, data) json_zip.close() configurator.set('gps_json', True)
def mk2_to_mk1(self, mk2_idx=-1): if mk2_idx == -1: mk2_idx = self.mk2_t return mk2_to_mk1(mk2_idx, self.gps_times_mk1, self.gps_times_mk2)
run = remote_run.split('/')[-2] driverseat_run = driverseat_folder + run + '/' imu_transforms, gps_times_mk1 = get_transforms(remote_run, run, 'mark1') _, gps_times_mk2 = get_transforms(remote_run, run, 'mark2') print driverseat_run json_name = 'gps.json' json_gps_name = driverseat_run + json_name zip_gps_name = json_gps_name + '.zip' if not os.path.isfile(json_gps_name): print '\tExporting ' + json_name gps_data = [] for i in xrange(0, gps_times_mk2.shape[0], sub_samp): mk1_i = mk2_to_mk1(i, gps_times_mk1, gps_times_mk2) imu_xform = imu_transforms[mk1_i, :, :] gps_data.append(imu_xform.tolist()) with open(json_gps_name, 'w') as json_gps_file: json.dump(gps_data, json_gps_file) if not os.path.isfile(zip_gps_name): print '\tZipping...' data = '\n'.join([x for x in open(json_gps_name, 'r').readlines()]) json_zip = ZipFile(zip_gps_name, 'w', ZIP_DEFLATED) json_zip.writestr(json_name, data) json_zip.close() configurator.set('gps_json', True)