def rpc_registration(world, cropped_cam, cropped_edge_image, uncertainty, shift_3d_flag=0, scale=0, is_uncertainty_float=0): bvxm_batch.init_process("bvxmRpcRegistrationProcess") 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_bool(3, shift_3d_flag) if is_uncertainty_float == 1: print "uncertainty = ", uncertainty bvxm_batch.set_input_float(4, uncertainty) else: bvxm_batch.set_input_from_db(4, uncertainty) bvxm_batch.set_input_unsigned(5, scale) bvxm_batch.run_process() (cam_id, cam_type) = bvxm_batch.commit_output(0) cam = dbvalue(cam_id, cam_type) (expected_edge_image_id, expected_edge_image_type) = bvxm_batch.commit_output(1) expected_edge_image = dbvalue(expected_edge_image_id, expected_edge_image_type) (offset_u_id, offset_u_type) = bvxm_batch.commit_output(2) offset_u = bvxm_batch.get_output_double(offset_u_id) (offset_v_id, offset_v_type) = bvxm_batch.commit_output(3) offset_v = bvxm_batch.get_output_double(offset_v_id) return cam, expected_edge_image, offset_u, offset_v
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 scene_resources(res, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, scene_res_file, band="PAN", GSD_threshold=10.0, pick_seeds=0, n_seeds=0): bvxm_batch.init_process("volmQuerySatelliteResourcesProcess") 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, band) # of 0, it returns all resources that intersect the box, otherwise, it # picks n_seeds among these resources bvxm_batch.set_input_bool(7, pick_seeds) bvxm_batch.set_input_int(8, n_seeds) bvxm_batch.set_input_double(9, GSD_threshold) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cnt = bvxm_batch.get_output_unsigned(id) return cnt
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 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 truncate_nitf_image(img, is_short = True): bvxm_batch.init_process("bripTruncateNITFBitProcess"); bvxm_batch.set_input_from_db(0, img); bvxm_batch.set_input_bool(1, is_short); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); out_img = dbvalue(id, type); return out_img;
def create_ortho_camera(world, is_utm=False): bvxm_batch.init_process("bvxmCreateOrthoCameraProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_bool(1, is_utm) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) ortho_cam = dbvalue(id, type) return ortho_cam
def add_to_filter_bank(tclsf, img_name, plane, filter_folder, is_gauss_smooth = True): 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.set_input_bool(4,is_gauss_smooth) bvxm_batch.run_process();
def create_satellite_resouces(roi_kml, leaf_size=0.1, eliminate_same_images=False): bvxm_batch.init_process("volmCreateSatResourcesProcess") bvxm_batch.set_input_string(0, roi_kml) bvxm_batch.set_input_float(1, leaf_size) bvxm_batch.set_input_bool(2, eliminate_same_images) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) sat_res = dbvalue(id, type) return sat_res
def truncate_nitf_image(img, is_byte=True, is_scale=False): bvxm_batch.init_process("bripTruncateNITFBitProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_bool(1, is_byte) bvxm_batch.set_input_bool(2, is_scale) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_img = dbvalue(id, type) return out_img
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 correct_ransac_with_initial_process(res, cor_file, dem_folder, output_folder, pixel_radius, enforce_existing=False): bvxm_batch.init_process("volmCorrectRationalCameraRANSACwithIntialProcess") bvxm_batch.set_input_from_db(0, res) bvxm_batch.set_input_string(1, cor_file) bvxm_batch.set_input_string(2, dem_folder) bvxm_batch.set_input_string(3, output_folder) bvxm_batch.set_input_float(4, pixel_radius) bvxm_batch.set_input_bool(5, enforce_existing) status = bvxm_batch.run_process() return status
def estimate_shadows(image, metadata, atmospheric_params): bvxm_batch.init_process("bradEstimateShadowsProcess") bvxm_batch.set_input_from_db(0, image) bvxm_batch.set_input_from_db(1, metadata) bvxm_batch.set_input_from_db(2, atmospheric_params) bvxm_batch.set_input_bool(3, False) # False returns probability value bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) shadow_probs = dbvalue(id, type) return shadow_probs
def estimate_shadows(image, metadata, atmospheric_params): bvxm_batch.init_process("bradEstimateShadowsProcess") bvxm_batch.set_input_from_db(0,image) bvxm_batch.set_input_from_db(1,metadata) bvxm_batch.set_input_from_db(2,atmospheric_params) bvxm_batch.set_input_bool(3,False) # False returns probability value bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) shadow_probs = dbvalue(id,type) return shadow_probs
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 render_height_map_with_cam(world, input_cam, ni, nj, is_negate=False): bvxm_batch.init_process("bvxmHeightmapProcess") bvxm_batch.set_input_from_db(0, input_cam) bvxm_batch.set_input_unsigned(1, ni) bvxm_batch.set_input_unsigned(2, nj) bvxm_batch.set_input_from_db(3, world) bvxm_batch.set_input_bool(4, is_negate) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_d_img = dbvalue(id, type) return out_d_img
def estimate_atmospheric_parameters(image, metadata, mean_reflectance = None, constrain_parameters=None): bvxm_batch.init_process("bradEstimateAtmosphericParametersProcess") bvxm_batch.set_input_from_db(0,image) bvxm_batch.set_input_from_db(1,metadata) if mean_reflectance != None: bvxm_batch.set_input_float(2,mean_reflectance) if constrain_parameters != None: bvxm_batch.set_input_bool(3, constrain_parameters) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) atm_params = dbvalue(id,type) return atm_params
def scene_resources2(res, poly_kml, scene_res_file, band="PAN", GSD_threshold=10.0, pick_seeds=0, n_seeds=0): bvxm_batch.init_process("volmQuerySatelliteResourceKmlProcess"); bvxm_batch.set_input_from_db(0, res); bvxm_batch.set_input_string(1, poly_kml); bvxm_batch.set_input_string(2, scene_res_file); bvxm_batch.set_input_string(3, band); bvxm_batch.set_input_bool(4, pick_seeds); bvxm_batch.set_input_int(5, n_seeds); bvxm_batch.set_input_double(6, GSD_threshold); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0) cnt = bvxm_batch.get_output_unsigned(id); return cnt;
def isfm_rational_camera_seed(track_file, out_folder, dem_folder, ll_lon=0.0, ll_lat=0.0, ur_lon=0.0, ur_lat=0.0, height_diff=20.0, pixel_radius=2.0, enforce_existing=False): bvxm_batch.init_process("vpglIsfmRationalCameraSeedProcess") bvxm_batch.set_input_string(0, track_file) bvxm_batch.set_input_string(1, out_folder) bvxm_batch.set_input_string(2, dem_folder) bvxm_batch.set_input_float(3, ll_lon) bvxm_batch.set_input_float(4, ll_lat) bvxm_batch.set_input_float(5, ur_lon) bvxm_batch.set_input_float(6, ur_lat) bvxm_batch.set_input_double(7, height_diff) bvxm_batch.set_input_float(8, pixel_radius) bvxm_batch.set_input_bool(9, enforce_existing) status = bvxm_batch.run_process() return status
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 scene_resources(res, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, scene_res_file, band="PAN", pick_seeds=0, n_seeds=0): bvxm_batch.init_process("volmQuerySatelliteResourcesProcess"); 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, band); bvxm_batch.set_input_bool(7, pick_seeds); ## of 0, it returns all resources that intersect the box, otherwise, it picks n_seeds among these resources bvxm_batch.set_input_int(8, n_seeds); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); cnt = bvxm_batch.get_output_unsigned(id); return cnt;
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
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): 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) 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 roi_init(image_filename, cam, world, roi_init_params_xml, is_all_bits=False): bvxm_batch.init_process("bvxmRoiInitProcess"); bvxm_batch.set_input_string(0,image_filename); bvxm_batch.set_input_from_db(1,cam); bvxm_batch.set_input_from_db(2,world); bvxm_batch.set_input_bool(3,is_all_bits) bvxm_batch.set_params_process(roi_init_params_xml); ##"bvxmRoiInitProcess.xml"); statuscode=bvxm_batch.run_process(); if statuscode: (cropped_cam_id, cropped_cam_type) = bvxm_batch.commit_output(0); cropped_cam = dbvalue(cropped_cam_id, cropped_cam_type); (cropped_image_id, cropped_image_type) = bvxm_batch.commit_output(1); cropped_image=dbvalue(cropped_image_id, cropped_image_type); (uncertainty_id,uncertainty_type) = bvxm_batch.commit_output(2); uncertainty = dbvalue(uncertainty_id,uncertainty_type); return statuscode, cropped_cam, cropped_image, uncertainty else: return statuscode, dbvalue(0, ""), dbvalue(0, ""), dbvalue(0, "")
def get_geocam_footprint2(geocam, geotiff_filename, out_kml="", write_kml=False): bvxm_batch.init_process("vpglGeoFootprintProcess2") bvxm_batch.set_input_from_db(0, geocam) bvxm_batch.set_input_string(1, geotiff_filename) bvxm_batch.set_input_string(2, out_kml) bvxm_batch.set_input_bool(3, write_kml) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) ll_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) ll_lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) ur_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) ur_lat = bvxm_batch.get_output_double(id) return ll_lon, ll_lat, ur_lon, ur_lat else: return 0.0, 0.0, 0.0, 0.0
def scene_resources2(res, poly_kml, scene_res_file, band="PAN", GSD_threshold=10.0, pick_seeds=0, n_seeds=0): bvxm_batch.init_process("volmQuerySatelliteResourceKmlProcess") bvxm_batch.set_input_from_db(0, res) bvxm_batch.set_input_string(1, poly_kml) bvxm_batch.set_input_string(2, scene_res_file) bvxm_batch.set_input_string(3, band) bvxm_batch.set_input_bool(4, pick_seeds) bvxm_batch.set_input_int(5, n_seeds) bvxm_batch.set_input_double(6, GSD_threshold) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cnt = bvxm_batch.get_output_unsigned(id) return cnt
def rpc_registration(world, cropped_cam, cropped_edge_image, uncertainty, shift_3d_flag=0, scale=0, is_uncertainty_float = 0): bvxm_batch.init_process("bvxmRpcRegistrationProcess"); 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_bool(3,shift_3d_flag); if is_uncertainty_float == 1: print "uncertainty = ", uncertainty bvxm_batch.set_input_float(4, uncertainty) else: bvxm_batch.set_input_from_db(4,uncertainty); bvxm_batch.set_input_unsigned(5,scale); bvxm_batch.run_process(); (cam_id,cam_type) = bvxm_batch.commit_output(0); cam = dbvalue(cam_id,cam_type); (expected_edge_image_id,expected_edge_image_type) = bvxm_batch.commit_output(1); expected_edge_image=dbvalue(expected_edge_image_id,expected_edge_image_type); (offset_u_id,offset_u_type) = bvxm_batch.commit_output(2); offset_u = bvxm_batch.get_output_double(offset_u_id); (offset_v_id,offset_v_type) = bvxm_batch.commit_output(3); offset_v = bvxm_batch.get_output_double(offset_v_id); return cam, expected_edge_image, offset_u, offset_v
def get_nitf_footprint2(nitf_img_filename, out_kml_file="", is_kml=False): bvxm_batch.init_process("vpglNITFFootprintProcess2") bvxm_batch.set_input_string(0, nitf_img_filename) bvxm_batch.set_input_string(1, out_kml_file) bvxm_batch.set_input_bool(2, is_kml) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) ll_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) ll_lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) ll_elev = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) ur_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(4) ur_lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(5) ur_elev = bvxm_batch.get_output_double(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 roi_init(image_filename, cam, world, roi_init_params_xml, is_all_bits=False): bvxm_batch.init_process("bvxmRoiInitProcess") bvxm_batch.set_input_string(0, image_filename) bvxm_batch.set_input_from_db(1, cam) bvxm_batch.set_input_from_db(2, world) bvxm_batch.set_input_bool(3, is_all_bits) bvxm_batch.set_params_process(roi_init_params_xml) ##"bvxmRoiInitProcess.xml"); statuscode = bvxm_batch.run_process() if statuscode: (cropped_cam_id, cropped_cam_type) = bvxm_batch.commit_output(0) cropped_cam = dbvalue(cropped_cam_id, cropped_cam_type) (cropped_image_id, cropped_image_type) = bvxm_batch.commit_output(1) cropped_image = dbvalue(cropped_image_id, cropped_image_type) (uncertainty_id, uncertainty_type) = bvxm_batch.commit_output(2) uncertainty = dbvalue(uncertainty_id, uncertainty_type) return statuscode, cropped_cam, cropped_image, uncertainty else: return statuscode, dbvalue(0, ""), dbvalue(0, ""), dbvalue(0, "")
def create_land_map(world, geo_folder, urban_folder, osm_folder, is_osm_pt, is_osm_region, is_osm_line, is_convert=True): bvxm_batch.init_process("bvxmCreateLandMapProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_string(1, geo_folder) bvxm_batch.set_input_string(2, urban_folder) bvxm_batch.set_input_string(3, osm_folder) bvxm_batch.set_input_bool(4, is_osm_pt) bvxm_batch.set_input_bool(5, is_osm_line) bvxm_batch.set_input_bool(6, is_osm_region) bvxm_batch.set_input_bool(7, is_convert) result = bvxm_batch.run_process() if result: (img_id, img_type) = bvxm_batch.commit_output(0) land_img = dbvalue(img_id, img_type) else: land_img = 0 return land_img
def create_land_map(world, geo_folder, urban_folder, osm_folder, is_osm_pt, is_osm_region, is_osm_line): bvxm_batch.init_process("bvxmCreateLandMapProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_string(1, geo_folder) bvxm_batch.set_input_string(2, urban_folder) bvxm_batch.set_input_string(3, osm_folder) bvxm_batch.set_input_bool(4, is_osm_pt) bvxm_batch.set_input_bool(5, is_osm_line) bvxm_batch.set_input_bool(6, is_osm_region) result = bvxm_batch.run_process() if result: (img_id, img_type) = bvxm_batch.commit_output(0) land_img = dbvalue(img_id, img_type) else: land_img = 0 return land_img