def load_projective_camera(file_path): bstm_batch.init_process("vpglLoadProjCameraProcess") bstm_batch.set_input_string(0, file_path) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) cam = dbvalue(id, type) return cam
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 bstm_batch.init_process("bstmBundleToSceneProcess") bstm_batch.set_input_string(0, bundle_file) bstm_batch.set_input_string(1, img_dir) bstm_batch.set_input_string(2, app_model) bstm_batch.set_input_string(3, nobs_model) bstm_batch.set_input_bool(4, isalign) bstm_batch.set_input_unsigned(5, timeSteps) bstm_batch.set_input_string(6, out_dir) bstm_batch.run_process() (scene_id, scene_type) = bstm_batch.commit_output(0) uscene = dbvalue(scene_id, scene_type) return uscene
def load_perspective_camera(file_path) : bstm_batch.init_process("vpglLoadPerspectiveCameraProcess"); bstm_batch.set_input_string(0, file_path); bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def convert_image(img, type="byte"): bstm_batch.init_process("vilConvertPixelTypeProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_string(1, type) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) cimg = dbvalue(id, type) return cimg
def load_scene(scene_str): #print("Loading a Scene from file: ", scene_str); bstm_batch.init_process("bstmLoadSceneProcess") bstm_batch.set_input_string(0, scene_str) bstm_batch.run_process() (scene_id, scene_type) = bstm_batch.commit_output(0) scene = dbvalue(scene_id, scene_type) return scene
def load_scene(scene_str): #print("Loading a Scene from file: ", scene_str); bstm_batch.init_process("bstmLoadSceneProcess"); bstm_batch.set_input_string(0, scene_str); bstm_batch.run_process(); (scene_id, scene_type) = bstm_batch.commit_output(0); scene = dbvalue(scene_id, scene_type); return scene;
def binary_img_op(img1, img2, operation="sum"): bstm_batch.init_process("vilBinaryImageOpProcess") bstm_batch.set_input_from_db(0, img1) bstm_batch.set_input_from_db(1, img2) bstm_batch.set_input_string(2, operation) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) out = dbvalue(id, type) return out
def resize(img, ni, nj, pixel="float"): bstm_batch.init_process("vilResampleProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_int(1, ni) bstm_batch.set_input_int(2, nj) bstm_batch.set_input_string(3, pixel) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) img = dbvalue(id, type) return img
def load_image(file_path): bstm_batch.init_process("vilLoadImageViewProcess") bstm_batch.set_input_string(0, file_path) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) (ni_id, ni_type) = bstm_batch.commit_output(1) (nj_id, nj_type) = bstm_batch.commit_output(2) ni = bstm_batch.get_output_unsigned(ni_id) nj = bstm_batch.get_output_unsigned(nj_id) img = dbvalue(id, type) bstm_batch.remove_data(ni_id) bstm_batch.remove_data(nj_id) return img, ni, nj
def load_perspective_camera_from_kml_file(NI, NJ, kml_file): bstm_batch.init_process("vpglLoadPerspCameraFromKMLFileProcess") bstm_batch.set_input_unsigned(0, NI) bstm_batch.set_input_unsigned(1, NJ) bstm_batch.set_input_string(2, kml_file) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) cam = dbvalue(id, type) (id, type) = bstm_batch.commit_output(1) longitude = bstm_batch.get_output_double(id) (id, type) = bstm_batch.commit_output(2) latitude = bstm_batch.get_output_double(id) (id, type) = bstm_batch.commit_output(3) altitude = bstm_batch.get_output_double(id) return cam, longitude, latitude, altitude
def change_detect(scene, device, cache, cam, img, time, mask_img=None, raybelief="", max_mode=False): bstm_batch.init_process("bstmOclChangeDetectionProcess") bstm_batch.set_input_from_db(0, device) bstm_batch.set_input_from_db(1, scene) bstm_batch.set_input_from_db(2, cache) bstm_batch.set_input_from_db(3, cam) bstm_batch.set_input_from_db(4, img) bstm_batch.set_input_from_db(5, mask_img) bstm_batch.set_input_string(6, raybelief) bstm_batch.set_input_bool(7, max_mode) bstm_batch.set_input_float(8, time) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) cd_img = dbvalue(id, type) return cd_img
def change_detect(scene, device, cache, cam, img, time, mask_img=None, raybelief="", max_mode=False) : bstm_batch.init_process("bstmOclChangeDetectionProcess"); bstm_batch.set_input_from_db(0,device); bstm_batch.set_input_from_db(1,scene); bstm_batch.set_input_from_db(2,cache); bstm_batch.set_input_from_db(3,cam); bstm_batch.set_input_from_db(4,img); bstm_batch.set_input_from_db(5,mask_img); bstm_batch.set_input_string(6, raybelief); bstm_batch.set_input_bool(7, max_mode); bstm_batch.set_input_float(8, time); bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); cd_img = dbvalue(id,type); return cd_img;
def export_pt_cloud(scene, cache, output_filename, prob_t, time, output_aux=True): bstm_batch.init_process("bstmCppExtractPointCloudProcess") bstm_batch.set_input_from_db(0, scene) bstm_batch.set_input_from_db(1, cache) bstm_batch.set_input_float(2, prob_t) bstm_batch.set_input_float(3, time) bstm_batch.run_process() bstm_batch.init_process("bstmCppExportPointCloudProcess") bstm_batch.set_input_from_db(0, scene) bstm_batch.set_input_from_db(1, cache) bstm_batch.set_input_string(2, output_filename) bstm_batch.set_input_bool(3, output_aux) bstm_batch.set_input_float(4, time) bstm_batch.run_process() return
def export_pt_cloud(scene, cache, output_filename, prob_t, time, output_aux=True): bstm_batch.init_process("bstmCppExtractPointCloudProcess"); bstm_batch.set_input_from_db(0,scene); bstm_batch.set_input_from_db(1,cache); bstm_batch.set_input_float(2, prob_t); bstm_batch.set_input_float(3, time); bstm_batch.run_process(); bstm_batch.init_process("bstmCppExportPointCloudProcess"); bstm_batch.set_input_from_db(0,scene); bstm_batch.set_input_from_db(1,cache); bstm_batch.set_input_string(2, output_filename); bstm_batch.set_input_bool(3, output_aux); bstm_batch.set_input_float(4, time); bstm_batch.run_process(); return;
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"); bstm_batch.init_process("bstmCreateCacheProcess") bstm_batch.set_input_from_db(0, scene) bstm_batch.set_input_string(1, "lru") bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) cache = dbvalue(id, type) #print("Init Manager"); bstm_batch.init_process("boclInitManagerProcess") bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) mgr = dbvalue(id, type) #print("Get Gpu Device"); bstm_batch.init_process("boclGetDeviceProcess") bstm_batch.set_input_string(0, device_string) bstm_batch.set_input_from_db(1, mgr) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) device = dbvalue(id, type) #print("Create Gpu Cache"); bstm_batch.init_process("bstmOclCreateCacheProcess") bstm_batch.set_input_from_db(0, device) bstm_batch.set_input_from_db(1, scene) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) openclcache = dbvalue(id, type) return scene, cache, mgr, device, openclcache
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"); bstm_batch.init_process("bstmCreateCacheProcess"); bstm_batch.set_input_from_db(0,scene); bstm_batch.set_input_string(1,"lru"); bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); cache = dbvalue(id, type); #print("Init Manager"); bstm_batch.init_process("boclInitManagerProcess"); bstm_batch.run_process(); (id, type) = bstm_batch.commit_output(0); mgr = dbvalue(id, type); #print("Get Gpu Device"); bstm_batch.init_process("boclGetDeviceProcess"); bstm_batch.set_input_string(0,device_string) bstm_batch.set_input_from_db(1,mgr) bstm_batch.run_process(); (id, type) = bstm_batch.commit_output(0); device = dbvalue(id, type); #print("Create Gpu Cache"); bstm_batch.init_process("bstmOclCreateCacheProcess"); bstm_batch.set_input_from_db(0,device) bstm_batch.set_input_from_db(1,scene) bstm_batch.run_process(); (id, type) = bstm_batch.commit_output(0); openclcache = dbvalue(id, type); return scene, cache, mgr, device, openclcache;
def save_image(img, file_path): assert not isinstance(list, tuple) bstm_batch.init_process("vilSaveImageViewProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_string(1, file_path) bstm_batch.run_process()
def boxm22scene(boxm2_filename, bstm_datapath, timeSteps=32): bstm_batch.init_process("bstmBoxm2SceneToBstmProcess") bstm_batch.set_input_string(0, boxm2_filename) bstm_batch.set_input_string(1, bstm_datapath) bstm_batch.set_input_unsigned(2, timeSteps) bstm_batch.run_process()
def boxm22scene(boxm2_filename, bstm_datapath, timeSteps = 32) : bstm_batch.init_process("bstmBoxm2SceneToBstmProcess"); bstm_batch.set_input_string(0, boxm2_filename); bstm_batch.set_input_string(1, bstm_datapath); bstm_batch.set_input_unsigned(2, timeSteps); bstm_batch.run_process();