def load_atmospheric_parameters(filename): bvxm_batch.init_process("bradLoadAtmosphericParametersProcess") bvxm_batch.set_input_string(0,filename) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) atm_params = dbvalue(id,type) return atm_params
def load_perspective_camera(file_path) : bvxm_batch.init_process("vpglLoadPerspectiveCameraProcess"); bvxm_batch.set_input_string(0, file_path); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def load_dictionary(dictionary_name): bvxm_batch.init_process("sdetLoadTextureDictionaryProcess"); bvxm_batch.set_input_string(0,dictionary_name); bvxm_batch.run_process(); (tclsf_id, tclsf_type)=bvxm_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def affine_rectify_images2(img1, affine_cam1, local_rational_cam1, img2, affine_cam2, local_rational_cam2, min_x, min_y, min_z, max_x, max_y, max_z, output_path_H1, output_path_H2, local_ground_plane_height = 5, n_points=100): bvxm_batch.init_process("vpglAffineRectifyImagesProcess2"); bvxm_batch.set_input_from_db(0, img1); bvxm_batch.set_input_from_db(1, affine_cam1); bvxm_batch.set_input_from_db(2, local_rational_cam1); bvxm_batch.set_input_from_db(3, img2); bvxm_batch.set_input_from_db(4, affine_cam2); bvxm_batch.set_input_from_db(5, local_rational_cam2); bvxm_batch.set_input_double(6, min_x); bvxm_batch.set_input_double(7, min_y); bvxm_batch.set_input_double(8, min_z); bvxm_batch.set_input_double(9, max_x); bvxm_batch.set_input_double(10, max_y); bvxm_batch.set_input_double(11, max_z); bvxm_batch.set_input_unsigned(12, n_points); bvxm_batch.set_input_double(13, local_ground_plane_height); bvxm_batch.set_input_string(14, output_path_H1); bvxm_batch.set_input_string(15, output_path_H2); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); out_img1 = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); out_cam1 = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(2); out_img2 = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(3); out_cam2 = dbvalue(id, type); return out_img1, out_cam1, out_img2, out_cam2
def load_projective_camera(file_path): bvxm_batch.init_process("vpglLoadProjCameraProcess") bvxm_batch.set_input_string(0, file_path) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) return cam
def convert_local_rational_perspective_camera(local_cam) : bvxm_batch.init_process("vpglConvertLocalRationalToPerspectiveProcess"); bvxm_batch.set_input_from_db(0, local_cam); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def create_ortho_camera(world): bvxm_batch.init_process("bvxmCreateOrthoCameraProcess"); bvxm_batch.set_input_from_db(0,world); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); ortho_cam = dbvalue(id, type); return ortho_cam
def map_sdet_to_volm_ids(sdet_color_class_img): bvxm_batch.init_process("volmGenerateClassMapProcess"); bvxm_batch.set_input_from_db(0,sdet_color_class_img); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); out_img = dbvalue(id, type); return out_img
def model_dir(scene): bvxm_batch.init_process("bvxmSceneModelDirProcess"); bvxm_batch.set_input_from_db(0, scene); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); model_dir = bvxm_batch.get_output_string(id); return model_dir;
def save_occupancy_raw(world, filename, app_model, scale=0): bvxm_batch.init_process("bvxmSaveOccupancyRawProcess"); bvxm_batch.set_input_from_db(0,world); bvxm_batch.set_input_string(1,filename); bvxm_batch.set_input_unsigned(2, scale); bvxm_batch.set_input_string(3, app_model); bvxm_batch.run_process();
def create_scene(scene_params_xml): bvxm_batch.init_process("bvxmCreateVoxelWorldProcess"); bvxm_batch.set_params_process(scene_params_xml); ## "./bvxmCreateVoxelWorldProcess.xml" bvxm_batch.run_process(); (world_id, world_type) = bvxm_batch.commit_output(0); world = dbvalue(world_id, world_type); return world
def generate_roc(tclsf, class_out_prob_img, class_out_color_img, orig_img, prefix_for_bin_files, positive_category_name,category_id_file): bvxm_batch.init_process("sdetTextureClassifierROCProcess"); bvxm_batch.set_input_from_db(0, tclsf); bvxm_batch.set_input_from_db(1, class_out_prob_img); bvxm_batch.set_input_from_db(2, class_out_color_img); bvxm_batch.set_input_from_db(3, orig_img); bvxm_batch.set_input_string(4, prefix_for_bin_files); bvxm_batch.set_input_string(5, positive_category_name); bvxm_batch.set_input_string(6, category_id_file); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); tp = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(1); tn = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(2); fp = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(3); fn = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(4); tpr = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(5); fpr = bvxm_batch.get_bbas_1d_array_float(id); (id,type) = bvxm_batch.commit_output(6); outimg = dbvalue(id,type); return tp, tn, fp, fn, tpr, fpr, outimg;
def load_classifier(classifier_name): bvxm_batch.init_process("sdetLoadTextureClassifierProcess"); bvxm_batch.set_input_string(0,classifier_name); bvxm_batch.run_process(); (tclsf_id, tclsf_type)=bvxm_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def correct_ransac_process(res, cor_file, output_folder, pixel_radius): bvxm_batch.init_process("volmCorrectRationalCamerasRANSACProcess"); bvxm_batch.set_input_from_db(0, res); bvxm_batch.set_input_string(1, cor_file); bvxm_batch.set_input_string(2, output_folder); bvxm_batch.set_input_float(3, pixel_radius); ## pixel radius to count for inliers bvxm_batch.run_process();
def correct_ransac_process(cor_file, output_folder, pixel_radius): bvxm_batch.init_process("volmCorrectRationalCamerasRANSACProcess") bvxm_batch.set_input_string(0, cor_file) bvxm_batch.set_input_string(1, output_folder) # pixel radius to count for inliers bvxm_batch.set_input_float(2, pixel_radius) bvxm_batch.run_process()
def load_sat_resources(res_file_name): bvxm_batch.init_process("volmLoadSatResourcesProcess"); bvxm_batch.set_input_string(0,res_file_name); bvxm_batch.run_process(); (res2_id, res2_type) = bvxm_batch.commit_output(0); res2 = dbvalue(res2_id, res2_type); return res2
def get_metadata_info(mdata): bvxm_batch.init_process("bradGetMetaDataInfoProcess") bvxm_batch.set_input_from_db(0, mdata) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) sun_az = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id,type) = bvxm_batch.commit_output(1) sun_el = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(2) year = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(3) month = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(4) day = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(5) hour = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(6) minutes = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(7) seconds = bvxm_batch.get_output_int(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(8) gsd = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(9) sat_name = bvxm_batch.get_output_string(id) bvxm_batch.remove_data(id) return sun_az, sun_el, year, month, day, hour, minutes, seconds, gsd, sat_name
def load_rational_camera_nitf(file_path): bvxm_batch.init_process("vpglLoadRationalCameraNITFProcess") bvxm_batch.set_input_string(0, file_path) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) return cam
def add_to_filter_bank(tclsf, img_name, plane, filter_folder): bvxm_batch.init_process("sdetAddtoFilterBankProcess"); bvxm_batch.set_input_from_db(0,tclsf); # classifier instance bvxm_batch.set_input_string(1,img_name); bvxm_batch.set_input_unsigned(2,plane); ## pass which plane to extract the gauss response from bvxm_batch.set_input_string(3,filter_folder); bvxm_batch.run_process();
def load_local_rational_camera(file_path) : bvxm_batch.init_process("vpglLoadLocalRationalCameraProcess"); bvxm_batch.set_input_string(0, file_path); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def load_image_metadata(filename): bvxm_batch.init_process("bradLoadImageMetadataProcess") bvxm_batch.set_input_string(0,filename) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) mdata = dbvalue(id,type) return mdata
def get_geocam_footprint(geocam, geotiff_filename, out_kml_filename,init_finish=True): bvxm_batch.init_process('vpglGeoFootprintProcess'); bvxm_batch.set_input_from_db(0,geocam); bvxm_batch.set_input_string(1,geotiff_filename); bvxm_batch.set_input_string(2,out_kml_filename); bvxm_batch.set_input_bool(3,init_finish); bvxm_batch.run_process();
def load_eigenspace(filename): bvxm_batch.init_process("bradLoadEigenspaceProcess"); bvxm_batch.set_input_string(0, filename); bvxm_batch.run_process(); (eig_id,eig_type)=bvxm_batch.commit_output(0); eig = dbvalue(eig_id, eig_type); return eig;
def load_lvcs(lvcs_filename): bvxm_batch.init_process("vpglLoadLVCSProcess"); bvxm_batch.set_input_string(0, lvcs_filename); bvxm_batch.run_process(); (lvcs_id, lvcs_type) = bvxm_batch.commit_output(0); lvcs = dbvalue(lvcs_id, lvcs_type); return lvcs;
def save_lvcs(lat,lon,hae,lvcs_filename): bvxm_batch.init_process("vpglSaveLVCSProcess"); bvxm_batch.set_input_float(0,lat); bvxm_batch.set_input_float(1,lon); bvxm_batch.set_input_float(2,hae); bvxm_batch.set_input_string(3,lvcs_filename); bvxm_batch.run_process(); return;
def find_sun_dir_bin(metadata, output_file): bvxm_batch.init_process("bradSunDirBinProcess"); bvxm_batch.set_input_from_db(0,metadata) bvxm_batch.set_input_string(1,output_file); bvxm_batch.run_process(); (bin_id,bin_type)=bvxm_batch.commit_output(0); bin = bvxm_batch.get_output_int(bin_id); return bin
def bvxm_detect_edges(cropped_image, edge_params_xml): bvxm_batch.init_process("bvxmDetectEdgesProcess"); bvxm_batch.set_input_from_db(0,cropped_image); bvxm_batch.set_params_process(edge_params_xml); bvxm_batch.run_process(); (cropped_edge_image_id,cropped_edge_image) = bvxm_batch.commit_output(0); cropped_edge_image = dbvalue(cropped_edge_image_id,cropped_edge_image); return cropped_edge_image
def update_edges(world, cropped_cam, cropped_edge_image, update_params_xml, scale=0): bvxm_batch.init_process("bvxmUpdateEdgesProcess"); bvxm_batch.set_input_from_db(0,world); bvxm_batch.set_input_from_db(1,cropped_cam); bvxm_batch.set_input_from_db(2,cropped_edge_image); bvxm_batch.set_input_unsigned(3,0); bvxm_batch.set_params_process(update_params_xml); # "./bvxmUpdateEdgesProcess.xml"); bvxm_batch.run_process();
def read_nitf_metadata(nitf_filename, imd_folder=""): bvxm_batch.init_process("bradNITFReadMetadataProcess") bvxm_batch.set_input_string(0, nitf_filename) # requires full path and name bvxm_batch.set_input_string(1, imd_folder) # pass empty if meta is in img folder bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) meta = dbvalue(id, type) return meta
def radiometrically_calibrate(cropped_image, meta): bvxm_batch.init_process("bradNITFAbsRadiometricCalibrationProcess") bvxm_batch.set_input_from_db(0, cropped_image) bvxm_batch.set_input_from_db(1, meta) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cropped_img_cal = dbvalue(id, type) return cropped_img_cal
def scene_box(scene): bvxm_batch.init_process("bvxmSceneBoxProcess") bvxm_batch.set_input_from_db(0, scene) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) lower_left_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) lower_left_lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) upper_right_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) upper_right_lat = bvxm_batch.get_output_double(id) return lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat
def test_classifier(tclsf, block_size, category_id_file=""): bvxm_batch.init_process("sdetTextureClassifierProcess2") bvxm_batch.set_input_from_db(0, tclsf) bvxm_batch.set_input_unsigned(1, block_size) bvxm_batch.set_input_string(2, category_id_file) bvxm_batch.run_process() (out_id, out_type) = bvxm_batch.commit_output(0) out = dbvalue(out_id, out_type) (out_id, out_type) = bvxm_batch.commit_output(1) out_color = dbvalue(out_id, out_type) (out_id, out_type) = bvxm_batch.commit_output(2) out_id = dbvalue(out_id, out_type) return out, out_color, out_id
def create_perspective_camera_with_rot(pcam, phi, theta, cent_x, cent_y, cent_z): bvxm_batch.init_process("vpglCreatePerspectiveCameraProcess3") bvxm_batch.set_input_from_db(0, pcam) bvxm_batch.set_input_float(1, phi) bvxm_batch.set_input_float(2, theta) bvxm_batch.set_input_float(3, cent_x) bvxm_batch.set_input_float(4, cent_y) bvxm_batch.set_input_float(5, cent_z) bvxm_batch.run_process() (c_id, c_type) = bvxm_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def perturb_camera(cam_in, angle, rng): bvxm_batch.init_process('vpglPerturbPerspCamOrientProcess') bvxm_batch.set_input_from_db(0, cam_in) bvxm_batch.set_input_float(1, angle) bvxm_batch.set_input_from_db(2, rng) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) pert_cam = dbvalue(id, type) (theta_id, type) = bvxm_batch.commit_output(1) (phi_id, type) = bvxm_batch.commit_output(2) theta = bvxm_batch.get_output_float(theta_id) phi = bvxm_batch.get_output_float(phi_id) return pert_cam, theta, phi
def update_edges(world, cropped_cam, cropped_edge_image, update_params_xml, scale=0): bvxm_batch.init_process("bvxmUpdateEdgesProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_from_db(1, cropped_cam) bvxm_batch.set_input_from_db(2, cropped_edge_image) bvxm_batch.set_input_unsigned(3, 0) bvxm_batch.set_params_process(update_params_xml) # "./bvxmUpdateEdgesProcess.xml"); bvxm_batch.run_process()
def render_exp_edge_img(cam, ni, nj, world, scale=0): bvxm_batch.init_process("bvxmExpectedEdgeImageProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_from_db(1, cam) bvxm_batch.set_input_unsigned(2, ni) bvxm_batch.set_input_unsigned(3, nj) bvxm_batch.set_input_unsigned(4, scale) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) exp_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) exp_img_byte = dbvalue(id, type) return exp_img, exp_img_byte
def write_scene_kml(scene, kml_filename, is_overwrite=True, r=255, g=255, b=255): bvxm_batch.init_process("bvxmSceneKmlProcess") bvxm_batch.set_input_from_db(0, scene) bvxm_batch.set_input_string(1, kml_filename) bvxm_batch.set_input_bool(2, is_overwrite) bvxm_batch.set_input_unsigned(3, r) bvxm_batch.set_input_unsigned(4, g) bvxm_batch.set_input_unsigned(5, b) bvxm_batch.run_process()
def get_3d_from_depth(persp_cam, u, v, t): bvxm_batch.init_process("vpglGenerate3dPointFromDepthProcess") bvxm_batch.set_input_from_db(0, persp_cam) bvxm_batch.set_input_float(1, u) bvxm_batch.set_input_float(2, v) bvxm_batch.set_input_float(3, t) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) x = bvxm_batch.get_output_float(id) (id, type) = bvxm_batch.commit_output(1) y = bvxm_batch.get_output_float(id) (id, type) = bvxm_batch.commit_output(2) z = bvxm_batch.get_output_float(id) return x, y, z
def find_intersecting_sat_resources(res, poly_kml, max_intersecting_resources, sat_res_file): bvxm_batch.init_process("volmFindIntersectingSatResourcesProcess") bvxm_batch.set_input_from_db(0, res) # satellite resource bvxm_batch.set_input_string(1, poly_kml) # kml polygon filename bvxm_batch.set_input_float(2, max_intersecting_resources) # maximum number of intersecting images to consider, e.g., 5; # be careful with this number as this process computes # a rising powerset, i.e., n choose k ... n choose l bvxm_batch.set_input_string(3, sat_res_file) # output file to print the list (this will also save a kml version) bvxm_batch.run_process()
def compute_affine_from_local_rational(cropped_cam, min_x, min_y, min_z, max_x, max_y, max_z, n_points=100): bvxm_batch.init_process("vpglComputeAffineFromRationalProcess") bvxm_batch.set_input_from_db(0, cropped_cam) bvxm_batch.set_input_double(1, min_x) bvxm_batch.set_input_double(2, min_y) bvxm_batch.set_input_double(3, min_z) bvxm_batch.set_input_double(4, max_x) bvxm_batch.set_input_double(5, max_y) bvxm_batch.set_input_double(6, max_z) bvxm_batch.set_input_unsigned(7, n_points) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_cam = dbvalue(id, type) return out_cam
def classify_image(eig, h_no, h_atmos, input_image_filename, tile_ni, tile_nj): bvxm_batch.init_process("bradClassifyImageProcess") bvxm_batch.set_input_from_db(0, eig) bvxm_batch.set_input_from_db(1, h_no) bvxm_batch.set_input_from_db(2, h_atmos) bvxm_batch.set_input_string(3, input_image_filename) bvxm_batch.set_input_unsigned(4, tile_ni) bvxm_batch.set_input_unsigned(5, tile_nj) bvxm_batch.run_process() (vid, vtype) = bvxm_batch.commit_output(0) q_img = dbvalue(vid, vtype) (vid, vtype) = bvxm_batch.commit_output(1) q_img_orig_size = dbvalue(vid, vtype) return q_img, q_img_orig_size
def create_image_metadata(gain=1.0, offset=0.0, view_az = 0.0, view_el = 90.0, sun_az = 0.0, sun_el = 90.0, sun_irrad = None): bvxm_batch.init_process("bradCreateImageMetadataProcess") bvxm_batch.set_input_float(0,gain) bvxm_batch.set_input_float(1,offset) bvxm_batch.set_input_float(2,view_az) bvxm_batch.set_input_float(3,view_el) bvxm_batch.set_input_float(4,sun_az) bvxm_batch.set_input_float(5,sun_el) if sun_irrad != None: bvxm_batch.set_input_float(6,sun_irrad) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) mdata = dbvalue(id,type) return mdata
def segment_image_using_height2(img, height_img, edge_img, weight_thres, margin=0, min_size=50, sigma=1,neigh=8): bvxm_batch.init_process("sdetSegmentUsingHeightMapProcess2"); bvxm_batch.set_input_from_db(0,img); bvxm_batch.set_input_from_db(1,height_img); bvxm_batch.set_input_from_db(2,edge_img); bvxm_batch.set_input_int(3,margin); bvxm_batch.set_input_int(4,neigh); bvxm_batch.set_input_float(5,weight_thres); bvxm_batch.set_input_float(6,sigma); bvxm_batch.set_input_int(7,min_size); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); seg_img = dbvalue(id, type); return seg_img
def create_classifier(lambda0, lambda1, n_scales, scale_interval, angle_interval, laplace_radius, gauss_radius, k, n_samples): bvxm_batch.init_process("sdetCreateTextureClassifierProcess"); bvxm_batch.set_input_float(0,lambda0); # lambda0 bvxm_batch.set_input_float(1,lambda1); # lambda1 bvxm_batch.set_input_unsigned(2,n_scales); # n_scales bvxm_batch.set_input_float(3, scale_interval); # scale_interval bvxm_batch.set_input_float(4, angle_interval); # angle_interval bvxm_batch.set_input_float(5, laplace_radius); # laplace_radius bvxm_batch.set_input_float(6, gauss_radius); # gauss_radius bvxm_batch.set_input_unsigned(7, k); # k bvxm_batch.set_input_unsigned(8,n_samples);# number of samples bvxm_batch.run_process(); (tclsf_id, tclsf_type)=bvxm_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def update_edges(world, cropped_cam, cropped_edge_image, edge_prob_mask_size=21, edge_prob_mask_sigma=1.0, scale=0): bvxm_batch.init_process("bvxmUpdateEdgesProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_from_db(1, cropped_cam) bvxm_batch.set_input_from_db(2, cropped_edge_image) bvxm_batch.set_input_unsigned(3, 0) bvxm_batch.set_input_int(4, edge_prob_mask_size) bvxm_batch.set_input_float(5, edge_prob_mask_sigma) # bvxm_batch.set_params_process(update_params_xml); # "./bvxmUpdateEdgesProcess.xml"); bvxm_batch.run_process()
def convert_reflectance_to_digital_count(reflectance_image, metadata, atmospheric_params, normalize_0_1=False, max_digital_count=2047): bvxm_batch.init_process("bradConvertReflectanceToDigitalCountProcess") bvxm_batch.set_input_from_db(0, reflectance_image) bvxm_batch.set_input_from_db(1, metadata) bvxm_batch.set_input_from_db(2, atmospheric_params) bvxm_batch.set_input_bool(3, normalize_0_1) bvxm_batch.set_input_unsigned(4, max_digital_count) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) output_img = dbvalue(id, type) return output_img
def load_perspective_camera_from_kml_file(NI, NJ, kml_file): bvxm_batch.init_process("vpglLoadPerspCameraFromKMLFileProcess") bvxm_batch.set_input_unsigned(0, NI) bvxm_batch.set_input_unsigned(1, NJ) bvxm_batch.set_input_string(2, kml_file) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) longitude = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) latitude = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) altitude = bvxm_batch.get_output_double(id) return cam, longitude, latitude, altitude
def render_ortho_edgemap(world, scale=0): print("Rendering ortho edge map") bvxm_batch.init_process("bvxmEdgemapOrthoProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_unsigned(1, 0) # scale bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_e_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) out_e_img_byte = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(2) out_h_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(3) ortho_cam = dbvalue(id, type) return out_e_img, out_e_img_byte, out_h_img, ortho_cam
def interpolate_perspective_cameras(cam0, cam1, ncams, outdir): bvxm_batch.init_process("vpglInterpolatePerspectiveCamerasProcess") bvxm_batch.set_input_from_db(0, cam0) bvxm_batch.set_input_from_db(1, cam1) bvxm_batch.set_input_unsigned(2, ncams) bvxm_batch.set_input_string(3, outdir) return bvxm_batch.run_process()
def generate_ndsm(land_geocam, land_img_file, geo_index_txt, h_map_folder, ground_txt, dem_folder, max_h_limit=254.0, window_size=30): bvxm_batch.init_process("volmNdsmGenearationProcess") bvxm_batch.set_input_from_db(0, land_geocam) bvxm_batch.set_input_string(1, land_img_file) bvxm_batch.set_input_string(2, geo_index_txt) bvxm_batch.set_input_string(3, h_map_folder) bvxm_batch.set_input_unsigned(4, window_size) bvxm_batch.set_input_float(5, max_h_limit) bvxm_batch.set_input_string(6, ground_txt) bvxm_batch.set_input_string(7, dem_folder) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) out_ndsm = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) out_dsm = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(2) out_cam = dbvalue(id, type) return out_ndsm, out_dsm, out_cam else: return None, None, None
def create_perspective_camera(scale, ppoint, center, look_pt, up=[0, 1, 0]): bvxm_batch.init_process("vpglCreatePerspectiveCameraProcess") bvxm_batch.set_input_double(0, scale[0]) bvxm_batch.set_input_double(1, ppoint[0]) bvxm_batch.set_input_double(2, scale[1]) bvxm_batch.set_input_double(3, ppoint[1]) bvxm_batch.set_input_double(4, center[0]) bvxm_batch.set_input_double(5, center[1]) bvxm_batch.set_input_double(6, center[2]) bvxm_batch.set_input_double(7, look_pt[0]) bvxm_batch.set_input_double(8, look_pt[1]) bvxm_batch.set_input_double(9, look_pt[2]) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) return cam
def generate_layers(land_img, land_cam, height_img, height_cam, land_txt, min_h, max_h, beta=10.0): bvxm_batch.init_process("volmLayerExtractionProcess") bvxm_batch.set_input_from_db(0, land_img) bvxm_batch.set_input_from_db(1, land_cam) bvxm_batch.set_input_from_db(2, height_img) bvxm_batch.set_input_from_db(3, height_cam) bvxm_batch.set_input_string(4, land_txt) bvxm_batch.set_input_float(5, min_h) bvxm_batch.set_input_float(6, max_h) bvxm_batch.set_input_double(7, beta) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) out_prob_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) out_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(2) mask_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(3) out_cam = dbvalue(id, type) return out_prob_img, out_img, mask_img, out_cam else: return None, None, None, None
def region_wise_roc_analysis(in_img, in_cam, positive_kml, negative_kml): bvxm_batch.init_process("volmDetectionRateROCProcess") bvxm_batch.set_input_from_db(0, in_img) bvxm_batch.set_input_from_db(1, in_cam) bvxm_batch.set_input_string(2, positive_kml) bvxm_batch.set_input_string(3, negative_kml) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) thres_out = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(1) tp = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(2) tn = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(3) fp = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(4) fn = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(5) tpr = bvxm_batch.get_bbas_1d_array_float(id) (id, type) = bvxm_batch.commit_output(6) fpr = bvxm_batch.get_bbas_1d_array_float(id) return thres_out, tp, tn, fp, fn, tpr, fpr else: return None, None, None, None, None, None, None
def extract_building_outlines(height_img, class_img, geocam, csv_file_name, kml_file_name): bvxm_batch.init_process("volmExtractBuildinOutlinesProcess") bvxm_batch.set_input_from_db(0, height_img) bvxm_batch.set_input_from_db(1, class_img) bvxm_batch.set_input_from_db(2, geocam) bvxm_batch.set_input_string(3, csv_file_name) bvxm_batch.set_input_string(4, kml_file_name) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) binary_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) binary_img_e = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(2) binary_img_d = dbvalue(id, type) return binary_img, binary_img_e, binary_img_d
def registration_error_analysis(gt_file, cor_file, ori_file, gsd=1.0, cor_vector_file="", ori_vector_file=""): bvxm_batch.init_process("volmRegistrationErrorProcess") bvxm_batch.set_input_string(0, gt_file) bvxm_batch.set_input_string(1, cor_file) bvxm_batch.set_input_string(2, ori_file) bvxm_batch.set_input_double(3, gsd) bvxm_batch.set_input_string(4, cor_vector_file) bvxm_batch.set_input_string(5, ori_vector_file) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) cor_average = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) cor_std = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) ori_average = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) ori_std = bvxm_batch.get_output_double(id) return cor_average, cor_std, ori_average, ori_std else: return 0.0, 0.0, 0.0, 0.0
def project_osm_to_crop_img(crop_img, crop_cam, ortho_img, ortho_cam, osm_bin_file, band="r", is_road=True, is_region=False, vsol_bin_filename="", kml_file=""): bvxm_batch.init_process("volmMapOSMtoImage") bvxm_batch.set_input_from_db(0, crop_img) bvxm_batch.set_input_from_db(1, crop_cam) bvxm_batch.set_input_from_db(2, ortho_img) bvxm_batch.set_input_from_db(3, ortho_cam) bvxm_batch.set_input_string(4, osm_bin_file) bvxm_batch.set_input_string(5, band) bvxm_batch.set_input_bool(6, is_region) bvxm_batch.set_input_bool(7, is_road) bvxm_batch.set_input_string(8, vsol_bin_filename) bvxm_batch.set_input_string(9, kml_file) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) out_img = dbvalue(id, type) else: out_img = 0 return out_img
def find_stereo_pairs(res, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, GSD_threshold, scene_res_file, satellite_name): bvxm_batch.init_process("volmFindSatellitePairsProcess") bvxm_batch.set_input_from_db(0, res) bvxm_batch.set_input_double(1, lower_left_lon) bvxm_batch.set_input_double(2, lower_left_lat) bvxm_batch.set_input_double(3, upper_right_lon) bvxm_batch.set_input_double(4, upper_right_lat) bvxm_batch.set_input_string(5, scene_res_file) bvxm_batch.set_input_string(6, satellite_name) bvxm_batch.set_input_float(7, GSD_threshold) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cnt = bvxm_batch.get_output_unsigned(id) return cnt
def pick_nadir_resource_pair(res, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, satellite_name, out_folder, band_name="PAN", non_cloud_folder=""): bvxm_batch.init_process("volmPickNadirResPairProcess") bvxm_batch.set_input_from_db(0, res) bvxm_batch.set_input_double(1, lower_left_lon) bvxm_batch.set_input_double(2, lower_left_lat) bvxm_batch.set_input_double(3, upper_right_lon) bvxm_batch.set_input_double(4, upper_right_lat) bvxm_batch.set_input_string(5, band_name) bvxm_batch.set_input_string(6, satellite_name) bvxm_batch.set_input_string(7, non_cloud_folder) bvxm_batch.set_input_string(8, out_folder) statuscode = bvxm_batch.run_process() if statuscode: (p_id, p_type) = bvxm_batch.commit_output(0) pan_path = bvxm_batch.get_output_string(p_id) bvxm_batch.remove_data(p_id) (m_id, m_type) = bvxm_batch.commit_output(1) multi_path = bvxm_batch.get_output_string(m_id) bvxm_batch.remove_data(m_id) else: pan_path = "" multi_path = "" return statuscode, pan_path, multi_path
def get_image_coverage(mdata): bvxm_batch.init_process("bradGetImageCoverageProcess") bvxm_batch.set_input_from_db(0, mdata) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) ll_lon = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(1) ll_lat = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(2) ll_elev = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(3) ur_lon = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(4) ur_lat = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(5) ur_elev = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) return ll_lon, ll_lat, ll_elev, ur_lon, ur_lat, ur_elev else: return 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
def train_classifier(tclsf, poly_file, category_name, dictionary_name, compute_category_textons, finish_and_write_dictionary): bvxm_batch.init_process("sdetTextureTrainingProcess2"); bvxm_batch.set_input_from_db(0,tclsf); if compute_category_textons: bvxm_batch.set_input_bool(1,1); # compute the textons if this is the last polygon file for the category else: bvxm_batch.set_input_bool(1,0); bvxm_batch.set_input_string(2, poly_file); bvxm_batch.set_input_string(3, category_name); bvxm_batch.set_input_string(4, dictionary_name); bvxm_batch.run_process(); (tclsf_id, tclsf_type)=bvxm_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); if finish_and_write_dictionary: bvxm_batch.finish_process(); return tclsf