Esempio n. 1
0
def trajectory_next(trajectory):
    batch.init_process("bstmViewTrajectoryNextProcess")
    batch.set_input_from_db(0, trajectory)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    cam = dbvalue(id, type)
    return cam
Esempio n. 2
0
def merge(scene, cpu_cache, p_threshold, time):
    batch.init_process("bstmCppMergeTTProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpu_cache)
    batch.set_input_float(2, p_threshold)
    batch.set_input_float(3, time)
    batch.run_process()
Esempio n. 3
0
def refine_time(scene, cpu_cache, change_prob_t, time):
    batch.init_process("bstmCppRefineTTProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpu_cache)
    batch.set_input_float(2, change_prob_t)
    batch.set_input_float(3, time)
    batch.run_process()
Esempio n. 4
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)
Esempio n. 5
0
def remove_from_db(dbvals):
    if not isinstance(dbvals, (list, tuple)):
        dbvals = [dbvals]
    for dbval in dbvals:
        batch.init_process("bbasRemoveFromDbProcess")
        batch.set_input_unsigned(0, dbval.id)
        batch.run_process()
Esempio n. 6
0
def refine(scene, cpu_cache, p_threshold, time):
    batch.init_process("bstmCppRefineSpacetimeProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpu_cache)
    batch.set_input_float(2, p_threshold)
    batch.set_input_float(3, time)
    batch.run_process()
Esempio n. 7
0
def change_btw_frames(scene, cpu_cache, time0, time1):
    batch.init_process("bstmCppChangeBtwFramesProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cpu_cache)
    batch.set_input_float(2, time0)
    batch.set_input_float(3, time1)
    batch.run_process()
Esempio n. 8
0
def trajectory_size(trajectory):
    batch.init_process("bstmViewTrajectorySizeProcess")
    batch.set_input_from_db(0, trajectory)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    size = batch.get_output_unsigned(id)
    batch.remove_data(id)
    return size
Esempio n. 9
0
def write_cache(cache, do_clear=0):
    if cache.type == "bstm_cache_sptr":
        batch.init_process("bstmWriteCacheProcess")
        batch.set_input_from_db(0, cache)
        batch.set_input_bool(1, do_clear)
        batch.run_process()
    else:
        print "ERROR: Cache type needs to be bstm_cache_sptr, not ", cache.type
Esempio n. 10
0
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
Esempio n. 11
0
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
Esempio n. 12
0
def ocl_info():
    # print("Init Manager");
    batch.init_process("boclInitManagerProcess")
    batch.run_process()
    (id, type) = batch.commit_output(0)
    mgr = dbvalue(id, type)

    print("Get OCL info")
    batch.init_process("bocl_info_process")
    batch.set_input_from_db(0, mgr)
    batch.run_process()
Esempio n. 13
0
def boxm2_clear_cache(cache):
    if cache.type == "boxm2_cache_sptr":
        batch.init_process("boxm2ClearCacheProcess")
        batch.set_input_from_db(0, cache)
        batch.run_process()
    elif cache.type == "boxm2_opencl_cache_sptr":
        batch.init_process("boxm2ClearOpenclCacheProcess")
        batch.set_input_from_db(0, cache)
        batch.run_process()
    else:
        print "ERROR: Cache type needs to be boxm2_cache_sptr, not ", cache.type
Esempio n. 14
0
def clear_cache(cache):
    if cache.type == "bstm_cache_sptr":
        batch.init_process("bstmClearCacheProcess")
        batch.set_input_from_db(0, cache)
        batch.run_process()
    elif cache.type == "bstm_opencl_cache_sptr":
        batch.init_process("bstmOclClearCacheProcess")
        batch.set_input_from_db(0, cache)
        batch.run_process()
    else:
        print "ERROR: Cache type needs to be bstm_cache_sptr, not ", cache.type
Esempio n. 15
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()
Esempio n. 16
0
def label_change(scene, device, cache, cam, change_img, change_t, label, time):
    batch.init_process("bstmOclLabelRayProcess")
    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, change_img)
    batch.set_input_float(5, change_t)
    batch.set_input_float(6, time)
    batch.set_input_int(7, label)
    batch.run_process()
Esempio n. 17
0
def init_trajectory(scene, startInc, endInc, radius, ni=1280, nj=720):
    batch.init_process("bstmViewInitTrajectoryProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_double(1, float(startInc))  # incline0
    batch.set_input_double(2, float(endInc))  # incline1
    batch.set_input_double(3, float(radius))  # radius
    batch.set_input_unsigned(4, ni)  # ni
    batch.set_input_unsigned(5, nj)  # nj
    batch.run_process()
    (id, type) = batch.commit_output(0)
    trajectory = dbvalue(id, type)
    return trajectory
Esempio n. 18
0
def scene_statistics(scene, cache):
    batch.init_process("bstmSceneStatisticsProcess")
    batch.set_input_from_db(0, scene)
    batch.set_input_from_db(1, cache)
    batch.run_process()
    (s1_id, s1_type) = batch.commit_output(0)
    (s2_id, s2_type) = batch.commit_output(1)
    (s3_id, s3_type) = batch.commit_output(2)
    s1 = batch.get_output_float(s1_id)
    s2 = batch.get_output_float(s2_id)
    s3 = batch.get_output_unsigned(s3_id)
    return [s1, s2, s3]
Esempio n. 19
0
 def transform(self, tx, ty, tz, rx, ry, rz, scale):
     batch.init_process("bstmTransformModelProcess")
     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
Esempio n. 20
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()
Esempio n. 21
0
def scene_bbox(scene):
    batch.init_process("bstmSceneBboxProcess")
    batch.set_input_from_db(0, scene)
    batch.run_process()
    out = []
    for outIdx in range(6):
        (id, type) = batch.commit_output(outIdx)
        pt = batch.get_output_double(id)
        batch.remove_data(id)
        out.append(pt)
    minPt = (out[0], out[1], out[2])
    maxPt = (out[3], out[4], out[5])
    return (minPt, maxPt)
Esempio n. 22
0
def update_change(scene, device, cache, cam, img, time, mask_img=None):
    batch.init_process("bstmOclUpdateChangeProcess")
    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_float(6, time)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    cd_img = dbvalue(id, type)
    return cd_img
Esempio n. 23
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()
Esempio n. 24
0
def update_color(scene, device, cache, cam, img, time, mog_var=-1,
                 mask_img=None, update_alpha=True, update_changes_only=False):
    batch.init_process("bstmOclUpdateColorProcess")
    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_float(5, time)
    batch.set_input_float(6, mog_var)
    batch.set_input_from_db(7, mask_img)
    batch.set_input_bool(8, update_alpha)
    batch.set_input_bool(9, update_changes_only)
    batch.run_process()
Esempio n. 25
0
 def render_expected_albedo_normal(self, camera, ni, nj):
     batch.init_process("bstmOclRenderExpectedAlbedoNormalProcess")
     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, camera)
     batch.set_input_unsigned(4, ni)
     batch.set_input_unsigned(5, nj)
     batch.run_process()
     (id, type) = batch.commit_output(0)
     exp_albedo = batch.dvalue(id, type)
     (id, type) = batch.commit_output(1)
     exp_normal = batch.dvalue(id, type)
     (id, type) = batch.commit_output(2)
     mask_image = batch.dvalue(id, type)
     return(exp_albedo, exp_normal, mask_image)
Esempio n. 26
0
    def transform_to_scene(self, to_scene, trans, rot, scale):
        if self.opencl_cache.type == "bstm_opencl_cache_sptr":
            print("transforming scene")
            batch.init_process("bstmVecfOclTransformSceneProcess")
            batch.set_input_from_db(0, self.scene)
            batch.set_input_from_db(1, to_scene)
            batch.set_input_from_db(2, self.opencl_cache)
            batch.set_input_double(3, trans[0])
            batch.set_input_double(4, trans[1])
            batch.set_input_double(5, trans[2])
            batch.set_input_double(6, rot[0][0])
            batch.set_input_double(7, rot[0][1])
            batch.set_input_double(8, rot[0][2])
            batch.set_input_double(9, rot[1][0])
            batch.set_input_double(10, rot[1][1])
            batch.set_input_double(11, rot[1][2])
            batch.set_input_double(12, rot[2][0])
            batch.set_input_double(13, rot[2][1])
            batch.set_input_double(14, rot[2][2])
            batch.set_input_double(15, scale[0])
            batch.set_input_double(16, scale[1])
            batch.set_input_double(17, scale[2])

            return batch.run_process()
        else:
            print "ERROR: Cache type not recognized: ", self.opencl_cache.type
            return False
Esempio n. 27
0
 def render_expected_image_naa(
         self, camera, ni, nj, metadata, atmospheric_params):
     batch.init_process("bstmOclRenderExpectedImageNAAProcess")
     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, camera)
     batch.set_input_unsigned(4, ni)
     batch.set_input_unsigned(5, nj)
     batch.set_input_from_db(6, metadata)
     batch.set_input_from_db(7, atmospheric_params)
     batch.run_process()
     (id, type) = batch.commit_output(0)
     exp_image = batch.dvalue(id, type)
     (id, type) = batch.commit_output(1)
     mask_image = batch.dvalue(id, type)
     return(exp_image, mask_image)
Esempio n. 28
0
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
Esempio n. 29
0
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
Esempio n. 30
0
def describe_scene(scene):
    batch.init_process("bstmDescribeSceneProcess")
    batch.set_input_from_db(0, scene)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    dataPath = batch.get_output_string(id)
    batch.remove_data(id)
    (id, type) = batch.commit_output(1)
    appType = batch.get_output_string(id)
    batch.remove_data(id)
    (id, type) = batch.commit_output(2)
    voxel_size = batch.get_output_double(id)
    batch.remove_data(id)
    description = {'voxelLength': voxel_size,
                   'dataPath': dataPath,
                   'appType': appType}
    return description
Esempio n. 31
0
def render_change(scene, device, cache, cam, time=0, ni=1624, nj=1224):
    if cache.type == "bstm_cache_sptr":
        print "bstm_batch CPU render grey and vis not yet implemented"
        return
    elif cache.type == "bstm_opencl_cache_sptr" and device:
        batch.init_process("bstmOclRenderExpectedChangeProcess")
        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_float(6, time)
        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
Esempio n. 32
0
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