Пример #1
0
def transform_folder_to_world(sub_dir):
    base_dir = "E:\Datasets\DataHack\Train"
    base_res_dir = "E:\Datasets\DataHack\World\Train"
    print('Working on sub_dir: {}'.format(sub_dir))

    for idx in data_utils.enumerate_frames(os.path.join(base_dir, sub_dir)):
        pc_file = os.path.join(
            base_res_dir,
            data_utils.frame_to_filename(sub_dir, idx, 'pointcloud'))
        if os.path.exists(pc_file):
            continue
        pc, ego, label = data_utils.read_all_data(
            os.path.join(base_dir, sub_dir), idx)
        ego_pc = transform_frame_to_world(pc, ego)
        ego_pc = np.concatenate((ego_pc, pc[:, 3:4]), -1)
        df = (pd.DataFrame(ego_pc) * 100).astype(int)
        res_dir = os.path.join(base_res_dir, sub_dir)
        if not os.path.exists(res_dir):
            os.makedirs(res_dir)
        file_name = os.path.join(res_dir, str(idx).zfill(7))
        df.to_csv(file_name + '_pointcloud.csv', header=None, index=False)
        pd.DataFrame([0] * df.shape[0]).to_csv(file_name + '_labels.csv',
                                               header=None,
                                               index=False)
        pd.DataFrame([0.] * 6).T.to_csv(file_name + '_egomotion.csv',
                                        header=None,
                                        index=False)
Пример #2
0
    
    decimate = 1
    #elMin = 9999
    #azMin = 9999
    #elMax = -9999
    #azMax = -9999
    # agg_point_cloud_list=[]
    prev_img=np.zeros((EL_NUM,AZ_NUM)) # init
    imgSum = np.zeros((EL_NUM,AZ_NUM))
    prev_img_list=[]
    idxXY_list = []
    label_list = []
    fn_list = []
    cloud_len_list=[]
    for idx, frame in enumerate(data_utils.enumerate_frames(video_dir)):
        if idx < min_idx or idx % decimate != 0:
            continue
        pc, ego, label,label_pred_new,fn = data_utils.read_all_data(video_dir, frame)
        # label=label_pred_new
        ego_rt = RotationTranslationData(vecs=(ego[:3], ego[3:]))
        ego_pc = ego_rt.apply_transform(pc[:, :3])
        ego_pc = np.concatenate((ego_pc, pc[:, 3:4]), -1)

        # labeled_pc = np.concatenate((ego_pc, label), -1)
        # agg_point_cloud_list.append(labeled_pc)
        
        
        # img = np.zeros((EL_NUM,AZ_NUM))
        # # img1 = np.zeros((EL_NUM,AZ_NUM))
        # el = np.rad2deg(np.arctan2(pc[:,2],pc[:,0]))
Пример #3
0
import pandas as pd
import os
import numpy as np
from utilities.math_utils import RotationTranslationData
from visualizations.vis import pcshow
from utilities import data_utils

if __name__ == '__main__':
    base_dir = os.path.dirname(os.getcwd())
    video_dir = os.path.join(base_dir, 'data_examples', 'test_video')
    agg_point_cloud_list = []
    max_frames_to_keep = 10
    min_idx = 0
    decimate = 1
    max_dist = 100
    for idx in data_utils.enumerate_frames(video_dir):
        if idx < min_idx or idx % decimate != 0:
            continue
        pc_file = data_utils.frame_to_filename(video_dir, idx, 'pointcloud')
        pc, ego, label = data_utils.read_all_data(video_dir, idx)
        ego_rt = RotationTranslationData(vecs=(ego[:3], ego[3:]))
        ego_pc = ego_rt.apply_transform(pc[:, :3])
        ego_pc = np.concatenate((ego_pc, pc[:, 3:4]), -1)

        labeled_pc = np.concatenate((ego_pc, label), -1)
        agg_point_cloud_list.append(labeled_pc)
        if len(agg_point_cloud_list) > max_frames_to_keep:
            agg_point_cloud_list = agg_point_cloud_list[1:]
        agg_point_cloud = np.concatenate(agg_point_cloud_list, 0)
        pc2disp = ego_rt.inverse().apply_transform(agg_point_cloud[:, :3])
        pc2disp = np.concatenate((pc2disp, agg_point_cloud[:, 3:]), -1)