def get_info_along_ray(scene,cache,cam,u,v,prefix,identifier="") : print("Ray Probe"); boxm2_batch.init_process("boxm2CppRayProbeProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_from_db(2,cam); boxm2_batch.set_input_unsigned(3,u); boxm2_batch.set_input_unsigned(4,v); boxm2_batch.set_input_string(5,prefix); boxm2_batch.set_input_string(6,identifier); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); len_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(1); alpha_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(2); vis_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(3); tabs_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(4); res_array_1d = boxm2_batch.get_bbas_1d_array_float(id); if (prefix != "") : (id, type) = boxm2_batch.commit_output(5); data_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(6); nelems = boxm2_batch.get_output_int(id); return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d,res_array_1d, data_array_1d, nelems; else : return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d,res_array_1d;
def load_perspective_camera(file_path) : boxm2_batch.init_process("vpglLoadPerspectiveCameraProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def gen_error_point_cloud(scene,cache,filename,thresh = 0.3): boxm2_batch.init_process("boxm2ExportErrorPointCloudProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,filename); #ply filename boxm2_batch.set_input_float(3,thresh); #prob threshold boxm2_batch.run_process();
def load_lvcs(lvcs_filename): boxm2_batch.init_process("vpglLoadLVCSProcess"); boxm2_batch.set_input_string(0, lvcs_filename); boxm2_batch.run_process(); (lvcs_id, lvcs_type) = boxm2_batch.commit_output(0); lvcs = dbvalue(lvcs_id, lvcs_type); return lvcs;
def load_dictionary(dictionary_name): boxm2_batch.init_process("sdetLoadTextureDictionaryProcess"); boxm2_batch.set_input_string(0,dictionary_name); boxm2_batch.run_process(); (tclsf_id, tclsf_type)=boxm2_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def get_geocam_footprint(geocam, geotiff_filename, out_kml_filename,init_finish=True): boxm2_batch.init_process('vpglGeoFootprintProcess'); boxm2_batch.set_input_from_db(0,geocam); boxm2_batch.set_input_string(1,geotiff_filename); boxm2_batch.set_input_string(2,out_kml_filename); boxm2_batch.set_input_bool(3,init_finish); boxm2_batch.run_process();
def load_eigenspace(filename): boxm2_batch.init_process("bradLoadEigenspaceProcess"); boxm2_batch.set_input_string(0, filename); boxm2_batch.run_process(); (eig_id,eig_type)=boxm2_batch.commit_output(0); eig = dbvalue(eig_id, eig_type); return eig;
def load_local_rational_camera(file_path) : boxm2_batch.init_process("vpglLoadLocalRationalCameraProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def export_points_and_normals( scene, cache, file_out, save_aux=True, prob_thresh=0.0, vis_thresh=0.0, nmag_thresh=0.0, exp_thresh=0.0, bbox_file="", ): if cache.type == "boxm2_cache_sptr": print ("Exporting to oriented point cloud") boxm2_batch.init_process("boxm2ExportOrientedPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, file_out) # output aux (prob, vis, normal magnitdue) boxm2_batch.set_input_bool(3, save_aux) boxm2_batch.set_input_float(4, vis_thresh) # vis threshold boxm2_batch.set_input_float(5, nmag_thresh) # nmag threshold boxm2_batch.set_input_float(6, prob_thresh) # prob threshold # boxm2_batch.set_input_float(7,exp_thresh); #exp threshold # boxm2_batch.set_input_string(8, bbox_file); #bb filename boxm2_batch.set_input_string(7, bbox_file) # bb filename return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def import_triangle_mesh(scene, cache, ply_filename, occupied_prob=0.99): boxm2_batch.init_process("boxm2ImportTriangleMeshProcess") boxm2_batch.set_input_from_db(0,scene) boxm2_batch.set_input_from_db(1,cache) boxm2_batch.set_input_string(2,ply_filename) boxm2_batch.set_input_float(3,occupied_prob) boxm2_batch.run_process()
def load_projective_camera(file_path): boxm2_batch.init_process("vpglLoadProjCameraProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def load_rational_camera_nitf(file_path): boxm2_batch.init_process("vpglLoadRationalCameraNITFProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def load_image_metadata(filename): boxm2_batch.init_process("bradLoadImageMetadataProcess") boxm2_batch.set_input_string(0,filename) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) mdata = dbvalue(id,type) return mdata
def load_joint_hist3d(filename): boxm2_batch.init_process("bstaLoadJointHist3dProcess"); boxm2_batch.set_input_string(0,filename); boxm2_batch.run_process(); (h_id,h_type) = boxm2_batch.commit_output(0); h = dbvalue(h_id, h_type); return h
def interpolate_perspective_cameras(cam0,cam1,ncams,outdir): boxm2_batch.init_process("vpglInterpolatePerspectiveCamerasProcess"); boxm2_batch.set_input_from_db(0, cam0); boxm2_batch.set_input_from_db(1, cam1); boxm2_batch.set_input_unsigned(2, ncams); boxm2_batch.set_input_string(3, outdir); return boxm2_batch.run_process();
def load_atmospheric_parameters(filename): boxm2_batch.init_process("bradLoadAtmosphericParametersProcess") boxm2_batch.set_input_string(0,filename) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id,type) return atm_params
def texture_classifier_kernel_margin(dictionary): boxm2_batch.init_process("sdetTextureClassifierKernelMarginProcess"); boxm2_batch.set_input_string(0,dictionary); boxm2_batch.run_process(); (m_id, m_type) = boxm2_batch.commit_output(0); margin = boxm2_batch.get_output_int(m_id); return margin;
def import_point_cloud(scene,cache,in_file,min_octree_depth=2): boxm2_batch.init_process("boxm2ImportPointCloudProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,in_file); boxm2_batch.set_input_unsigned(3, min_octree_depth) boxm2_batch.run_process();
def load_mesh(filename): boxm2_batch.init_process("boxm2LoadMeshProcess"); boxm2_batch.set_input_string(0,filename); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); mesh = dbvalue(id, type); return mesh;
def load_classifier(classifier_name): boxm2_batch.init_process("sdetLoadTextureClassifierProcess"); boxm2_batch.set_input_string(0,classifier_name); boxm2_batch.run_process(); (tclsf_id, tclsf_type)=boxm2_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def export_stack(scene,cache,outdir,identifier): boxm2_batch.init_process("boxm2ExportStackImagesProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,outdir); boxm2_batch.set_input_string(3,identifier); boxm2_batch.run_process();
def export_stack(scene,cache,outdir,isopacityonly= True): boxm2_batch.init_process("boxm2ExportStackImagesProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,outdir); boxm2_batch.set_input_bool(3,isopacityonly); boxm2_batch.run_process();
def paint_mesh(scene,cache,in_file,out_file): boxm2_batch.init_process("boxm2PaintMeshProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,in_file); boxm2_batch.set_input_string(3,out_file); boxm2_batch.run_process();
def read_nitf_metadata(nitf_filename, imd_folder=""): boxm2_batch.init_process("bradNITFReadMetadataProcess") boxm2_batch.set_input_string(0, nitf_filename) # requires full path and name boxm2_batch.set_input_string(1, imd_folder) # pass empty if meta is in img folder boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) meta = dbvalue(id, type) return meta
def create_local_rational_camera(rational_cam_fname, lvcs_fname): boxm2_batch.init_process('vpglCreateLocalRationalCameraProcess') boxm2_batch.set_input_string(0, rational_cam_fname) boxm2_batch.set_input_string(1, lvcs_fname) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def update_cpp(scene, cache, cam, img, ident=""): boxm2_batch.init_process("boxm2CppUpdateImageProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_from_db(2, cam) boxm2_batch.set_input_from_db(3, img) boxm2_batch.set_input_string(4, ident) boxm2_batch.run_process()
def convert_image(img, type="byte"): boxm2_batch.init_process("vilConvertPixelTypeProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_string(1, type) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cimg = dbvalue(id, type) return cimg
def find_sun_dir_bin(metadata, output_file): boxm2_batch.init_process("bradSunDirBinProcess") boxm2_batch.set_input_from_db(0, metadata) boxm2_batch.set_input_string(1, output_file) boxm2_batch.run_process() (bin_id, bin_type) = boxm2_batch.commit_output(0) bin = boxm2_batch.get_output_int(bin_id) return bin
def save_lvcs(lat,lon,hae,lvcs_filename): boxm2_batch.init_process("vpglSaveLVCSProcess") boxm2_batch.set_input_float(0,lat) boxm2_batch.set_input_float(1,lon) boxm2_batch.set_input_float(2,hae) boxm2_batch.set_input_string(3,lvcs_filename) boxm2_batch.run_process() return
def load_scene(scene_str): print("Loading a Scene from file: ", scene_str) boxm2_batch.init_process("boxm2LoadSceneProcess") boxm2_batch.set_input_string(0, scene_str) boxm2_batch.run_process() (scene_id, scene_type) = boxm2_batch.commit_output(0) scene = dbvalue(scene_id, scene_type) return scene
def texture_classifier_kernel_margin(dictionary): boxm2_batch.init_process("sdetTextureClassifierKernelMarginProcess") boxm2_batch.set_input_string(0, dictionary) boxm2_batch.run_process() (m_id, m_type) = boxm2_batch.commit_output(0) margin = boxm2_batch.get_output_int(m_id) boxm2_batch.remove_data(m_id) return margin
def sun_dir_bin(meta, illum_bin_filename): boxm2_batch.init_process("bradSunDirBinProcess") boxm2_batch.set_input_from_db(0, meta) boxm2_batch.set_input_string(1, illum_bin_filename) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) bin = boxm2_batch.get_output_int(id) return bin
def create_local_rational_camera(rational_cam_fname, lvcs_fname): boxm2_batch.init_process('vpglCreateLocalRationalCameraProcess'); boxm2_batch.set_input_string(0,rational_cam_fname); boxm2_batch.set_input_string(1,lvcs_fname); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def create_and_save_lvcs(lat, lon, elev, cs_name, lvcs_filename): boxm2_batch.init_process("vpglCreateAndSaveLVCSProcess"); boxm2_batch.set_input_float(0, lat); boxm2_batch.set_input_float(1, lon); boxm2_batch.set_input_float(2, elev); boxm2_batch.set_input_string(3, cs_name); boxm2_batch.set_input_string(4, lvcs_filename); return bvxm_batch.run_process();
def save_lvcs(lat,lon,hae,lvcs_filename): boxm2_batch.init_process("vpglSaveLVCSProcess"); boxm2_batch.set_input_float(0,lat); boxm2_batch.set_input_float(1,lon); boxm2_batch.set_input_float(2,hae); boxm2_batch.set_input_string(3,lvcs_filename); boxm2_batch.run_process(); return;
def create_and_save_lvcs(lat, lon, elev, cs_name, lvcs_filename): boxm2_batch.init_process("vpglCreateAndSaveLVCSProcess") boxm2_batch.set_input_float(0, lat) boxm2_batch.set_input_float(1, lon) boxm2_batch.set_input_float(2, elev) boxm2_batch.set_input_string(3, cs_name) boxm2_batch.set_input_string(4, lvcs_filename) return bvxm_batch.run_process()
def load_affine_camera(file_path, viewing_dist=1000): boxm2_batch.init_process("vpglLoadAffineCameraProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.set_input_double(1, viewing_dist) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def sun_dir_bin(meta,illum_bin_filename): boxm2_batch.init_process("bradSunDirBinProcess"); boxm2_batch.set_input_from_db(0,meta); boxm2_batch.set_input_string(1,illum_bin_filename); boxm2_batch.run_process(); (id,type)=boxm2_batch.commit_output(0); bin = boxm2_batch.get_output_int(id); return bin;
def load_geotiff_cam2(filename, ni, nj): boxm2_batch.init_process("vpglLoadGeoCameraProcess2") boxm2_batch.set_input_string(0, filename) boxm2_batch.set_input_unsigned(1, ni) boxm2_batch.set_input_unsigned(2, nj) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def query_cell_brdf(scene, cache, point, model_type): boxm2_batch.init_process("boxm2CppQueryCellBrdfProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_float(2, point[0]) boxm2_batch.set_input_float(3, point[1]) boxm2_batch.set_input_float(4, point[2]) boxm2_batch.set_input_string(5, model_type) boxm2_batch.run_process()
def gen_error_point_cloud(scene, cache, filename, thresh=0.3): boxm2_batch.init_process("boxm2ExportErrorPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, filename) #ply filename boxm2_batch.set_input_float(3, thresh) #prob threshold boxm2_batch.run_process()
def bae_raw_stream(file_path): boxm2_batch.init_process("bilCreateRawImageIstreamProcess") boxm2_batch.set_input_string(0, file_path) 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
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
def binary_img_op(img1, img2, operation="sum"): boxm2_batch.init_process("vilBinaryImageOpProcess") boxm2_batch.set_input_from_db(0, img1) boxm2_batch.set_input_from_db(1, img2) boxm2_batch.set_input_string(2, operation) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out = dbvalue(id, type) return out
def update_with_quality(scene, cache, cam, img, q_img, identifier=""): boxm2_batch.init_process("boxm2CppUpdateUsingQualityProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_from_db(2, cam) boxm2_batch.set_input_from_db(3, img) boxm2_batch.set_input_from_db(4, q_img) boxm2_batch.set_input_string(5, identifier) boxm2_batch.run_process()
def load_geotiff_from_header(filename, lvcs=0): boxm2_batch.init_process("vpglLoadGeotiffCamFromHeaderProcess") boxm2_batch.set_input_string(0, filename) if lvcs != 0: boxm2_batch.set_input_from_db(1, lvcs) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def load_rational_camera(file_path): boxm2_batch.init_process("vpglLoadRationalCameraProcess") boxm2_batch.set_input_string(0, file_path) status = boxm2_batch.run_process() cam = None if status: (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return status, cam
def load_image_metadata(filename): boxm2_batch.init_process("bradLoadImageMetadataProcess") boxm2_batch.set_input_string(0, filename) status = boxm2_batch.run_process() mdata = None if status: (id, type) = boxm2_batch.commit_output(0) mdata = dbvalue(id, type) return mdata
def texture_classifier(tcl, dictionary, img, block_size=64): boxm2_batch.init_process("sdetTextureClassifierProcess") boxm2_batch.set_input_from_db(0, tcl) boxm2_batch.set_input_string(1, dictionary) boxm2_batch.set_input_from_db(2, img) boxm2_batch.set_input_unsigned(3, block_size) # size of blocks boxm2_batch.run_process() (img_id, img_type) = boxm2_batch.commit_output(0) img_classified = dbvalue(img_id, img_type) return img_classified
def write_perspective_cam_vrml(vrml_filename, pcam, camera_rad, axis_length, r, g, b): boxm2_batch.init_process("bvrmlWritePerspectiveCamProcess"); boxm2_batch.set_input_string(0,vrml_filename); boxm2_batch.set_input_from_db(1,pcam); boxm2_batch.set_input_float(2,camera_rad); boxm2_batch.set_input_float(3,axis_length); boxm2_batch.set_input_float(4,r); boxm2_batch.set_input_float(5,g); boxm2_batch.set_input_float(6,b); boxm2_batch.run_process();
def stretch_image(img, min_value, max_value, output_type_str='float'): boxm2_batch.init_process("vilStretchImageProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_float(1, min_value) boxm2_batch.set_input_float(2, max_value) boxm2_batch.set_input_string(3, output_type_str) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
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
def load_geotiff_cam(tfw_filename, lvcs, utm_zone, utm_hemisphere): boxm2_batch.init_process("vpglLoadGeoCameraProcess") boxm2_batch.set_input_string(0, tfw_filename) boxm2_batch.set_input_from_db(1, lvcs) boxm2_batch.set_input_int(2, utm_zone) boxm2_batch.set_input_unsigned(3, utm_hemisphere) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def read_nitf_metadata(nitf_filename, imd_folder=""): boxm2_batch.init_process("bradNITFReadMetadataProcess") boxm2_batch.set_input_string(0, nitf_filename) # requires full path and name boxm2_batch.set_input_string( 1, imd_folder) # pass empty if meta is in img folder boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) meta = dbvalue(id, type) return meta
def gen_mesh(z_img,x_img,y_img,out_dir): boxm2_batch.init_process("boxm2ExportMeshProcess"); boxm2_batch.set_input_from_db(0,z_img); boxm2_batch.set_input_from_db(1,x_img); boxm2_batch.set_input_from_db(2,y_img); boxm2_batch.set_input_string(3,out_dir); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); mesh = dbvalue(id, type); return mesh;
def create_lvcs(lat, lon, el, csname): boxm2_batch.init_process('vpglCreateLVCSProcess') boxm2_batch.set_input_float(0, lat) boxm2_batch.set_input_float(1, lon) boxm2_batch.set_input_float(2, el) boxm2_batch.set_input_string(3, csname) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) lvcs = dbvalue(id, type) return lvcs
def get_geocam_footprint(geocam, geotiff_filename, out_kml_filename, init_finish=True): boxm2_batch.init_process('vpglGeoFootprintProcess') boxm2_batch.set_input_from_db(0, geocam) boxm2_batch.set_input_string(1, geotiff_filename) boxm2_batch.set_input_string(2, out_kml_filename) boxm2_batch.set_input_bool(3, init_finish) boxm2_batch.run_process()
def sun_angles(image_path): boxm2_batch.init_process('bbasSunAnglesProcess') boxm2_batch.set_input_string(0, image_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) sun_el = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) sun_az = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return (sun_az, sun_el)