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 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 rational_cam_img_to_global(camera, i, j, init_lon=-1.0, init_lat=-1.0, init_elev=-1.0, pl_elev=-1.0, error_tol=0.05): bvxm_batch.init_process("vpglRationalImgToGlobalProcess") bvxm_batch.set_input_from_db(0, camera) bvxm_batch.set_input_unsigned(1, i) bvxm_batch.set_input_unsigned(2, j) bvxm_batch.set_input_double(3, init_lon) bvxm_batch.set_input_double(4, init_lat) bvxm_batch.set_input_double(5, init_elev) bvxm_batch.set_input_double(6, pl_elev) bvxm_batch.set_input_double(7, error_tol) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) elev = bvxm_batch.get_output_double(id) return lon, lat, elev else: return -1.0, -1.0, -1.0
def scene_origin(scene): bvxm_batch.init_process("bvxmSceneOriginProcess"); 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); lower_left_z = bvxm_batch.get_output_double(id); return lower_left_lon, lower_left_lat, lower_left_z;
def get_rational_camera_offsets(cam_in): bvxm_batch.init_process('vpglGetRationalCameraOffsetsProcess'); bvxm_batch.set_input_from_db(0,cam_in); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); offset_u = bvxm_batch.get_output_double(id); bvxm_batch.remove_data(id); (id,type) = bvxm_batch.commit_output(1); offset_v = bvxm_batch.get_output_double(id); bvxm_batch.remove_data(id); return (offset_u,offset_v);
def scene_origin(scene): bvxm_batch.init_process("bvxmSceneOriginProcess") 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) lower_left_z = bvxm_batch.get_output_double(id) return lower_left_lon, lower_left_lat, lower_left_z
def get_rational_camera_offsets(cam_in): bvxm_batch.init_process('vpglGetRationalCameraOffsetsProcess') bvxm_batch.set_input_from_db(0, cam_in) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) offset_u = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(1) offset_v = bvxm_batch.get_output_double(id) bvxm_batch.remove_data(id) return (offset_u, offset_v)
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 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 geo_cam_img_to_global(geocam, i, j): bvxm_batch.init_process("vpglGeoImgToGlobalProcess") bvxm_batch.set_input_from_db(0, geocam) bvxm_batch.set_input_unsigned(1, i) bvxm_batch.set_input_unsigned(2, j) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) lat = bvxm_batch.get_output_double(id) return lon, lat else: return 0.0, 0.0
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 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 find_min_max_elev(ll_lon, ll_lat, ur_lon, ur_lat, dem_folder): bvxm_batch.init_process("volmFindMinMaxHeightPorcess") bvxm_batch.set_input_double(0, ll_lon) bvxm_batch.set_input_double(1, ll_lat) bvxm_batch.set_input_double(2, ur_lon) bvxm_batch.set_input_double(3, ur_lat) bvxm_batch.set_input_string(4, dem_folder) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) min_elev = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) max_elev = bvxm_batch.get_output_double(id) return min_elev, max_elev else: return 0.0, 0.0
def utm_coords(lon, lat): bvxm_batch.init_process("vpglComputeUTMZoneProcess") bvxm_batch.set_input_double(0, lon) bvxm_batch.set_input_double(1, lat) result = bvxm_batch.run_process() if result: (id, type) = bvxm_batch.commit_output(0) x = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) y = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) utm_zone = bvxm_batch.get_output_int(id) (id, type) = bvxm_batch.commit_output(3) northing = bvxm_batch.get_output_int(id) return x, y, utm_zone, northing else: return 0.0, 0.0, 0, 0
def rational_cam_nadirness(camera, lat, lon, elev): bvxm_batch.init_process("vpglRationalCamNadirnessProcess") bvxm_batch.set_input_from_db(0, camera) bvxm_batch.set_input_double(1, lat) bvxm_batch.set_input_double(2, lon) bvxm_batch.set_input_double(3, elev) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) val = bvxm_batch.get_output_double(id) return val
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 rational_cam_nadirness(camera, lat, lon, elev): bvxm_batch.init_process("vpglRationalCamNadirnessProcess"); bvxm_batch.set_input_from_db(0, camera); bvxm_batch.set_input_double(1, lat); bvxm_batch.set_input_double(2, lon); bvxm_batch.set_input_double(3, elev); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); val = bvxm_batch.get_output_double(id) return val
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 rational_cam_img_to_global(camera, i, j, init_lon=-1.0, init_lat=-1.0, init_elev=-1.0, pl_elev = -1.0, error_tol = 0.05): bvxm_batch.init_process("vpglRationalImgToGlobalProcess"); bvxm_batch.set_input_from_db(0, camera); bvxm_batch.set_input_unsigned(1, i); bvxm_batch.set_input_unsigned(2, j); bvxm_batch.set_input_double(3, init_lon); bvxm_batch.set_input_double(4, init_lat); bvxm_batch.set_input_double(5, init_elev); bvxm_batch.set_input_double(6, pl_elev); bvxm_batch.set_input_double(7, error_tol); status = bvxm_batch.run_process(); if status: (id, type) = bvxm_batch.commit_output(0); lon = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(1); lat = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(2); elev = bvxm_batch.get_output_double(id) return lon, lat, elev else: return -1.0, -1.0, -1.0
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 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 image_mutual_info(image1, image2, min_val, max_val, n_bins): bvxm_batch.init_process("bripImageMutualInfoProcess") bvxm_batch.set_input_from_db(0, image1) bvxm_batch.set_input_from_db(1, image2) bvxm_batch.set_input_double(2, min_val) bvxm_batch.set_input_double(3, max_val) bvxm_batch.set_input_unsigned(4, n_bins) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) mutual_info = bvxm_batch.get_output_double(id) return mutual_info else: return -1.0
def scene_local_box(scene): bvxm_batch.init_process("bvxmSceneLocalBoxProcess") bvxm_batch.set_input_from_db(0, scene) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) lower_left_x = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) lower_left_y = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) upper_right_x = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) upper_right_y = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(4) voxel_size = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(5) lower_left_z = bvxm_batch.get_output_double(id) # min z (id, type) = bvxm_batch.commit_output(6) upper_right_z = bvxm_batch.get_output_double(id) # max z return lower_left_x, lower_left_y, upper_right_x, upper_right_y, voxel_size, lower_left_z, upper_right_z
def scene_local_box(scene): bvxm_batch.init_process("bvxmSceneLocalBoxProcess"); bvxm_batch.set_input_from_db(0,scene); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); lower_left_x = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(1); lower_left_y = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(2); upper_right_x = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(3); upper_right_y = bvxm_batch.get_output_double(id); (id, type) = bvxm_batch.commit_output(4); voxel_size = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(5); lower_left_z = bvxm_batch.get_output_double(id); ## min z (id, type) = bvxm_batch.commit_output(6); upper_right_z = bvxm_batch.get_output_double(id); ## max z return lower_left_x, lower_left_y, upper_right_x, upper_right_y, voxel_size, lower_left_z, upper_right_z;
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) lower_left_elev = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) upper_right_lon = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(4) upper_right_lat = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(5) upper_right_elev = bvxm_batch.get_output_double(id) return lower_left_lon, lower_left_lat, lower_left_elev, upper_right_lon, upper_right_lat, upper_right_elev
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