Ejemplo n.º 1
0
def read_CLIF07(indir,outdir,camnum,datatype="CLIF06") :
  boxm2_batch.init_process("bilReadCLIF07DataProcess")
  boxm2_batch.set_input_string(0,indir);
  boxm2_batch.set_input_string(1,outdir);
  boxm2_batch.set_input_int(2,camnum);
  boxm2_batch.set_input_string(3,datatype);
  boxm2_batch.run_process();
Ejemplo n.º 2
0
def read_CLIF07(indir, outdir, camnum, datatype="CLIF06"):
    boxm2_batch.init_process("bilReadCLIF07DataProcess")
    boxm2_batch.set_input_string(0, indir)
    boxm2_batch.set_input_string(1, outdir)
    boxm2_batch.set_input_int(2, camnum)
    boxm2_batch.set_input_string(3, datatype)
    boxm2_batch.run_process()
Ejemplo n.º 3
0
def median_filter_image(img, neighborhood_radius):
    boxm2_batch.init_process("vilMedianFilterProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_int(1, neighborhood_radius)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    filt_img = dbvalue(id, type)
    return filt_img
Ejemplo n.º 4
0
def median_filter_image(img, neighborhood_radius):
    boxm2_batch.init_process("vilMedianFilterProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_int(1,neighborhood_radius)
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    filt_img = dbvalue(id,type)
    return filt_img
Ejemplo n.º 5
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
Ejemplo n.º 6
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;
Ejemplo n.º 7
0
def pixel(img, point):
    boxm2_batch.init_process("vilPixelValueProcess")
    boxm2_batch.set_input_from_db(0,img)
    boxm2_batch.set_input_int(1, int(point[0]))
    boxm2_batch.set_input_int(2, int(point[1]))
    boxm2_batch.run_process()
    (id,type) = boxm2_batch.commit_output(0)
    val = boxm2_batch.get_output_float(id)
    return val
Ejemplo n.º 8
0
def pixel(img, point):
    boxm2_batch.init_process("vilPixelValueProcess")
    boxm2_batch.set_input_from_db(0, img)
    boxm2_batch.set_input_int(1, int(point[0]))
    boxm2_batch.set_input_int(2, int(point[1]))
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    val = boxm2_batch.get_output_float(id)
    return val
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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 "
Ejemplo n.º 12
0
def filter_scene_data(scene, cache, device, filters, filter_idx):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Filtering Scene Data")
        batch.init_process("boxm2_ocl_filter_scene_data_process")
        batch.set_input_from_db(0, device)
        batch.set_input_from_db(1, scene)
        batch.set_input_from_db(2, cache)
        batch.set_input_from_db(3, filters)
        batch.set_input_int(4, filter_idx)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Ejemplo n.º 13
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;
Ejemplo n.º 14
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
Ejemplo n.º 15
0
def load_multi_cache(scene, numdevices=1):
    ###############################################################
    # Create multi cache, opencl manager, device, and gpu cache
    ###############################################################
    #print("Create Main Cache");
    batch.init_process("boxm2CreateMultiCacheProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_int(1, numdevices)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mcache = dbvalue(id, type)

    return mcache
Ejemplo n.º 16
0
def load_multi_cache(scene, numdevices=1):
    ###############################################################
    # Create multi cache, opencl manager, device, and gpu cache
    ###############################################################
    #print("Create Main Cache");
    batch.init_process("boxm2CreateMultiCacheProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_int(1, numdevices)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mcache = dbvalue(id, type)

    return mcache
Ejemplo n.º 17
0
def filter_scene_data(scene, cache, device, filters, filter_idx):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Filtering Scene Data")
        batch.init_process("boxm2_ocl_filter_scene_data_process")
        batch.set_input_from_db(0, device)
        batch.set_input_from_db(1, scene)
        batch.set_input_from_db(2, cache)
        batch.set_input_from_db(3, filters)
        batch.set_input_int(4, filter_idx)
        return batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
    def createScene(self, stepNum):

        bundleFile = os.path.abspath(self.config.NVMFileName)
        imgDir = os.path.abspath(self.config.SRCImageDirName)
        outDir = os.path.abspath(self.config.NVMOutputDirName)

        if False == os.path.isfile(bundleFile):
            log("Step %d - SceneCreation cannot begin because the NVM file %s is missing." %
                (stepNum, bundleFile))
            log("Processing will not proceed.")
            return -stepNum

        if False == os.path.isdir(imgDir):
            log("Step %d - SceneCreation cannot beging because the image directory %s cannot be found." %
                (stepNum, imgDir))
            log("Processing will not proceed.")
            return -stepNum

        log("Creating scene with bundleFile %s." % (bundleFile))
        log("Output will be written to %s." % (outDir))

        boxm2_batch.not_verbose()
        boxm2_batch.register_processes()
        boxm2_batch.register_datatypes()

        # class used for python/c++ pointers in database
        class dbvalue:

            def __init__(self, index, type):
                self.id = index    # unsigned integer
                self.type = type   # string

        # run process
        boxm2_batch.init_process("boxm2BundleToSceneProcess")
        boxm2_batch.set_input_string(0, bundleFile)
        boxm2_batch.set_input_string(1, imgDir)
        boxm2_batch.set_input_string(2, self.config.NVMAppModel)
        boxm2_batch.set_input_string(3, self.config.NVMNobsModel)
        boxm2_batch.set_input_int(4, 8)
        boxm2_batch.set_input_string(5, outDir)
        boxm2_batch.run_process()
        (scene_id, scene_type) = boxm2_batch.commit_output(0)
        uscene = dbvalue(scene_id, scene_type)
        (scene_id, scene_type) = boxm2_batch.commit_output(1)
        rscene = dbvalue(scene_id, scene_type)

        return 0
Ejemplo n.º 21
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
Ejemplo n.º 22
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
Ejemplo n.º 23
0
    def createScene(self, stepNum):

        bundleFile = os.path.abspath(self.config.NVMFileName)
        imgDir = os.path.abspath(self.config.SRCImageDirName)
        outDir = os.path.abspath(self.config.NVMOutputDirName)

        if False == os.path.isfile(bundleFile):
            log("Step %d - SceneCreation cannot begin because the NVM file %s is missing."
                % (stepNum, bundleFile))
            log("Processing will not proceed.")
            return -stepNum

        if False == os.path.isdir(imgDir):
            log("Step %d - SceneCreation cannot beging because the image directory %s cannot be found."
                % (stepNum, imgDir))
            log("Processing will not proceed.")
            return -stepNum

        log("Creating scene with bundleFile %s." % (bundleFile))
        log("Output will be written to %s." % (outDir))

        # run process
        batch.init_process("boxm2BundleToSceneProcess")
        batch.set_input_string(0, bundleFile)
        batch.set_input_string(1, imgDir)
        batch.set_input_string(2, self.config.NVMAppModel)
        batch.set_input_string(3, self.config.NVMNobsModel)
        batch.set_input_int(4, 8)
        batch.set_input_string(5, outDir)
        batch.run_process()
        (scene_id, scene_type) = batch.commit_output(0)
        uscene = dbvalue(scene_id, scene_type)
        (scene_id, scene_type) = batch.commit_output(1)
        rscene = dbvalue(scene_id, scene_type)

        return 0
Ejemplo n.º 24
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
Ejemplo n.º 25
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
Ejemplo n.º 26
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
Ejemplo n.º 27
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
Ejemplo n.º 28
0
import os
import shutil
import time
import sys


class dbvalue:

    def __init__(self, index, type):
        self.id = index    # unsigned integer
        self.type = type   # string

print "create FS"
boxm2_batch.init_process("bhdfsCreateFSManagerProcess")
boxm2_batch.set_input_string(0, "default")
boxm2_batch.set_input_int(1, 0)
boxm2_batch.run_process()

file_list = glob.glob(sys.argv[1] + "/*" + sys.argv[2])

boxm2_batch.init_process("bhdfsCreateDirProcess")
boxm2_batch.set_input_string(0, sys.argv[3])
statuscode = boxm2_batch.run_process()
if statuscode != 1:
    print "Unable to create folder: " + sys.argv[3] + " on HDFS, exiting!\n"
    sys.exit(0)

for fname in file_list:
    print fname
    boxm2_batch.init_process("bhdfsCopyFileProcess")
    boxm2_batch.set_input_string(0, fname)
Ejemplo n.º 29
0
import os
import shutil
import time
import sys


class dbvalue:
    def __init__(self, index, type):
        self.id = index  # unsigned integer
        self.type = type  # string


print "create FS"
boxm2_batch.init_process("bhdfsCreateFSManagerProcess")
boxm2_batch.set_input_string(0, "default")
boxm2_batch.set_input_int(1, 0)
boxm2_batch.run_process()

boxm2_batch.init_process("bbasStringArrayProcess")
boxm2_batch.set_input_string(0, sys.argv[2])
boxm2_batch.run_process()
boxm2_batch.set_input_string(0, sys.argv[3])
boxm2_batch.run_process()
boxm2_batch.finish_process()
(arr_id, arr_type) = boxm2_batch.commit_output(0)
arr = dbvalue(arr_id, arr_type)

# generate an input file on the output hdfs folder, this file will be streamed to mapper processes
# a vector of strings are inputted which will be used to form globs to retrieve file names
# the output file will have <name1> <name2> ... <name n> names on each line depending on this vector's size
boxm2_batch.init_process("bhdfsGenerateStdInFileProcess")
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();
Ejemplo n.º 31
0
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()
Ejemplo n.º 32
0
import glob
import random
import math
import os
import shutil
import time
import sys

import brl_init
import boxm2_batch as batch
dbvalue = brl_init.register_batch(batch)

print "create FS"
batch.init_process("bhdfsCreateFSManagerProcess")
batch.set_input_string(0, "default")
batch.set_input_int(1, 0)
batch.run_process()

batch.init_process("bbasStringArrayProcess")
batch.set_input_string(0, sys.argv[2])
batch.run_process()
batch.set_input_string(0, sys.argv[3])
batch.run_process()
batch.finish_process()
(arr_id, arr_type) = batch.commit_output(0)
arr = dbvalue(arr_id, arr_type)

# generate an input file on the output hdfs folder, this file will be streamed to mapper processes
# a vector of strings are inputted which will be used to form globs to retrieve file names
# the output file will have <name1> <name2> ... <name n> names on each
# line depending on this vector's size
Ejemplo n.º 33
0
import math
import os
import shutil
import time
import sys

import brl_init
import boxm2_batch as batch
dbvalue = brl_init.register_batch(batch)

mytime = time.clock()

print "create FS"
batch.init_process("bhdfsCreateFSManagerProcess")
batch.set_input_string(0, "default")
batch.set_input_int(1, 0)
batch.run_process()

# read the hadoop output folder from the configuration file
f = open("conf_mapper.txt", 'r')
dir_names = f.readlines()
f.close()
output_path = dir_names[0].strip()
print output_path
exh_search_rad = int(dir_names[1].strip())
print exh_search_rad

for line in sys.stdin:
    line = line.strip()
    words = line.split()
    print words[0]