Esempio n. 1
0
def draw_uv_map_side(side, model_root, method='s', bins=256):
    """ Draw UV Map onto the RGB image of the Side class.

    Args:
        side: a Side class
        model_root: str, will be used to retrieve original 3d point cloud model
            using "/<model_root>/011_banana/google_512k/textured.obj"
        method: 's' or 'c'
        bins: int, default 256

    Returns: (h, w, 3) ndarray

    """
    _img = side.img
    for i, class_name in enumerate(side.class_list):
        model_path = f"{model_root}/{class_name}/google_512k/textured.obj"
        pts = datalib.load_obj(model_path)
        segid = fat_name2segid[class_name]

        store_dict = dict(depth_sorted_ind=None)
        pts_ind = side.transform_point_cloud(
            pts, ind=i, store_dict=store_dict).astype(int)
        pts_sorted = pts[store_dict['depth_sorted_ind']]
        _img = draw_uv_map_image(pts_sorted, pts_ind, _img,
                                 mask_config=(side.seg, segid),
                                 method=method, bins=bins)
    return _img
def generator(n_pc):
    idx = 0
    while (idx < n_pc):
        # for idx in range(len(pc_names)):
        if idx == len(pc_names):
            idx = 0
        pc_filename = pc_names[idx]
        pc_filepath = join(root_dir, pc_filename)
        points = load_obj(pc_filepath)
        idx += 1
        yield points
Esempio n. 3
0
    def visualize_object(self,
                         ind,
                         model_root,
                         show_pivots=True,
                         show_cuboids=True,
                         show_projected_pcd=True,
                         color_array=(255, 0, 255)):
        """

        Args:
            ind: index into self.objects
            model_root: /<model_root>/<model_name>/google_512k/textured.obj'
                        example <model_name> like '037_scissors'
            show_pivots: bool, show transformed pivots axis
            show_cuboids: bool, show projected cuboids
            show_projected_pcd: bool, draw colored projected point cloud
                                onto the object
            color_array: tuple, default pink

        Returns: annotated ndarray (h, w, 3)

        """
        pivots = self.canonical_pivots[ind]
        cuboid = self.canonical_cuboids[ind]

        # Get model point cloud
        # The '006_mustart_bottle' is UPPER CASE 16K, others' are 16k?
        model_name = self.objects[0]['class'].replace('_16k', '').replace('_16K', '')
        model_pcd = datalib.load_obj(
            osp.join(model_root, model_name, 'google_512k/textured.obj'))

        # Visualize
        _img = self.img.copy()
        if show_projected_pcd:
            store_dict = dict(depth_sorted_ind=None)
            pcd_2d = self.transform_point_cloud(model_pcd, ind, store_dict=store_dict)
            pcd_ind = np.floor(pcd_2d).astype(int)
            y_ind = np.clip(pcd_ind[:, 1], 0, self.cap_height-1)
            x_ind = np.clip(pcd_ind[:, 0], 0, self.cap_width-1)
            _img[y_ind, x_ind, :] = color_array
        if show_cuboids:
            cuboid_2d = self.transform_point_cloud(cuboid, ind)
            _img = visualize.draw_proj_cuboid_image(_img, cuboid_2d)
        if show_pivots:
            pivots_2d = self.transform_point_cloud(pivots, ind)
            _img = visualize.draw_pivots_image(_img, pivots_2d)

        return _img
Esempio n. 4
0
        return False


# Set directory paths
dir_path = os.path.dirname(os.path.realpath(__file__))
data_path = os.path.join(dir_path, 'data')
car_path = os.path.join(data_path, 'autonomous-car')

# Reference location on Earth (Hoover Tower)
lat0 = 37.4276
lon0 = -122.1670
h0 = 0
p_ref_ECEF = utils.lla2ecef(np.array([lat0, lon0, h0]))

# Load data
sensors = data_utils.load_obj(car_path + '/sim/sensor_data')
data_gnss = sensors["gnss"]
data_compass = sensors["compass"]
car_params = vehicle_sim.get_parameters()
traj = data_utils.load_obj(car_path + '/sim/traj_data')

################################################################
# Least Squares
################################################################
LS = ls.runLeastSquares(data_gnss["t"],
                        data_gnss["sat_pos"],
                        data_gnss["pr"],
                        p_ref_ECEF=p_ref_ECEF)
data_utils.save_obj(LS, car_path + '/filtering/leastsquares')

################################################################
Esempio n. 5
0
 def __getitem__(self, idx):
     pc_filename = self.pc_names[idx]
     pc_filepath = join(self.root_dir, pc_filename)
     sample = load_obj(pc_filepath)
     return sample, 0