# Author: Tomas Hodan ([email protected]) # Center for Machine Perception, Czech Technical University in Prague # Example of sampling views from a view sphere. import os import sys sys.path.append(os.path.abspath('..')) from pysixd import view_sampler, misc min_n_views = 642 radius = 1 hemisphere = False out_views_vis_path = '../output/view_sphere.ply' misc.ensure_dir(os.path.dirname(out_views_vis_path)) # Sample views views, views_level = view_sampler.sample_views(min_n_views, radius, hemisphere) print('Sampled views: ' + str(len(views))) view_sampler.save_vis(out_views_vis_path, views)
# Load model texture if par['model_texture_mpath']: model_texture_path = par['model_texture_mpath'].format(obj_id) model_texture = inout.load_im(model_texture_path) else: model_texture = None obj_info = {} obj_gt = {} im_id = 0 for radius in radii: # Sample views views, views_level = view_sampler.sample_views(min_n_views, radius, azimuth_range, elev_range) print('Sampled views: ' + str(len(views))) view_sampler.save_vis(out_views_vis_mpath.format(str(radius)), views, views_level) # Render the object model from all the views for view_id, view in enumerate(views): if view_id % 10 == 0: print('obj,radius,view: ' + str(obj_id) + ',' + str(radius) + ',' + str(view_id)) # Render depth image depth = renderer.render(model, par['cam']['im_size'], par['cam']['K'], view['R'], view['t'], clip_near, clip_far, mode='depth') # Convert depth so it is in the same units as the real test images depth /= par['cam']['depth_scale']
# Load model texture if par['model_texture_mpath']: model_texture_path = par['model_texture_mpath'].format(obj_id) model_texture = inout.load_im(model_texture_path) else: model_texture = None obj_info = {} obj_gt = {} im_id = 0 for radius in radii: # Sample views views, views_level = view_sampler.sample_views(min_n_views, radius, azimuth_range, elev_range) print('Sampled views: ' + str(len(views))) view_sampler.save_vis(out_views_vis_mpath.format(str(radius)), views, views_level) # Render the object model from all the views for view_id, view in enumerate(views): if view_id % 10 == 0: print('obj,radius,view: ' + str(obj_id) + ',' + str(radius) + ',' + str(view_id)) # Render depth image depth = renderer.render(model, par['cam']['im_size'], par['cam']['K'], view['R'], view['t'], clip_near, clip_far, mode='depth') # Convert depth so it is in the same units as the real test images depth /= par['cam']['depth_scale']