Esempio n. 1
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
Esempio n. 2
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)
Esempio n. 3
0
def paint_mesh(scene, cache, in_file, out_file):
    batch.init_process("boxm2PaintMeshProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, in_file)
    batch.set_input_string(3, out_file)
    batch.run_process()
Esempio n. 4
0
    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()
    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()
Esempio n. 6
0
def import_point_cloud(scene, cache, in_file, min_octree_depth=2):
    batch.init_process("boxm2ImportPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, in_file)
    batch.set_input_unsigned(3, min_octree_depth)
    batch.run_process()
Esempio n. 7
0
def load_mesh(filename):
    batch.init_process("boxm2LoadMeshProcess")
    batch.set_input_string(0, filename)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mesh = dbvalue(id, type)
    return mesh
Esempio n. 8
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()
Esempio n. 9
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()
Esempio n. 10
0
def export_stack(scene, cache, outdir, identifier):
    batch.init_process("boxm2ExportStackImagesProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, outdir)
    batch.set_input_string(3, identifier)
    batch.run_process()
Esempio n. 11
0
def load_mesh(filename):
    batch.init_process("boxm2LoadMeshProcess")
    batch.set_input_string(0, filename)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mesh = dbvalue(id, type)
    return mesh
Esempio n. 12
0
def import_point_cloud(scene, cache, in_file, min_octree_depth=2):
    batch.init_process("boxm2ImportPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, in_file)
    batch.set_input_unsigned(3, min_octree_depth)
    batch.run_process()
Esempio n. 13
0
def paint_mesh(scene, cache, in_file, out_file):
    batch.init_process("boxm2PaintMeshProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, in_file)
    batch.set_input_string(3, out_file)
    batch.run_process()
Esempio n. 14
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)
Esempio n. 15
0
def export_stack(scene, cache, outdir, identifier):
    batch.init_process("boxm2ExportStackImagesProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, outdir)
    batch.set_input_string(3, identifier)
    batch.run_process()
Esempio n. 16
0
def convert_image(img, type="byte"):
    boxm2_batch.init_process("vilConvertPixelTypeProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_string(1, type)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    cimg = dbvalue(id, type)
    return cimg
Esempio n. 17
0
def convert_image(img, type="byte") :
  boxm2_batch.init_process("vilConvertPixelTypeProcess");
  boxm2_batch.set_input_from_db(0, img);
  boxm2_batch.set_input_string(1, type);
  boxm2_batch.run_process();
  (id,type) = boxm2_batch.commit_output(0);
  cimg = dbvalue(id,type);
  return cimg;
Esempio n. 18
0
def binary_img_op(img1, img2, operation="sum"):
  boxm2_batch.init_process("vilBinaryImageOpProcess")
  boxm2_batch.set_input_from_db(0,img1)
  boxm2_batch.set_input_from_db(1,img2)
  boxm2_batch.set_input_string(2,operation)
  boxm2_batch.run_process()
  (id,type) = boxm2_batch.commit_output(0)
  out = dbvalue(id, type);
  return out
Esempio n. 19
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()
Esempio n. 20
0
def compute_dispersion(device, scene, opencl_cache, filename, coordinate_type="Cartesian"):
    print("Fuse two models using Surface Density")
    batch.init_process("boxm2OclComputeExpectationViewDirectionProcess")
    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_string(3, filename)
    batch.set_input_string(4, coordinate_type)
    return batch.run_process()
Esempio n. 21
0
def undistort_image(img, param_file, iters) :
  boxm2_batch.init_process("vilUndistortImageProcess");
  boxm2_batch.set_input_from_db(0,img)
  boxm2_batch.set_input_string(1, param_file);
  boxm2_batch.set_input_int(2, iters);
  boxm2_batch.run_process();
  (o_id,o_type) = boxm2_batch.commit_output(0);
  out_img = dbvalue(o_id,o_type);
  return out_img;
Esempio n. 22
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()
Esempio n. 23
0
def undistort_image(img, param_file, iters):
    boxm2_batch.init_process("vilUndistortImageProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_string(1, param_file)
    boxm2_batch.set_input_int(2, iters)
    boxm2_batch.run_process()
    (o_id, o_type) = boxm2_batch.commit_output(0)
    out_img = dbvalue(o_id, o_type)
    return out_img
Esempio n. 24
0
def arf_stream(file_path):
    boxm2_batch.init_process("bilCreateArfImageIstreamProcess")
    boxm2_batch.set_input_string(0, file_path)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    stream = dbvalue(id, type)
    (id, type) = boxm2_batch.commit_output(1)
    numImgs = boxm2_batch.get_output_int(id)
    return stream, numImgs
Esempio n. 25
0
def binary_img_op(img1, img2, operation="sum"):
    boxm2_batch.init_process("vilBinaryImageOpProcess")
    boxm2_batch.set_input_from_db(0, img1)
    boxm2_batch.set_input_from_db(1, img2)
    boxm2_batch.set_input_string(2, operation)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    out = dbvalue(id, type)
    return out
Esempio n. 26
0
def arf_stream(file_path) :
  boxm2_batch.init_process("bilCreateArfImageIstreamProcess")
  boxm2_batch.set_input_string(0,file_path);
  boxm2_batch.run_process();
  (id, type) = boxm2_batch.commit_output(0);
  stream = dbvalue(id, type);
  (id, type) = boxm2_batch.commit_output(1);
  numImgs = boxm2_batch.get_output_int(id);
  return stream, numImgs
Esempio n. 27
0
def gen_mesh(z_img, x_img, y_img, out_dir):
    batch.init_process("boxm2ExportMeshProcess")
    batch.set_input_from_db(0, z_img)
    batch.set_input_from_db(1, x_img)
    batch.set_input_from_db(2, y_img)
    batch.set_input_string(3, out_dir)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mesh = dbvalue(id, type)
    return mesh
Esempio n. 28
0
 def update_alpha_with_cubic(self, pcam, img):
     """ Update occupancy (alpha) values using the cubic appearances """
     batch.init_process("boxm2OclUpdateAlphaWcubicProcess")
     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, pcam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "cubic_model")
     batch.run_process()
Esempio n. 29
0
 def uncertainty_per_view(self, cam, img, viewNum):
     """Store uncertainty aux data per image for this model """
     batch.init_process("boxm2OclUncertaintyPerImageProcess")
     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, cam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "uncertain_" + "%05d" % viewNum)
     batch.run_process()
Esempio n. 30
0
 def update_alpha_with_cubic(self, pcam, img):
     """ Update occupancy (alpha) values using the cubic appearances """
     batch.init_process("boxm2OclUpdateAlphaWcubicProcess")
     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, pcam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "cubic_model")
     batch.run_process()
Esempio n. 31
0
def gen_mesh(z_img, x_img, y_img, out_dir):
    batch.init_process("boxm2ExportMeshProcess")
    batch.set_input_from_db(0, z_img)
    batch.set_input_from_db(1, x_img)
    batch.set_input_from_db(2, y_img)
    batch.set_input_string(3, out_dir)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mesh = dbvalue(id, type)
    return mesh
Esempio n. 32
0
def resize(img, ni, nj, pixel="float"):
    boxm2_batch.init_process("vilResampleProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_int(1, ni)
    boxm2_batch.set_input_int(2, nj)
    boxm2_batch.set_input_string(3, pixel)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    img = dbvalue(id, type)
    return img
Esempio n. 33
0
 def create_aux_data(self, cam, img, viewNum):
     """ Computes aux for view num (visibility, seg len, app) """
     batch.init_process("boxm2OclUpdateAuxPerViewProcess")
     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, cam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "img_" + "%05d" % viewNum)
     batch.run_process()
Esempio n. 34
0
 def uncertainty_per_view(self, cam, img, viewNum):
     """Store uncertainty aux data per image for this model """
     batch.init_process("boxm2OclUncertaintyPerImageProcess")
     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, cam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "uncertain_" + "%05d" % viewNum)
     batch.run_process()
Esempio n. 35
0
def resize(img, ni, nj, pixel="float"):
    boxm2_batch.init_process("vilResampleProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_int(1, ni)
    boxm2_batch.set_input_int(2, nj)
    boxm2_batch.set_input_string(3, pixel);
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    img = dbvalue(id,type)
    return img
Esempio n. 36
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
Esempio n. 37
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
Esempio n. 38
0
 def create_aux_data(self, cam, img, viewNum):
     """ Computes aux for view num (visibility, seg len, app) """
     batch.init_process("boxm2OclUpdateAuxPerViewProcess")
     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, cam)
     batch.set_input_from_db(4, img)
     batch.set_input_string(5, "img_" + "%05d" % viewNum)
     batch.run_process()
Esempio n. 39
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()
Esempio n. 40
0
def update_PusingQ(scene, device, opencl_cache, operation=2, view_ident=""):
    #print("Init Manager");
    batch.init_process("boxm2OclUpdateUsingQProcess")
    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_int(3, operation)
    batch.set_input_string(4, view_ident)
    status = batch.run_process()
    if(status != True):
        print "Error in Running Aux Q "
Esempio n. 41
0
def grey_to_rgb(img, color_txt):
  boxm2_batch.init_process("vilGreyToRGBProcess")
  boxm2_batch.set_input_from_db(0,img)
  boxm2_batch.set_input_string(1,color_txt)
  result = boxm2_batch.run_process()
  if result:
    (id, type) = boxm2_batch.commit_output(0)
    outimg = dbvalue(id, type);
  else:
    outimg = 0
  return outimg
Esempio n. 42
0
def grey_to_rgb(img, color_txt):
    boxm2_batch.init_process("vilGreyToRGBProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_string(1, color_txt)
    result = boxm2_batch.run_process()
    if result:
        (id, type) = boxm2_batch.commit_output(0)
        outimg = dbvalue(id, type)
    else:
        outimg = 0
    return outimg
Esempio n. 43
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()
Esempio n. 44
0
def bae_raw_stream(file_path, ni=0, nj=0, pixelsize=0):
    boxm2_batch.init_process("bilCreateRawImageIstreamProcess")
    boxm2_batch.set_input_string(0, file_path)
    boxm2_batch.set_input_int(1, ni)
    boxm2_batch.set_input_int(2, nj)
    boxm2_batch.set_input_int(3, pixelsize)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    stream = dbvalue(id, type)
    (id, type) = boxm2_batch.commit_output(1)
    numImgs = boxm2_batch.get_output_int(id)
    return stream, numImgs
Esempio n. 45
0
def create_coarse_model(scene, cache, device, model_dir):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Create a Coarser Scene")
        batch.init_process("boxm2OclCreateCoarserSceneProcess")
        batch.set_input_from_db(0, device)
        batch.set_input_from_db(1, scene)
        batch.set_input_from_db(2, cache)
        batch.set_input_string(3, model_dir)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Esempio n. 46
0
def create_coarse_model(scene, cache, device, model_dir):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Create a Coarser Scene")
        batch.init_process("boxm2OclCreateCoarserSceneProcess")
        batch.set_input_from_db(0, device)
        batch.set_input_from_db(1, scene)
        batch.set_input_from_db(2, cache)
        batch.set_input_string(3, model_dir)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Esempio n. 47
0
def bae_raw_stream(file_path,ni=0,nj=0,pixelsize=0) :
  boxm2_batch.init_process("bilCreateRawImageIstreamProcess")
  boxm2_batch.set_input_string(0,file_path);
  boxm2_batch.set_input_int(1,ni);
  boxm2_batch.set_input_int(2,nj);
  boxm2_batch.set_input_int(3,pixelsize);
  boxm2_batch.run_process();
  (id, type) = boxm2_batch.commit_output(0);
  stream = dbvalue(id, type);
  (id, type) = boxm2_batch.commit_output(1);
  numImgs = boxm2_batch.get_output_int(id);
  return stream, numImgs
Esempio n. 48
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()
Esempio n. 49
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()
Esempio n. 50
0
 def create_view_directions(self, cam, ni, nj, viewNum):
     """ Create aux data for direction """
     batch.init_process("boxm2OclAuxUpdateViewDirectionProcess")
     batch.set_input_from_db(0, self.device)
     batch.set_input_from_db(1, self.scene)
     batch.set_input_from_db(2, self.cpu_cache)
     batch.set_input_from_db(3, self.opencl_cache)
     batch.set_input_from_db(4, cam)
     batch.set_input_unsigned(5, ni)
     batch.set_input_unsigned(6, nj)
     batch.set_input_string(7, "viewdir_" + "%05d" % viewNum)
     batch.set_input_string(8, "cartesian")
     batch.run_process()
Esempio n. 51
0
    def batch_uncertainty(self, image_id_fname):
        """Calculate voxel uncertainty"""
        # write image identifiers to file

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2OclBatchUncertaintyProcess")
        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.run_process()
        self.write_cache(True)
Esempio n. 52
0
    def batch_uncertainty(self, image_id_fname):
        """Calculate voxel uncertainty"""
        # write image identifiers to file

        # open the stream cache, this is a read-only cache
        batch.init_process("boxm2OclBatchUncertaintyProcess")
        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.run_process()
        self.write_cache(True)
Esempio n. 53
0
 def create_view_directions(self, cam, ni, nj, viewNum):
     """ Create aux data for direction """
     batch.init_process("boxm2OclAuxUpdateViewDirectionProcess")
     batch.set_input_from_db(0, self.device)
     batch.set_input_from_db(1, self.scene)
     batch.set_input_from_db(2, self.cpu_cache)
     batch.set_input_from_db(3, self.opencl_cache)
     batch.set_input_from_db(4, cam)
     batch.set_input_unsigned(5, ni)
     batch.set_input_unsigned(6, nj)
     batch.set_input_string(7, "viewdir_" + "%05d" % viewNum)
     batch.set_input_string(8, "cartesian")
     batch.run_process()
Esempio n. 54
0
def add_aux_info_to_ply(scene, cache, file_in, file_out):
    if cache.type == "boxm2_cache_sptr":
        print("Adding aux info to ply points")
        batch.init_process("boxm2_add_aux_info_to_ply_process")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_string(2, file_in)
        # output aux (prob, vis, normal magnitdue)
        batch.set_input_string(3, file_out)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Esempio n. 55
0
def update_auxQ(scene, device, opencl_cache, cam, img, ident="", view_ident=""):
    #print("Init Manager");
    batch.init_process("boxm2OclUpdateAuxQPerViewProcess")
    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_from_db(4, img)
    batch.set_input_string(5, ident)
    batch.set_input_string(6, view_ident)
    status = batch.run_process()
    if(status != True):
        print "Error in Running Aux Q "
Esempio n. 56
0
def add_aux_info_to_ply(scene, cache, file_in, file_out):
    if cache.type == "boxm2_cache_sptr":
        print("Adding aux info to ply points")
        batch.init_process("boxm2_add_aux_info_to_ply_process")
        batch.set_input_from_db(0, scene)
        batch.set_input_from_db(1, cache)
        batch.set_input_string(2, file_in)
        # output aux (prob, vis, normal magnitdue)
        batch.set_input_string(3, file_out)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Esempio n. 57
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;