예제 #1
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 = splitext(img)
            bname = 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("bstmCreateStreamCacheProcess")
        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 = batch.dbvalue(cache_id, cache_type)
예제 #2
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def load_scene(scene_str):
    # print("Loading a Scene from file: ", scene_str);
    batch.init_process("bstmLoadSceneProcess")
    batch.set_input_string(0, scene_str)
    batch.run_process()
    (scene_id, scene_type) = batch.commit_output(0)
    scene = dbvalue(scene_id, scene_type)
    return scene
예제 #3
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def load_cpp(scene_str):
    scene = load_scene(scene_str)
    batch.init_process("bstmCreateCacheProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_string(1, "lru")
    batch.run_process()
    (id, type) = batch.commit_output(0)
    cache = bstm_register.dbvalue(id, type)
    return scene, cache
예제 #4
0
def boxm2_load_scene(scene_str):
    # print("Loading a Scene from file: ", scene_str);
    batch.init_process("boxm2LoadSceneProcess")
    batch.set_input_string(0, scene_str)
    status = batch.run_process()
    if status:
        (scene_id, scene_type) = batch.commit_output(0)
        scene = dbvalue(scene_id, scene_type)
        return scene
    else:
        raise Exception('Could not load scene file')
예제 #5
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 = batch.dvalue(id, type)

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

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

            # create norm intensity (num rays...)
            batch.init_process("bstmCppCreateNormIntensitiesProcess")
            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("bstmCppCreateAuxDataOPT2Process")
            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("bstmCppBatchUpdateOPT2Process")
        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("bstmStreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()

        self.write_cache()
예제 #6
0
    def cpu_batch_compute_normal_albedo(
            self, metadata_filename_list, atmospheric_params_filename_list):
        batch.init_process("bstmCppBatchComputeNormalAlbedoProcess")
        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_string(3, metadata_filename_list)
        batch.set_input_string(4, atmospheric_params_filename_list)
        batch.run_process()

        # close the files so that they can be reloaded after the next iteration
        batch.init_process("bstmStreamCacheCloseFilesProcess")
        batch.set_input_from_db(0, self.str_cache)
        batch.run_process()
예제 #7
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def export_pt_cloud(scene, cache, output_filename, prob_t, time, output_aux=True):
    batch.init_process("bstmCppExtractPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_float(2, prob_t)
    batch.set_input_float(3, time)
    batch.run_process()

    batch.init_process("bstmCppExportPointCloudProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.set_input_string(2, output_filename)
    batch.set_input_bool(3, output_aux)
    batch.set_input_float(4, time)

    batch.run_process()
    return
예제 #8
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def change_detect(scene, device, cache, cam, img, time,
                  mask_img=None, raybelief="", max_mode=False):
    batch.init_process("bstmOclChangeDetectionProcess")
    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, cam)
    batch.set_input_from_db(4, img)
    batch.set_input_from_db(5, mask_img)
    batch.set_input_string(6, raybelief)
    batch.set_input_bool(7, max_mode)
    batch.set_input_float(8, time)

    batch.run_process()
    (id, type) = batch.commit_output(0)
    cd_img = dbvalue(id, type)
    return cd_img
예제 #9
0
def boxm2_load_opencl(scene_str, device_string="gpu"):
    scene = boxm2_load_scene(scene_str)

    ###############################################################
    # Create cache, opencl manager, device, and gpu cache
    ###############################################################
    # print("Create Main Cache");
    batch.init_process("boxm2CreateCacheProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_string(1, "lru")
    result = batch.run_process()
    if not result:
        raise Exception('boxm2CreateCacheProcess returned false')
    (id, type) = batch.commit_output(0)
    cache = dbvalue(id, type)

    # print("Init Manager");
    batch.init_process("boclInitManagerProcess")
    result = batch.run_process()
    if not result:
        raise Exception('boxm2InitManagerProcess returned false')

    # print("Get Gpu Device");
    batch.init_process("boclGetDeviceProcess")
    batch.set_input_string(0, device_string)
    result = batch.run_process()
    if not result:
        raise Exception('boclGetDeviceProcess returned false')
    (id, type) = batch.commit_output(0)
    device = dbvalue(id, type)

    # print("Create Gpu Cache");
    batch.init_process("boxm2CreateOpenclCacheProcess")
    batch.set_input_from_db(0, device)
    result = batch.run_process()
    if not result:
        raise Exception('boxm2CreateOpenclCacheProcess returned false')
    (id, type) = batch.commit_output(0)
    openclcache = dbvalue(id, type)

    return scene, cache, device, openclcache
예제 #10
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def bundle2scene(bundle_file, img_dir, app_model="bstm_mog3_grey",
                 isalign=True, out_dir="", timeSteps=32):
    if app_model == "bstm_mog3_grey":
        nobs_model = "bstm_num_obs"
    else:
        print "ERROR appearance model not recognized!!!", app_model
        return

    # run process
    batch.init_process("bstmBundleToSceneProcess")
    batch.set_input_string(0, bundle_file)
    batch.set_input_string(1, img_dir)
    batch.set_input_string(2, app_model)
    batch.set_input_string(3, nobs_model)
    batch.set_input_bool(4, isalign)
    batch.set_input_unsigned(5, timeSteps)
    batch.set_input_string(6, out_dir)
    batch.run_process()
    (scene_id, scene_type) = batch.commit_output(0)
    uscene = dbvalue(scene_id, scene_type)
    return uscene
예제 #11
0
def boxm2_render_grey_view_dep(scene,
                               cache,
                               cam,
                               ni=1280,
                               nj=720,
                               device=None,
                               ident_string=""):
    if cache.type == "boxm2_opencl_cache_sptr" and device:
        batch.init_process("boxm2OclRenderViewDepExpectedImageProcess")
        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, cam)
        batch.set_input_unsigned(4, ni)
        batch.set_input_unsigned(5, nj)
        batch.set_input_string(6, ident_string)
        batch.run_process()
        (id, type) = batch.commit_output(0)
        exp_image = dbvalue(id, type)
        return exp_image
    else:
        print "ERROR: Cache type not recognized: ", cache.type
예제 #12
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def load_opencl(scene_str, device_string="gpu"):
    scene = load_scene(scene_str)

    ###############################################################
    # Create cache, opencl manager, device, and gpu cache
    ###############################################################
    # print("Create Main Cache");
    batch.init_process("bstmCreateCacheProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_string(1, "lru")
    batch.run_process()
    (id, type) = batch.commit_output(0)
    cache = dbvalue(id, type)

    # print("Init Manager");
    batch.init_process("boclInitManagerProcess")
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mgr = dbvalue(id, type)

    # print("Get Gpu Device");
    batch.init_process("boclGetDeviceProcess")
    batch.set_input_string(0, device_string)
    batch.set_input_from_db(1, mgr)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    device = dbvalue(id, type)

    # print("Create Gpu Cache");
    batch.init_process("bstmOclCreateCacheProcess")
    batch.set_input_from_db(0, device)
    batch.set_input_from_db(1, scene)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    openclcache = dbvalue(id, type)

    return scene, cache, mgr, device, openclcache
예제 #13
0
 def ocl_batch_compute_normal_albedo(
         self, img_id_list, metadata_filename_list, atmospheric_params_filename_list):
     batch.init_process(
         "bstmOclBatchComputeNormalAlbedoArrayProcess")
     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_string(3, img_id_list)
     batch.set_input_string(4, metadata_filename_list)
     batch.set_input_string(5, atmospheric_params_filename_list)
     batch.run_process()
예제 #14
0
파일: bstm_adaptor.py 프로젝트: yochju/vxl
def boxm22scene(boxm2_filename, bstm_datapath, timeSteps=32):
    batch.init_process("bstmBoxm2SceneToBstmProcess")
    batch.set_input_string(0, boxm2_filename)
    batch.set_input_string(1, bstm_datapath)
    batch.set_input_unsigned(2, timeSteps)
    batch.run_process()