Esempio n. 1
0
 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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
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
Esempio n. 7
0
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;
Esempio n. 8
0
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
Esempio n. 9
0
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
Esempio n. 10
0
 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
Esempio n. 11
0
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
Esempio n. 12
0
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
Esempio n. 13
0
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)
Esempio n. 14
0
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)
Esempio n. 15
0
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)
Esempio n. 16
0
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)
Esempio n. 17
0
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
Esempio n. 18
0
def remove_data(id):
    if smart_register:
        print 'Warning: remove_data disabled when using smart_register'
    else:
        boxm2_batch.remove_data(id)
Esempio n. 19
0
def remove_data(id):
  boxm2_batch.remove_data(id)
Esempio n. 20
0
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};
Esempio n. 22
0
 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)
Esempio n. 23
0
 def destroy_stream_cache(self):
     if self.str_cache:
         batch.remove_data(self.str_cache.id)
         self.str_cache = None
Esempio n. 24
0
def remove_data(id):
    if smart_register:
        print 'Warning: remove_data disabled when using smart_register'
    else:
        boxm2_batch.remove_data(id)
Esempio n. 25
0
 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)
Esempio n. 26
0
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
Esempio n. 27
0
 def destroy_stream_cache(self):
     if self.str_cache:
         batch.remove_data(self.str_cache.id)
         self.str_cache = None