def batch_synoptic_function(self):
        """ Create synoptic function (cubic function) at each voxel """
        # write image identifiers to file
        image_id_fname = self.model_dir + "/image_list.txt"
        fd = open(image_id_fname, "w")
        print >> fd, 2 * len(self.imgList)
        for i, img in enumerate(self.imgList):
            print >> fd, "img_%05d" % i
        for i, img in enumerate(self.imgList):
            print >> fd, "viewdir_%05d" % i
        fd.close()

        type_id_fname = self.model_dir + "/type_names_list.txt"
        fd2 = open(type_id_fname, "w")
        print >>fd2, 4
        print >>fd2, "aux0"
        print >>fd2, "aux1"
        print >>fd2, "aux2"
        print >>fd2, "aux3"
        fd2.close()

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2OclBatchSynopticFunctionProcess")
        batch.set_input_from_db(0, self.device)
        batch.set_input_from_db(1, self.scene)
        batch.set_input_from_db(2, self.opencl_cache)
        batch.set_input_unsigned(3, len(self.imgList))
        batch.set_input_string(4, image_id_fname)
        batch.set_input_float(5, 0.09)
        batch.run_process()
Exemple #2
0
def scale_and_offset_values(img, scale, offset):
    boxm2_batch.init_process("vilScaleAndOffsetValuesProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, scale)
    boxm2_batch.set_input_float(2, offset)
    boxm2_batch.run_process()
    return
Exemple #3
0
    def create_stream_cache(self, imgs, interval=1, types="", max_gb=6.0):

        # write image identifiers to file
        # imgRange = range(0, len(imgs), interval);
        # num_imgs = len(imgRange);
        image_id_fname = self.model_dir + "/image_list.txt"
        fd = open(image_id_fname, "w")
        print >> fd, len(imgs)
        # for i in imgRange:
        #  print >>fd, "img_%05d"%i
        for img in imgs:
            fname, fextension = os.path.splitext(img)
            bname = os.path.basename(fname)
            print >> fd, bname
        fd.close()

        # write type identifiers into file
        type_id_fname = self.model_dir + "/type_names_list.txt"
        fd2 = open(type_id_fname, "w")
        print >> fd2, 4
        print >> fd2, "aux0"
        print >> fd2, "aux1"
        print >> fd2, "aux2"
        print >> fd2, "aux3"
        fd2.close()

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2CreateStreamCacheProcess")
        batch.set_input_from_db(0, self.scene)
        batch.set_input_string(1, type_id_fname)
        batch.set_input_string(2, image_id_fname)
        batch.set_input_float(3, max_gb)
        batch.run_process()
        (cache_id, cache_type) = batch.commit_output(0)
        self.str_cache = dbvalue(cache_id, cache_type)
    def create_stream_cache(self, imgs, interval=1, types="", max_gb=6.0):

        # write image identifiers to file
        # imgRange = range(0, len(imgs), interval);
        # num_imgs = len(imgRange);
        image_id_fname = self.model_dir + "/image_list.txt"
        fd = open(image_id_fname, "w")
        print >> fd, len(imgs)
        # for i in imgRange:
        #  print >>fd, "img_%05d"%i
        for img in imgs:
            fname, fextension = os.path.splitext(img)
            bname = os.path.basename(fname)
            print >> fd, bname
        fd.close()

        # write type identifiers into file
        type_id_fname = self.model_dir + "/type_names_list.txt"
        fd2 = open(type_id_fname, "w")
        print >>fd2, 4
        print >>fd2, "aux0"
        print >>fd2, "aux1"
        print >>fd2, "aux2"
        print >>fd2, "aux3"
        fd2.close()

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2CreateStreamCacheProcess")
        batch.set_input_from_db(0, self.scene)
        batch.set_input_string(1, type_id_fname)
        batch.set_input_string(2, image_id_fname)
        batch.set_input_float(3, max_gb)
        batch.run_process()
        (cache_id, cache_type) = batch.commit_output(0)
        self.str_cache = dbvalue(cache_id, cache_type)
def import_triangle_mesh(scene, cache, ply_filename, occupied_prob=0.99):
    batch.init_process("boxm2ImportTriangleMeshProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, ply_filename)
    batch.set_input_float(3, occupied_prob)
    batch.run_process()
def scale_and_offset_values(img,scale,offset):
  boxm2_batch.init_process("vilScaleAndOffsetValuesProcess")
  boxm2_batch.set_input_from_db(0,img)
  boxm2_batch.set_input_float(1,scale)
  boxm2_batch.set_input_float(2,offset)
  boxm2_batch.run_process()
  return
Exemple #7
0
def import_triangle_mesh(scene, cache, ply_filename, occupied_prob=0.99):
    batch.init_process("boxm2ImportTriangleMeshProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, ply_filename)
    batch.set_input_float(3, occupied_prob)
    batch.run_process()
    def batch_synoptic_function(self):
        """ Create synoptic function (cubic function) at each voxel """
        # write image identifiers to file
        image_id_fname = self.model_dir + "/image_list.txt"
        fd = open(image_id_fname, "w")
        print >> fd, 2 * len(self.imgList)
        for i, img in enumerate(self.imgList):
            print >> fd, "img_%05d" % i
        for i, img in enumerate(self.imgList):
            print >> fd, "viewdir_%05d" % i
        fd.close()

        type_id_fname = self.model_dir + "/type_names_list.txt"
        fd2 = open(type_id_fname, "w")
        print >> fd2, 4
        print >> fd2, "aux0"
        print >> fd2, "aux1"
        print >> fd2, "aux2"
        print >> fd2, "aux3"
        fd2.close()

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2OclBatchSynopticFunctionProcess")
        batch.set_input_from_db(0, self.device)
        batch.set_input_from_db(1, self.scene)
        batch.set_input_from_db(2, self.opencl_cache)
        batch.set_input_unsigned(3, len(self.imgList))
        batch.set_input_string(4, image_id_fname)
        batch.set_input_float(5, 0.09)
        batch.run_process()
Exemple #9
0
def detect_shadow_rgb(img, threshold):
    boxm2_batch.init_process("vilShadowDetectionProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, threshold)
    boxm2_batch.run_process()
    (o_id, o_type) = boxm2_batch.commit_output(0)
    region_img = dbvalue(o_id, o_type)
    return region_img
Exemple #10
0
def max_threshold_image(img, threshold):
    boxm2_batch.init_process("vilThresholdMaxImageProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, threshold)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    mask = dbvalue(id, type)
    return mask
Exemple #11
0
def max_threshold_image(img, threshold):
    boxm2_batch.init_process("vilThresholdMaxImageProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_float(1,threshold)
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    mask = dbvalue(id,type)
    return mask
Exemple #12
0
def detect_shadow_rgb(img,threshold) :
  boxm2_batch.init_process("vilShadowDetectionProcess");
  boxm2_batch.set_input_from_db(0,img)
  boxm2_batch.set_input_float(1, threshold);
  boxm2_batch.run_process();
  (o_id,o_type) = boxm2_batch.commit_output(0);
  region_img = dbvalue(o_id,o_type);
  return region_img;
Exemple #13
0
def threshold_image(img, value, threshold_above=True):
    boxm2_batch.init_process("vilThresholdImageProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, value)
    boxm2_batch.set_input_bool(2, threshold_above)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    mask = dbvalue(id, type)
    return mask
Exemple #14
0
def truncate_image(img, min_value, max_value):
    boxm2_batch.init_process("vilTruncateImageProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, min_value)
    boxm2_batch.set_input_float(2, max_value)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    img_out = dbvalue(id, type)
    return img_out
Exemple #15
0
def truncate_image(img,min_value,max_value):
    boxm2_batch.init_process("vilTruncateImageProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_float(1,min_value)
    boxm2_batch.set_input_float(2,max_value)
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    img_out = dbvalue(id,type)
    return img_out
Exemple #16
0
def threshold_image(img, value, threshold_above=True):
    boxm2_batch.init_process("vilThresholdImageProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_float(1,value)
    boxm2_batch.set_input_bool(2,threshold_above)
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    mask = dbvalue(id,type)
    return mask
Exemple #17
0
def threshold_image_inside(img, min_thres, max_thres, threshold_inside=True):
    boxm2_batch.init_process("vilThresholdImageInsideProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, min_thres)
    boxm2_batch.set_input_float(2, max_thres)
    boxm2_batch.set_input_bool(3, threshold_inside)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    mask = dbvalue(id, type)
    return mask
Exemple #18
0
def init_float_img(ni,nj,np,val):
  boxm2_batch.init_process("vilInitFloatImageProcess")
  boxm2_batch.set_input_unsigned(0,ni)
  boxm2_batch.set_input_unsigned(1,nj)
  boxm2_batch.set_input_unsigned(2,np)
  boxm2_batch.set_input_float(3,val)
  boxm2_batch.run_process()
  (id,type) = boxm2_batch.commit_output(0)
  img_out = dbvalue(id,type)
  return img_out
Exemple #19
0
def init_float_img(ni, nj, np, val):
    boxm2_batch.init_process("vilInitFloatImageProcess")
    boxm2_batch.set_input_unsigned(0, ni)
    boxm2_batch.set_input_unsigned(1, nj)
    boxm2_batch.set_input_unsigned(2, np)
    boxm2_batch.set_input_float(3, val)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    img_out = dbvalue(id, type)
    return img_out
Exemple #20
0
def stretch_image(img, min_value, max_value, output_type_str='float'):
    boxm2_batch.init_process("vilStretchImageProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_float(1,min_value)
    boxm2_batch.set_input_float(2,max_value)
    boxm2_batch.set_input_string(3,output_type_str)
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    img_out = dbvalue(id,type)
    return img_out
def extract_cell_centers(scene, cache, prob_thresh=0.0):
    if cache.type == "boxm2_cache_sptr":
        batch.init_process("boxm2ExtractPointCloudProcess")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_float(2, prob_thresh)  # prob t
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Exemple #22
0
def stretch_image(img, min_value, max_value, output_type_str='float'):
    boxm2_batch.init_process("vilStretchImageProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_float(1, min_value)
    boxm2_batch.set_input_float(2, max_value)
    boxm2_batch.set_input_string(3, output_type_str)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    img_out = dbvalue(id, type)
    return img_out
Exemple #23
0
def extract_cell_centers(scene, cache, prob_thresh=0.0):
    if cache.type == "boxm2_cache_sptr":
        batch.init_process("boxm2ExtractPointCloudProcess")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_float(2, prob_thresh)  # prob t
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
def apply_filters_cpp(scene, cpp_cache, prob_thres, filter_basename, filter_id, octree_lvl):
    batch.init_process("boxm2CppFilterResponseProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpp_cache)
    batch.set_input_float(2, prob_thres)
    batch.set_input_string(3, filter_basename)
    # id kernel --> read the kernel from filter_basename + str(filter_id) +
    # ".txt"
    batch.set_input_unsigned(4, filter_id)
    batch.set_input_unsigned(5, octree_lvl)  # octree level to run kernel
    batch.run_process()
Exemple #25
0
def apply_filters_cpp(scene, cpp_cache, prob_thres, filter_basename, filter_id,
                      octree_lvl):
    batch.init_process("boxm2CppFilterResponseProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpp_cache)
    batch.set_input_float(2, prob_thres)
    batch.set_input_string(3, filter_basename)
    # id kernel --> read the kernel from filter_basename + str(filter_id) +
    # ".txt"
    batch.set_input_unsigned(4, filter_id)
    batch.set_input_unsigned(5, octree_lvl)  # octree level to run kernel
    batch.run_process()
Exemple #26
0
    def cpu_batch_paint(self, imgs, cams):
        if (self.str_cache is None):
            self.create_stream_cache(imgs)

        # sigma norm table?
        under_estimation_probability = 0.2
        batch.init_process("bstaSigmaNormTableProcess")
        batch.set_input_float(0, under_estimation_probability)
        batch.run_process()
        (id, type) = batch.commit_output(0)
        n_table = dbvalue(id, type)

        # loop over images creating aux data
        for idx in range(0, len(imgs)):

            # load cam/img
            img, ni, nj = vil_adaptor.load_image(imgs[idx])
            pcam = vpgl_adaptor.load_perspective_camera(cams[idx])
            gcam = vpgl_adaptor.persp2gen(pcam, ni, nj)

            # create norm intensity (num rays...)
            batch.init_process("boxm2CppCreateNormIntensitiesProcess")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, gcam)
            batch.set_input_from_db(3, img)
            batch.set_input_string(4, "img_" + "%05d" % idx)
            batch.run_process()

            # create aux
            batch.init_process("boxm2CppCreateAuxDataOPT2Process")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, gcam)
            batch.set_input_from_db(3, img)
            batch.set_input_string(4, "img_" + "%05d" % idx)
            batch.run_process()
            self.write_cache(True)

        batch.init_process("boxm2CppBatchUpdateOPT2Process")
        batch.set_input_from_db(0, self.scene)
        batch.set_input_from_db(1, self.cpu_cache)
        batch.set_input_from_db(2, self.str_cache)
        batch.set_input_from_db(3, n_table)
        batch.run_process()

        # close the files so that they can be reloaded after the next iteration
        batch.init_process("boxm2StreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()

        self.write_cache()
    def cpu_batch_paint(self, imgs, cams):
        if (self.str_cache is None):
            self.create_stream_cache(imgs)

        # sigma norm table?
        under_estimation_probability = 0.2
        batch.init_process("bstaSigmaNormTableProcess")
        batch.set_input_float(0, under_estimation_probability)
        batch.run_process()
        (id, type) = batch.commit_output(0)
        n_table = dbvalue(id, type)

        # loop over images creating aux data
        for idx in range(0, len(imgs)):

            # load cam/img
            img, ni, nj = vil_adaptor.load_image(imgs[idx])
            pcam = vpgl_adaptor.load_perspective_camera(cams[idx])
            gcam = vpgl_adaptor.persp2gen(pcam, ni, nj)

            # create norm intensity (num rays...)
            batch.init_process("boxm2CppCreateNormIntensitiesProcess")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, gcam)
            batch.set_input_from_db(3, img)
            batch.set_input_string(4, "img_" + "%05d" % idx)
            batch.run_process()

            # create aux
            batch.init_process("boxm2CppCreateAuxDataOPT2Process")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, gcam)
            batch.set_input_from_db(3, img)
            batch.set_input_string(4, "img_" + "%05d" % idx)
            batch.run_process()
            self.write_cache(True)

        batch.init_process("boxm2CppBatchUpdateOPT2Process")
        batch.set_input_from_db(0, self.scene)
        batch.set_input_from_db(1, self.cpu_cache)
        batch.set_input_from_db(2, self.str_cache)
        batch.set_input_from_db(3, n_table)
        batch.run_process()

        # close the files so that they can be reloaded after the next iteration
        batch.init_process("boxm2StreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()

        self.write_cache()
Exemple #28
0
def detect_shadow_ridge(region_img, blob_size_t, sun_angle):
    boxm2_batch.init_process("vilShadowRidgeDetectionProcess")
    boxm2_batch.set_input_from_db(0, region_img)
    boxm2_batch.set_input_int(1, blob_size_t)
    boxm2_batch.set_input_float(2, sun_angle)
    boxm2_batch.run_process()
    (o_id, o_type) = boxm2_batch.commit_output(0)
    region_img = dbvalue(o_id, o_type)
    (o_id, o_type) = boxm2_batch.commit_output(1)
    out_img = dbvalue(o_id, o_type)
    (o_id, o_type) = boxm2_batch.commit_output(2)
    dist_img = dbvalue(o_id, o_type)
    return region_img, out_img, dist_img
Exemple #29
0
def detect_shadow_ridge(region_img,blob_size_t, sun_angle) :
  boxm2_batch.init_process("vilShadowRidgeDetectionProcess");
  boxm2_batch.set_input_from_db(0,region_img)
  boxm2_batch.set_input_int(1, blob_size_t);
  boxm2_batch.set_input_float(2, sun_angle);
  boxm2_batch.run_process();
  (o_id,o_type) = boxm2_batch.commit_output(0);
  region_img = dbvalue(o_id,o_type);
  (o_id,o_type) = boxm2_batch.commit_output(1);
  out_img = dbvalue(o_id,o_type);
  (o_id,o_type) = boxm2_batch.commit_output(2);
  dist_img = dbvalue(o_id,o_type);
  return region_img, out_img, dist_img;
def render_multi(scene, mcache, cam, ni=1280, nj=720, ident_string="", tnear=100000.0, tfar=100000.0):
    batch.init_process("boxm2MultiRenderProcess")
    batch.set_input_from_db(0, mcache)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, cam)
    batch.set_input_unsigned(3, ni)
    batch.set_input_unsigned(4, nj)
    batch.set_input_string(5, ident_string)
    batch.set_input_float(6, tnear)
    batch.set_input_float(7, tfar)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    exp_image = dbvalue(id, type)
    return exp_image
Exemple #31
0
def update_view_surface_density(device, scene, opencl_cache, cam, ni, nj, depth, std_depth, tnear=1000000, tfar=0.00001):
    print("Updating View Surface Density")
    batch.init_process("boxm2OclUpdateSurfaceDensityProcess")
    batch.set_input_from_db(0, device)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, opencl_cache)
    batch.set_input_from_db(3, cam)
    batch.set_input_unsigned(4, ni)
    batch.set_input_unsigned(5, nj)
    batch.set_input_from_db(6, depth)
    batch.set_input_from_db(7, std_depth)
    batch.set_input_float(8, tnear)
    batch.set_input_float(9, tfar)
    return batch.run_process()
Exemple #32
0
def update_max_vis(device, scene, opencl_cache, cam, ni, nj, mask_ptr, tnear=1000000, tfar=0.00001):
    print("Updating Max Vis")
    batch.init_process("boxm2OclUpdateMaxVisScoreProcess")
    batch.set_input_from_db(0, device)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, opencl_cache)
    batch.set_input_from_db(3, cam)
    batch.set_input_unsigned(4, ni)
    batch.set_input_unsigned(5, nj)
    if(mask_ptr is not None):
        batch.set_input_from_db(6, mask_ptr)
    batch.set_input_float(7, tnear)
    batch.set_input_float(8, tfar)
    return batch.run_process()
Exemple #33
0
def gen_color_point_cloud(scene, cache, filename, thresh=0.3, ident="", depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportColorPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)
    batch.set_input_float(3, thresh)
    batch.set_input_string(4, ident)
    batch.run_process()
Exemple #34
0
 def refine_scene_around_geometry(self, filter_v, n_times, p_thresh,
                                  use_gpu):
     if self.opencl_cache.type == "boxm2_opencl_cache_sptr":
         print("Refining around surface geometry")
         batch.init_process(
             "boxm2_ocl_refine_scene_around_geometry_process")
         batch.set_input_from_db(0, self.scene)
         batch.set_input_from_db(1, self.opencl_cache)
         batch.set_input_from_db(2, self.device)
         batch.set_input_from_db(3, filter_v)
         batch.set_input_int(4, n_times)
         # use negative value to refine all
         batch.set_input_float(5, p_thresh)
         batch.set_input_bool(6, use_gpu)
         return batch.run_process()
     else:
         print "ERROR: Cache type not recognized: ", self.opencl_cache.type
         return False
 def refine_scene_around_geometry(
       self, filter_v, n_times, p_thresh, use_gpu):
     if self.opencl_cache.type == "boxm2_opencl_cache_sptr":
         print("Refining around surface geometry")
         batch.init_process(
             "boxm2_ocl_refine_scene_around_geometry_process")
         batch.set_input_from_db(0, self.scene)
         batch.set_input_from_db(1, self.opencl_cache)
         batch.set_input_from_db(2, self.device)
         batch.set_input_from_db(3, filter_v)
         batch.set_input_int(4, n_times)
         # use negative value to refine all
         batch.set_input_float(5, p_thresh)
         batch.set_input_bool(6, use_gpu)
         return batch.run_process()
     else:
         print "ERROR: Cache type not recognized: ", self.opencl_cache.type
         return False
Exemple #36
0
def gen_color_point_cloud(scene,
                          cache,
                          filename,
                          thresh=0.3,
                          ident="",
                          depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportColorPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)
    batch.set_input_float(3, thresh)
    batch.set_input_string(4, ident)
    batch.run_process()
Exemple #37
0
def render_multi(scene,
                 mcache,
                 cam,
                 ni=1280,
                 nj=720,
                 ident_string="",
                 tnear=100000.0,
                 tfar=100000.0):
    batch.init_process("boxm2MultiRenderProcess")
    batch.set_input_from_db(0, mcache)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, cam)
    batch.set_input_unsigned(3, ni)
    batch.set_input_unsigned(4, nj)
    batch.set_input_string(5, ident_string)
    batch.set_input_float(6, tnear)
    batch.set_input_float(7, tfar)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    exp_image = dbvalue(id, type)
    return exp_image
Exemple #38
0
def export_points_and_normals(scene,
                              cache,
                              file_out,
                              save_aux=True,
                              prob_thresh=0.0,
                              vis_thresh=0.0,
                              nmag_thresh=0.0,
                              exp_thresh=0.0,
                              bbox_file=""):
    if cache.type == "boxm2_cache_sptr":
        print("Exporting to oriented point cloud")
        batch.init_process("boxm2ExportOrientedPointCloudProcess")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_string(2, file_out)
        # output aux (prob, vis, normal magnitdue)
        batch.set_input_bool(3, save_aux)
        batch.set_input_float(4, vis_thresh)  # vis threshold
        batch.set_input_float(5, nmag_thresh)  # nmag threshold
        batch.set_input_float(6, prob_thresh)  # prob threshold
        # batch.set_input_float(7,exp_thresh); #exp threshold
        # batch.set_input_string(8, bbox_file); #bb filename
        batch.set_input_string(7, bbox_file)  # bb filename
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
def query_cell_data(scene, cache, point):
    batch.init_process("boxm2CppQueryCellDataProcess")
    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()
Exemple #40
0
def query_cell_data(scene, cache, point):
    batch.init_process("boxm2CppQueryCellDataProcess")
    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()
Exemple #41
0
def gen_error_point_cloud(scene, cache, filename, thresh=0.3, LE_thresh=-1.0, CE_thresh=-1.0, depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportErrorPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)  # ply filename
    batch.set_input_float(3, thresh)  # prob threshold
    batch.set_input_float(4, LE_thresh)  # LE threshold
    batch.set_input_float(5, CE_thresh)  # CE threshold
    batch.run_process()
Exemple #42
0
    def batch_paint(self, imgs, cams, device_string=""):
        # verify stream cache
        if (self.str_cache is None):
            self.create_stream_cache(imgs)

        # sigma norm table?
        under_estimation_probability = 0.2
        batch.init_process("bstaSigmaNormTableProcess")
        batch.set_input_float(0, under_estimation_probability)
        batch.run_process()
        (id, type) = batch.commit_output(0)
        n_table = dbvalue(id, type)

        # call batch paint process
        if device_string == "":
            batch.init_process("boxm2OclPaintBatchProcess")
            batch.set_input_from_db(0, self.device)
            batch.set_input_from_db(1, self.scene)
            batch.set_input_from_db(2, self.opencl_cache)
            batch.set_input_from_db(3, self.str_cache)
            batch.set_input_from_db(4, n_table)
            batch.run_process()
        elif device_string == "cpu":
            batch.init_process("boxm2CppBatchUpdateAppProcess")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, self.str_cache)
            batch.set_input_from_db(3, n_table)
            batch.run_process()

        # close the files so that they can be reloaded after the next iteration
        batch.init_process("boxm2StreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()

        # write out afterwards
        self.write_cache()
def query_cell_brdf(scene, cache, point, model_type):
    batch.init_process("boxm2CppQueryCellBrdfProcess")
    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.set_input_string(5, model_type)
    batch.run_process()
Exemple #44
0
def query_cell_brdf(scene, cache, point, model_type):
    batch.init_process("boxm2CppQueryCellBrdfProcess")
    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.set_input_string(5, model_type)
    batch.run_process()
    def batch_paint(self, imgs, cams, device_string=""):
        # verify stream cache
        if (self.str_cache is None):
            self.create_stream_cache(imgs)

        # sigma norm table?
        under_estimation_probability = 0.2
        batch.init_process("bstaSigmaNormTableProcess")
        batch.set_input_float(0, under_estimation_probability)
        batch.run_process()
        (id, type) = batch.commit_output(0)
        n_table = dbvalue(id, type)

        # call batch paint process
        if device_string == "":
            batch.init_process("boxm2OclPaintBatchProcess")
            batch.set_input_from_db(0, self.device)
            batch.set_input_from_db(1, self.scene)
            batch.set_input_from_db(2, self.opencl_cache)
            batch.set_input_from_db(3, self.str_cache)
            batch.set_input_from_db(4, n_table)
            batch.run_process()
        elif device_string == "cpu":
            batch.init_process("boxm2CppBatchUpdateAppProcess")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, self.cpu_cache)
            batch.set_input_from_db(2, self.str_cache)
            batch.set_input_from_db(3, n_table)
            batch.run_process()

        # close the files so that they can be reloaded after the next iteration
        batch.init_process("boxm2StreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()

        # write out afterwards
        self.write_cache()
Exemple #46
0
def gen_error_point_cloud(scene,
                          cache,
                          filename,
                          thresh=0.3,
                          LE_thresh=-1.0,
                          CE_thresh=-1.0,
                          depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportErrorPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)  # ply filename
    batch.set_input_float(3, thresh)  # prob threshold
    batch.set_input_float(4, LE_thresh)  # LE threshold
    batch.set_input_float(5, CE_thresh)  # CE threshold
    batch.run_process()
Exemple #47
0
def gen_point_cloud(scene, cache, filename, thresh=0.3, vis_thresh=0.5, depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportOrientedPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)
    batch.set_input_float(4, vis_thresh)
    batch.set_input_float(6, thresh)
    batch.run_process()
def update_multi(scene, mcache, cam, img,  ident="", update_alpha=True, var=-1.0, update_app=True, tnear=100000.0, tfar=0.000001):
    # If no device is passed in, do cpu update
    print("boxm2_batch multi GPU update")
    batch.init_process("boxm2MultiUpdateProcess")
    batch.set_input_from_db(0, mcache)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, cam)
    batch.set_input_from_db(3, img)
    batch.set_input_string(4, ident)
    batch.set_input_bool(5, update_alpha)
    batch.set_input_float(6, var)
    batch.set_input_bool(7, update_app)
    batch.set_input_float(8, tnear)
    batch.set_input_float(9, tfar)
    return batch.run_process()
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
Exemple #50
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
def export_points_and_normals(scene, cache, file_out, save_aux=True, prob_thresh=0.0, vis_thresh=0.0, nmag_thresh=0.0, exp_thresh=0.0, bbox_file=""):
    if cache.type == "boxm2_cache_sptr":
        print("Exporting to oriented point cloud")
        batch.init_process("boxm2ExportOrientedPointCloudProcess")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_string(2, file_out)
        # output aux (prob, vis, normal magnitdue)
        batch.set_input_bool(3, save_aux)
        batch.set_input_float(4, vis_thresh)  # vis threshold
        batch.set_input_float(5, nmag_thresh)  # nmag threshold
        batch.set_input_float(6, prob_thresh)  # prob threshold
        # batch.set_input_float(7,exp_thresh); #exp threshold
        # batch.set_input_string(8, bbox_file); #bb filename
        batch.set_input_string(7, bbox_file)  # bb filename
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Exemple #52
0
def gen_point_cloud(scene,
                    cache,
                    filename,
                    thresh=0.3,
                    vis_thresh=0.5,
                    depth=3):
    batch.init_process("boxm2ExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, thresh)  # prob threshold
    batch.set_input_unsigned(3, depth)  # prob threshold
    batch.run_process()

    batch.init_process("boxm2ExportOrientedPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, filename)
    batch.set_input_float(4, vis_thresh)
    batch.set_input_float(6, thresh)
    batch.run_process()
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)
Exemple #54
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)
Exemple #55
0
def update_multi(scene,
                 mcache,
                 cam,
                 img,
                 ident="",
                 update_alpha=True,
                 var=-1.0,
                 update_app=True,
                 tnear=100000.0,
                 tfar=0.000001):
    # If no device is passed in, do cpu update
    print("boxm2_batch multi GPU update")
    batch.init_process("boxm2MultiUpdateProcess")
    batch.set_input_from_db(0, mcache)
    batch.set_input_from_db(1, scene)
    batch.set_input_from_db(2, cam)
    batch.set_input_from_db(3, img)
    batch.set_input_string(4, ident)
    batch.set_input_bool(5, update_alpha)
    batch.set_input_float(6, var)
    batch.set_input_bool(7, update_app)
    batch.set_input_float(8, tnear)
    batch.set_input_float(9, tfar)
    return batch.run_process()
def writeSceneFromBox(data_path, resolution, min_pt, max_pt, ntrees_x=64,ntrees_y=64,ntrees_z=64, max_num_lvls=4, appearance_model1 = "boxm2_mog3_grey", appearance_model2 = "boxm2_num_obs", appearance_model3 = "boxm2_sum_log_msg_pos", p_init=0.001,max_data_size=1500.0):
    """A function that takes the minimum and maximum points of a bounding box for the scene in real world coordinates
    and partitions the space into the appropriate number of boxes given a user specified number of trees.

    min_pt              : A python list specifying the 3d position of the minimum corner of the box.
                             This is interpreted by boxm2 as the 3d origin of the scene.
    max-pt              : A python list specifying the 3d position of the maximum corner of the box.
    ntrees              : Number of trees in all dimensions (the python interface only supports symmetric trees thus far)
    max_num_lvls            : Maximum number of levels in the trees (a tree will have pow(2,max_num_lvls-1) possible cells)
    appearance_model     : A string indicating desired appearance model
    occupancy_model      : A string indicating desired occupancy model
    max_data_size        : Maximum Sizer of a block in megabytes. Determined by GPU memory. Recomment 650MB for 1GB card and 1.1GB for 1.5GM card
    maximum_data_size    : Maximum memory allowable for a superblock. The max_data_size is determined by GPU memory size.
                             For a 1 GB card, a maximum data size of 650MB is recommended.
                             For a 1.5GB card, a 1.1G maximum data size of 1.1GB is recommended.
    p_init               : Initial occupancy probability."""


    boxm2_batch.register_processes();
    boxm2_batch.register_datatypes();

    tree_size=resolution*pow(2,max_num_lvls-1);

    block_size_x=ntrees_x*tree_size;
    block_size_y=ntrees_y*tree_size;
    block_size_z=ntrees_z*tree_size;

    xsize=max_pt[0]-min_pt[0];
    ysize=max_pt[1]-min_pt[1];
    zsize=max_pt[2]-min_pt[2];

    print "zsize: %f" % zsize
    print "block size: %f" % block_size_z

    nblocks_x=int(round(xsize/block_size_x));
    nblocks_y=int(round(ysize/block_size_y));
    nblocks_z=int(round(zsize/block_size_z));
    print "nblocks_z : %f" % nblocks_z

    if(nblocks_x<=0):nblocks_x=1;
    if(nblocks_y<=0):nblocks_y=1;
    if(nblocks_z<=0):nblocks_z=1;

    print '\t Number of blocks in the x dimension: %d' % nblocks_x
    print '\t Number of blocks in the y dimension: %d' % nblocks_y
    print '\t Number of blocks in the z dimension: %d' % nblocks_z


    print("\t CREATING THE BOXM2_SCENE_SPTR")
    boxm2_batch.init_process("boxm2CreateSceneProcess");
    boxm2_batch.set_input_string(0,data_path);
    boxm2_batch.set_input_string(1,appearance_model1);
    boxm2_batch.set_input_string(2,appearance_model2);
    boxm2_batch.set_input_string(3,appearance_model3);
    boxm2_batch.set_input_float(4,min_pt[0]);
    boxm2_batch.set_input_float(5,min_pt[1]);
    boxm2_batch.set_input_float(6,min_pt[2]);
    boxm2_batch.run_process();
    (id,type)=boxm2_batch.commit_output(0);
    scene=dbvalue(id,type);


    for k in range(nblocks_z):
        for j in range(nblocks_y):
            for i in range(nblocks_x):
                block_origin_x=min_pt[0]+i*block_size_x;
                block_origin_y=min_pt[1]+j*block_size_y;
                block_origin_z=min_pt[2]+k*block_size_z;
                print '\t \t Creating block with id (%d,%d,%d) at origin (%s,%s,%s)' % (i,j,k,block_origin_x, block_origin_y, block_origin_z)
                boxm2_batch.init_process("boxm2AddBlockProcess");
                boxm2_batch.set_input_from_db(0,scene);
                boxm2_batch.set_input_int(1,i);
                boxm2_batch.set_input_int(2,j);
                boxm2_batch.set_input_int(3,k);
                boxm2_batch.set_input_unsigned(4,ntrees_x);
                boxm2_batch.set_input_unsigned(5,ntrees_y);
                boxm2_batch.set_input_unsigned(6,ntrees_z);
                boxm2_batch.set_input_unsigned(7,max_num_lvls);
                boxm2_batch.set_input_float(8,block_origin_x);
                boxm2_batch.set_input_float(9,block_origin_y);
                boxm2_batch.set_input_float(10,block_origin_z);
                boxm2_batch.set_input_float(11,tree_size);
                boxm2_batch.set_input_float(12,max_data_size);
                boxm2_batch.set_input_float(13,p_init);
                boxm2_batch.set_input_unsigned(14,1);
                boxm2_batch.run_process();



    boxm2_batch.init_process("boxm2WriteSceneXMLProcess")
    boxm2_batch.set_input_from_db(0,scene);
    boxm2_batch.set_input_string(1,"scene");
    boxm2_batch.run_process();
Exemple #57
0
def create_kernel_vector(factory_name, dir_type, dim_x, dim_y, dim_z, supp_x,
                         supp_y, supp_z):
    print("Creating Filtering Kernels")
    batch.init_process("bvpl_create_generic_kernel_vector_process")
    batch.set_input_float(0, dim_x)
    batch.set_input_float(1, dim_y)
    batch.set_input_float(2, dim_z)
    batch.set_input_float(3, supp_x)
    batch.set_input_float(4, supp_y)
    batch.set_input_float(5, supp_z)
    batch.set_input_string(6, factory_name)
    batch.set_input_string(7, dir_type)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    filters = dbvalue(id, type)

    return filters
Exemple #58
0
 def transform(self, tx, ty, tz, rx, ry, rz, scale):
     batch.init_process("boxm2TransformModelProcess")
     batch.set_input_from_db(0, self.scene)
     batch.set_input_float(1, tx)
     batch.set_input_float(2, ty)
     batch.set_input_float(3, tz)
     batch.set_input_float(4, rx)
     batch.set_input_float(5, ry)
     batch.set_input_float(6, rz)
     batch.set_input_float(7, scale)
     batch.run_process()
     return