def render( self, cam, ni=1280, nj=720, device_string="", ident_string="", tnear=1000000.0, tfar=1000000.0, ): dev, cache = self._get_device_cache(device_string) if self.rgb: if self.view: expimg = boxm2_adaptor.render_rgb_view_dep( self.scene, cache, cam, ni, nj, dev, ident_string) else: expimg, vis_image, status = boxm2_adaptor.render_rgb( self.scene, cache, cam, ni, nj, dev, tnear, tfar) batch.remove_data(vis_image.id) else: if self.view: expimg = boxm2_adaptor.render_grey_view_dep( self.scene, cache, cam, ni, nj, dev, ident_string) else: expimg = boxm2_adaptor.render_grey(self.scene, cache, cam, ni, nj, dev, ident_string, tnear, tfar) return expimg
def image_mean(img): boxm2_batch.init_process("vilImageMeanProcess") boxm2_batch.set_input_from_db(0,img) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) mean_val = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return mean_val
def image_mean(img): boxm2_batch.init_process("vilImageMeanProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mean_val = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return mean_val
def __del__(self): if self.scene is not None: batch.remove_data(self.scene.id) if self.cpu_cache is not None: batch.remove_data(self.cpu_cache.id) if self.device is not None: batch.remove_data(self.device.id) if self.opencl_cache is not None: batch.remove_data(self.opencl_cache.id) if self.lvcs is not None: batch.remove_data(self.lvcs.id)
def load_image(file_path): boxm2_batch.init_process("vilLoadImageViewProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) (ni_id, ni_type) = boxm2_batch.commit_output(1) (nj_id, nj_type) = boxm2_batch.commit_output(2) ni = boxm2_batch.get_output_unsigned(ni_id) nj = boxm2_batch.get_output_unsigned(nj_id) img = dbvalue(id, type) boxm2_batch.remove_data(ni_id) boxm2_batch.remove_data(nj_id) return img, ni, nj
def load_image(file_path) : boxm2_batch.init_process("vilLoadImageViewProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); (ni_id, ni_type) = boxm2_batch.commit_output(1); (nj_id, nj_type) = boxm2_batch.commit_output(2); ni = boxm2_batch.get_output_unsigned(ni_id); nj = boxm2_batch.get_output_unsigned(nj_id); img = dbvalue(id,type); boxm2_batch.remove_data(ni_id) boxm2_batch.remove_data(nj_id) return img, ni, nj;
def probe_intensities(scene, cpu_cache, str_cache, point): batch.init_process("boxm2CppBatchProbeIntensitiesProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cpu_cache) batch.set_input_from_db(2, str_cache) batch.set_input_float(3, point[0]) batch.set_input_float(4, point[1]) batch.set_input_float(5, point[2]) batch.run_process() (id, type) = batch.commit_output(0) intensities = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(1) visibilities = batch.get_bbas_1d_array_float(id) batch.remove_data(id) return intensities, visibilities
def render(self, cam, ni=1280, nj=720, device_string="", ident_string="", tnear=1000000.0, tfar=1000000.0, ): dev, cache = self._get_device_cache(device_string) if self.rgb: if self.view: expimg = boxm2_adaptor.render_rgb_view_dep(self.scene, cache, cam, ni, nj, dev, ident_string) else: expimg, vis_image, status = boxm2_adaptor.render_rgb( self.scene, cache, cam, ni, nj, dev, tnear, tfar) batch.remove_data(vis_image.id) else: if self.view: expimg = boxm2_adaptor.render_grey_view_dep(self.scene, cache, cam, ni, nj, dev, ident_string) else: expimg = boxm2_adaptor.render_grey(self.scene, cache, cam, ni, nj, dev, ident_string, tnear, tfar) return expimg
def query_cell(scene, cache, point, model_name, model_type): # Point should be 3 len, for a x, y, z coordinate OR #4 in lenght, blk_i, blk_j, blk_k, index if len(point) == 3: (blk, index) = get_index_from_3d_point(scene, cache, point) point = blk + (index, ) batch.init_process("boxm2CppQueryCellProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cache) batch.set_input_int(2, point[0]) batch.set_input_int(3, point[1]) batch.set_input_int(4, point[2]) batch.set_input_int(5, point[3]) batch.set_input_string(6, model_name) batch.set_input_string(7, model_type) batch.run_process() (id, type) = batch.commit_output(0) data = batch.get_bbas_1d_array_float(id) batch.remove_data(id) return data
def query_cell(scene, cache, point, model_name, model_type): # Point should be 3 len, for a x, y, z coordinate OR #4 in lenght, blk_i, blk_j, blk_k, index if len(point) == 3: (blk, index) = get_index_from_3d_point(scene, cache, point) point = blk + (index,) batch.init_process("boxm2CppQueryCellProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cache) batch.set_input_int(2, point[0]) batch.set_input_int(3, point[1]) batch.set_input_int(4, point[2]) batch.set_input_int(5, point[3]) batch.set_input_string(6, model_name) batch.set_input_string(7, model_type) batch.run_process() (id, type) = batch.commit_output(0) data = batch.get_bbas_1d_array_float(id) batch.remove_data(id) return data
def get_index_from_3d_point(scene, cache, point): batch.init_process("boxm2CppGetIndexFrom3dPointProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cache) batch.set_input_float(2, point[0]) batch.set_input_float(3, point[1]) batch.set_input_float(4, point[2]) batch.run_process() (id, type) = batch.commit_output(0) blk_i = batch.get_output_int(id) batch.remove_data(id) (id, type) = batch.commit_output(1) blk_j = batch.get_output_int(id) batch.remove_data(id) (id, type) = batch.commit_output(2) blk_k = batch.get_output_int(id) batch.remove_data(id) (id, type) = batch.commit_output(3) index = batch.get_output_int(id) batch.remove_data(id) return ((blk_i, blk_j, blk_k), index)
def get_3d_point_from_index(scene, cache, block_index, index): # Warning, you probably shouldn't be doing this! batch.init_process("boxm2CppGet3dPointFromIndexProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cache) batch.set_input_int(2, block_index[0]) batch.set_input_int(3, block_index[1]) batch.set_input_int(4, block_index[2]) batch.set_input_int(5, index) batch.run_process() (id, type) = batch.commit_output(0) x = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(1) y = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(2) z = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(3) xs = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(4) ys = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(5) zs = batch.get_output_float(id) batch.remove_data(id) (id, type) = batch.commit_output(6) leaf = batch.get_output_int(id) batch.remove_data(id) return ((x, y, z), (xs, ys, zs), leaf)
def get_info_along_ray(scene, cache, cam, u, v, prefix, identifier=""): print("Ray Probe") batch.init_process("boxm2CppRayProbeProcess") batch.set_input_from_db(0, scene) batch.set_input_from_db(1, cache) batch.set_input_from_db(2, cam) batch.set_input_unsigned(3, u) batch.set_input_unsigned(4, v) batch.set_input_string(5, prefix) batch.set_input_string(6, identifier) batch.run_process() (id, type) = batch.commit_output(0) len_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(1) alpha_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(2) vis_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(3) tabs_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(4) res_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) if (prefix != ""): (id, type) = batch.commit_output(5) data_array_1d = batch.get_bbas_1d_array_float(id) batch.remove_data(id) (id, type) = batch.commit_output(6) nelems = batch.get_output_int(id) batch.remove_data(id) return len_array_1d, alpha_array_1d, vis_array_1d, tabs_array_1d, res_array_1d, data_array_1d, nelems else: return len_array_1d, alpha_array_1d, vis_array_1d, tabs_array_1d, res_array_1d
def remove_data(id): if smart_register: print 'Warning: remove_data disabled when using smart_register' else: boxm2_batch.remove_data(id)
def remove_data(id): boxm2_batch.remove_data(id)
boxm2_batch.set_input_from_db(0,device); boxm2_batch.set_input_from_db(1,scene); boxm2_batch.set_input_from_db(2,openclcache); boxm2_batch.set_input_from_db(3,cam); boxm2_batch.set_input_unsigned(4,NI); boxm2_batch.set_input_unsigned(5,NJ); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); exp_img = dbvalue(id,type); boxm2_batch.init_process("vilSaveImageViewProcess"); boxm2_batch.set_input_from_db(0,exp_img); boxm2_batch.set_input_string(1,exp_fname); boxm2_batch.run_process(); boxm2_batch.remove_data(exp_img.id) boxm2_batch.remove_data(img.id) boxm2_batch.remove_data(cam.id) print("Write Main Cache"); boxm2_batch.init_process("boxm2WriteCacheProcess"); boxm2_batch.set_input_from_db(0,cache); boxm2_batch.run_process(); nadir_cam_fname=cams_dir+ "/camera_nadir.txt" for test_img_idx in test_frames : prediction_cam_fname= cams_dir+"/camera%(#)05d.txt"%{"#":test_img_idx};
def __del__(self): if smart_register and not hasattr(self, '__ref__'): # __ref__ is only an attr if it's a copy, don't remove_data on # delete boxm2_batch.remove_data(self.id)
def destroy_stream_cache(self): if self.str_cache: batch.remove_data(self.str_cache.id) self.str_cache = None
def __del__(self): if smart_register and not hasattr(self, '__ref__'): #__ref__ is only an attr if it's a copy, don't remove_data on delete boxm2_batch.remove_data(self.id)