예제 #1
0
def parse_args(folder, video_file):
    """Folder is the top level folder.
video_file is the name of the camera split to use
ex: parse_args('data/280S', '280S_a2.avi')
returns a dictionary with keys: ('map', 'frames', 'radar' 'gps', 'video', 'params')
corresponding to file names.
"""

    basename = folder + '/' + video_file[:-5]

    map_file = basename + '.map'
    lidar_folder = basename + '_frames/'
    radar_folder = basename + '_rdr/'
    gps_file = basename + '_gps.out'
    gps_mark1_file = basename + '_gpsmark1.out'
    gps_mark2_file = basename + '_gpsmark2.out'

    video_file_num = video_file[-5]

    video_file = folder + '/' + video_file
    param_file = folder + '/params.ini'
    params = open(param_file, 'r').readline().rstrip()

    return {
        'map': map_file,
        'frames': lidar_folder,
        'radar': radar_folder,
        'gps': gps_file,
        'gps_mark1': gps_mark1_file,
        'gps_mark2': gps_mark2_file,
        'video': video_file,
        'cam_num': int(video_file[-5]),
        'params': LoadParameters(params)
    }
예제 #2
0
def parse_args(folder, video_file):
    """
    Folder is the top level folder.
    video_file is the name of the camera split to use
    ex: parse_args('data/280S', '280S_a2.avi')
    returns a dictionary with keys:
    ('map', 'frames', 'radar' 'gps', 'video', 'params')
    corresponding to file names.
    """

    basename = video_file[0:video_file.rfind('_') + 2]
    fullname = folder + '/' + basename

    map_file = fullname + '.map'
    lidar_folder = fullname + '_frames/'
    radar_folder = fullname + '_radar/'
    gps_file = fullname + '_gps.out'
    gps_mark1_file = fullname + '_gpsmark1.out'
    gps_mark2_file = fullname + '_gpsmark2.out'
    mbly_obj_file = fullname + '_mbly.objproto'
    mbly_lane_file = fullname + '_mbly.lanesproto'
    mbly_ref_file = fullname + '_mbly.refproto'

    video_file_num = video_file.replace(basename, '')
    video_file_num = video_file_num.replace('.avi', '').replace('.zip', '')

    video_file = folder + '/' + video_file
    param_file = folder + '/params.ini'
    params = open(param_file, 'r').readline().rstrip()

    return {
        'map': map_file,
        'frames': lidar_folder,
        'radar': radar_folder,
        'gps': gps_file,
        'gps_mark1': gps_mark1_file,
        'gps_mark2': gps_mark2_file,
        'mbly_obj': mbly_obj_file,
        'mbly_lanes': mbly_lane_file,
        'mbly_ref_pts': mbly_ref_file,
        'video': video_file,
        'fullname': fullname,
        'basename': basename,
        'cam_num': int(video_file_num),
        'params': LoadParameters(params)
    }
예제 #3
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Convert ldr files to h5 files containing points')
    parser.add_argument('gps_file')
    parser.add_argument('ldr_file')
    parser.add_argument('h5_file')
    parser.add_argument('--no_transform', action='store_true')
    args = parser.parse_args()

    if not args.no_transform:
        gps_reader = GPSReader(args.gps_file)
        gps_data = gps_reader.getNumericData()
        #imu_transforms = IMUTransforms(gps_data)
        imu_transforms = np.load(OPT_POS_FILE)['data']

    params = LoadParameters(PARAMS_TO_LOAD)

    # FIXME Assuming that ldr file named after frame num
    fnum = int(os.path.splitext(os.path.basename(args.ldr_file))[0])

    data = loadLDR(args.ldr_file)
    if data.shape[0] == 0:
        print '%d data empty' % fnum
        raise

    # Filter
    dist = np.sqrt(np.sum(data[:, 0:3]**2, axis=1))
    if LANE_FILTER:
        data_filter_mask = (dist > 3) & \
                           (data[:, 3] > 40) & \
                           (np.abs(data[:, 1]) < 2.2) & \
예제 #4
0
import numpy as np
from Q50_config import LoadParameters
from pipeline_config import PARAMS_FILE, PARAMS_H5_FILE

def get_param(params, key):
    parts = key.split('/')
    param = params[parts[0]]
    for part in parts[1:]:
        if part.isdigit():
            param = param[int(part)]
        else:
            param = param[part]
    return param

if __name__ == '__main__':
    params = LoadParameters(open(PARAMS_FILE, 'r').readline().rstrip())
    #import IPython; IPython.embed()
    keys = params.keys()

    h5f = h5py.File(PARAMS_H5_FILE, 'w')

    for key in keys:
        val = get_param(params, key)
        if isinstance(val, list) and isinstance(val[0], dict):
            for j in range(len(val)):
                keys.append(key + '/' + str(j))
        elif isinstance(val, dict):
            for subkey in val:
                keys.append(key + '/' + subkey)
        else:
            print key
예제 #5
0
    def __init__(self):
        self.start = EXPORT_START
        self.end = EXPORT_START + EXPORT_NUM * EXPORT_STEP
        self.step = EXPORT_STEP
        self.count = 0

        self.ren = vtk.vtkRenderer()
        ''' Transforms '''

        self.imu_transforms = get_transforms()
        self.trans_wrt_imu = self.imu_transforms[self.start:self.end:self.step,
                                                 0:3, 3]
        self.params = LoadParameters('q50_4_3_14_params')
        self.radar_params = self.params['radar']
        self.lidar_params = self.params['lidar']
        ''' Radar '''

        self.rdr_pts = loadRDRCamMap(MAP_FILE)
        self.radar_actors = []

        print 'Adding transforms'

        gps_cloud = VtkPointCloud(self.trans_wrt_imu[:, 0:3],
                                  0 * self.trans_wrt_imu[:, 0])
        self.ren.AddActor(gps_cloud.get_vtk_cloud())

        #print 'Adding octomap'

        #octomap_actor = load_octomap(OCTOMAP_H5_FILE)
        #self.ren.AddActor(octomap_actor)

        print 'Adding point cloud'

        cloud_actor = load_vtk_cloud(STATIC_VTK_FILE)
        self.ren.AddActor(cloud_actor)

        #dynamic_actor = load_vtk_cloud(DYNAMIC_VTK_FILE)
        #dynamic_actor.GetProperty().SetColor(0, 0, 1)
        #dynamic_actor.GetMapper().ScalarVisibilityOff()
        #self.ren.AddActor(dynamic_actor)

        print 'Adding car'

        self.car = load_ply('gtr.ply')
        self.ren.AddActor(self.car)

        print 'Rendering'

        self.ren.ResetCamera()

        self.win = vtk.vtkRenderWindow()
        self.win.AddRenderer(self.ren)
        self.win.SetSize(400, 400)

        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.win)
        mouseInteractor = vtk.vtkInteractorStyleTrackballCamera()
        self.iren.SetInteractorStyle(mouseInteractor)

        self.iren.Initialize()

        # Whether to write video

        self.record = False

        # Set up time

        self.iren.AddObserver('TimerEvent', self.update)
        self.timer = self.iren.CreateRepeatingTimer(100)

        # Add keypress event
        self.iren.AddObserver('KeyPressEvent', self.keyhandler)
        self.mode = 'ahead'

        self.iren.Start()
    h5f = h5py.File(args.bounds1, 'r')
    cluster_labels1 = h5f['cluster_labels'][...]
    cluster_centers1 = h5f['cluster_centers'][...]
    h5f.close()
    h5f = h5py.File(args.bounds2, 'r')
    cluster_labels2 = h5f['cluster_labels'][...]
    cluster_centers2 = h5f['cluster_centers'][...]
    h5f.close()

    # Set up video and shared parameters

    cam_num = args.cam
    video_file = args.video
    # PARAM FIXME
    params = LoadParameters('q50_4_3_14_params')
    cam = params['cam'][cam_num-1]
    video_reader = VideoReader(video_file)
    T_from_i_to_l = np.linalg.inv(params['lidar']['T_from_l_to_i'])

    # BGR

    red = [0, 0, 255]
    blue = [255, 0, 0]
    green = [0, 255, 0]

    # Set up video writer

    if not args.debug:
        fps = 30  # PARAM
        fourcc = cv2.cv.CV_FOURCC(*'MJPG')