def render(scene, device, cache, cam, time=0, ni=1624, nj=1224, render_label=False): 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: bstm_batch.init_process("bstmOclRenderExpectedImageProcess") 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_unsigned(4, ni) bstm_batch.set_input_unsigned(5, nj) bstm_batch.set_input_float(6, time) bstm_batch.set_input_bool(7, render_label) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) exp_image = dbvalue(id, type) (id, type) = bstm_batch.commit_output(1) vis_image = dbvalue(id, type) return exp_image, vis_image else: print "ERROR: Cache type not recognized: ", cache.type
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 img_sum(img, plane_index=0): bstm_batch.init_process("vilImageSumProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_unsigned(1, plane_index) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) value = bstm_batch.get_output_double(id) return value
def threshold_image(img, value, threshold_above=True, id=255): bstm_batch.init_process("vilThresholdImageProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_float(1, value) bstm_batch.set_input_bool(2, threshold_above) bstm_batch.set_input_unsigned(3, id) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) mask = dbvalue(id, type) return mask
def init_trajectory(scene, startInc, endInc, radius, ni=1280, nj=720): bstm_batch.init_process("bstmViewInitTrajectoryProcess") bstm_batch.set_input_from_db(0, scene) bstm_batch.set_input_double(1, float(startInc)) # incline0 bstm_batch.set_input_double(2, float(endInc)) # incline1 bstm_batch.set_input_double(3, float(radius)) # radius bstm_batch.set_input_unsigned(4, ni) # ni bstm_batch.set_input_unsigned(5, nj) # nj bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) trajectory = dbvalue(id, type) return trajectory
def init_trajectory(scene, startInc, endInc, radius, ni=1280, nj=720) : bstm_batch.init_process("bstmViewInitTrajectoryProcess"); bstm_batch.set_input_from_db(0, scene); bstm_batch.set_input_double(1, float(startInc) ); #incline0 bstm_batch.set_input_double(2, float(endInc) ); #incline1 bstm_batch.set_input_double(3, float(radius) ); #radius bstm_batch.set_input_unsigned(4, ni); #ni bstm_batch.set_input_unsigned(5, nj); #nj bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); trajectory = dbvalue(id,type); return trajectory;
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 crop_image(img, i0, j0, ni, nj): bstm_batch.init_process("vilCropImageProcess") bstm_batch.set_input_from_db(0, img) bstm_batch.set_input_unsigned(1, i0) bstm_batch.set_input_unsigned(2, j0) bstm_batch.set_input_unsigned(3, ni) bstm_batch.set_input_unsigned(4, nj) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
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: bstm_batch.init_process("bstmOclRenderExpectedChangeProcess") 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_unsigned(4, ni) bstm_batch.set_input_unsigned(5, nj) bstm_batch.set_input_float(6, time) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) exp_image = dbvalue(id, type) return exp_image else: print "ERROR: Cache type not recognized: ", cache.type
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 : bstm_batch.init_process("bstmOclRenderExpectedChangeProcess"); 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_unsigned(4,ni); bstm_batch.set_input_unsigned(5,nj); bstm_batch.set_input_float(6, time ); bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); exp_image = dbvalue(id,type); return exp_image; else : print "ERROR: Cache type not recognized: ", cache.type;
def render(scene, device, cache, cam, time=0, ni=1624, nj=1224, render_label=False) : 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 : bstm_batch.init_process("bstmOclRenderExpectedImageProcess"); 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_unsigned(4,ni); bstm_batch.set_input_unsigned(5,nj); bstm_batch.set_input_float(6,time); bstm_batch.set_input_bool(7,render_label); bstm_batch.run_process(); (id,type) = bstm_batch.commit_output(0); exp_image = dbvalue(id,type); (id,type) = bstm_batch.commit_output(1); vis_image = dbvalue(id,type); return exp_image,vis_image; else : print "ERROR: Cache type not recognized: ", cache.type;
def convert_to_generic_camera(cam_in, ni, nj, level=0): bstm_batch.init_process('vpglConvertToGenericCameraProcess') bstm_batch.set_input_from_db(0, cam_in) bstm_batch.set_input_unsigned(1, ni) bstm_batch.set_input_unsigned(2, nj) bstm_batch.set_input_unsigned(3, level) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) generic_cam = dbvalue(id, type) return generic_cam
def persp2gen(pcam, ni, nj, level=0): bstm_batch.init_process("vpglConvertToGenericCameraProcess") bstm_batch.set_input_from_db(0, pcam) bstm_batch.set_input_unsigned(1, ni) bstm_batch.set_input_unsigned(2, nj) bstm_batch.set_input_unsigned(3, level) bstm_batch.run_process() (id, type) = bstm_batch.commit_output(0) gcam = dbvalue(id, type) return gcam
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()