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 crop_image_using_3d_box_dem(img_res, camera, ll_lon, ll_lat, ur_lon, ur_lat, dem_folder, extra_height, uncertainty, lvcs=0): bvxm_batch.init_process("vpglCropImgUsing3DboxDemProcess") bvxm_batch.set_input_from_db(0, img_res) bvxm_batch.set_input_from_db(1, camera) bvxm_batch.set_input_double(2, ll_lon) bvxm_batch.set_input_double(3, ll_lat) bvxm_batch.set_input_double(4, ur_lon) bvxm_batch.set_input_double(5, ur_lat) bvxm_batch.set_input_string(6, dem_folder) bvxm_batch.set_input_double(7, extra_height) bvxm_batch.set_input_double(8, uncertainty) if lvcs != 0: bvxm_batch.set_input_from_db(9, lvcs) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) local_cam = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) i0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(2) j0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(3) ni = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(4) nj = bvxm_batch.get_output_unsigned(id) return status, local_cam, i0, j0, ni, nj else: return status, dbvalue(0, ""), 0.0, 0.0, 0.0, 0.0
def test_classifier_clouds2(tclsf, dictionary_name, image_resource, i, j, width, height, block_size, percent_cat_name, category_id_file=""): bvxm_batch.init_process("sdetTextureClassifySatelliteCloudsProcess2") bvxm_batch.set_input_from_db(0, tclsf) bvxm_batch.set_input_string(1, dictionary_name) bvxm_batch.set_input_from_db(2, image_resource) bvxm_batch.set_input_unsigned(3, i) bvxm_batch.set_input_unsigned(4, j) bvxm_batch.set_input_unsigned(5, width) bvxm_batch.set_input_unsigned(6, height) bvxm_batch.set_input_unsigned(7, block_size) bvxm_batch.set_input_string(8, category_id_file) bvxm_batch.set_input_string(9, percent_cat_name) status = bvxm_batch.run_process() if status: (out_id, out_type) = bvxm_batch.commit_output(0) out_crop = dbvalue(out_id, out_type) (out_id, out_type) = bvxm_batch.commit_output(1) out_id_map = dbvalue(out_id, out_type) (out_id, out_type) = bvxm_batch.commit_output(2) out_rgb_map = dbvalue(out_id, out_type) (out_id, out_type) = bvxm_batch.commit_output(3) percent = bvxm_batch.get_output_float(out_id) bvxm_batch.remove_data(out_id) return out_crop, out_id_map, out_rgb_map, percent else: return 0, 0, 0, 100
def generate_ndsm(ll_lon, ll_lat, ur_lon, ur_lat, img_size_ni, img_size_nj, geo_index_txt, h_map_folder, grd_map_folder, window_size = 20, max_h_limit = 254.0): bvxm_batch.init_process("volmNdsmGenearationProcess") 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_unsigned(4, img_size_ni) bvxm_batch.set_input_unsigned(5, img_size_nj) bvxm_batch.set_input_string(6, geo_index_txt) bvxm_batch.set_input_string(7, h_map_folder) bvxm_batch.set_input_string(8, grd_map_folder) bvxm_batch.set_input_unsigned(9, window_size) bvxm_batch.set_input_float(10, max_h_limit) 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) grd_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(3) out_cam = dbvalue(id, type) return out_ndsm, out_dsm, grd_img, out_cam else: return None, None, None, None
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 crop_ortho_image_using_3d_box(img_res, camera, lower_left_lon, lower_left_lat, lower_left_elev, upper_right_lon, upper_right_lat, upper_right_elev): bvxm_batch.init_process("vpglCropOrthoUsing3DboxPRocess") bvxm_batch.set_input_from_db(0, img_res); bvxm_batch.set_input_from_db(1, camera); bvxm_batch.set_input_double(2, lower_left_lon); bvxm_batch.set_input_double(3, lower_left_lat); bvxm_batch.set_input_double(4, lower_left_elev); bvxm_batch.set_input_double(5, upper_right_lon); bvxm_batch.set_input_double(6, upper_right_lat); bvxm_batch.set_input_double(7, upper_right_elev); status = bvxm_batch.run_process(); if status: (id, type) = bvxm_batch.commit_output(0); local_geo_cam = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); i0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(2); j0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(3); ni = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(4); nj = bvxm_batch.get_output_unsigned(id) return status, local_geo_cam, i0, j0, ni, nj; else: return status, dbvalue(0, ""), 0, 0, 0, 0;
def crop_image_using_3d_box(img_res, camera, lower_left_lon, lower_left_lat, lower_left_elev, upper_right_lon, upper_right_lat, upper_right_elev, uncertainty, lvcs=0): bvxm_batch.init_process("vpglCropImgUsing3DboxProcess") bvxm_batch.set_input_from_db(0, img_res) bvxm_batch.set_input_from_db(1, camera) bvxm_batch.set_input_double(2, lower_left_lon) bvxm_batch.set_input_double(3, lower_left_lat) bvxm_batch.set_input_double(4, lower_left_elev) bvxm_batch.set_input_double(5, upper_right_lon) bvxm_batch.set_input_double(6, upper_right_lat) bvxm_batch.set_input_double(7, upper_right_elev) bvxm_batch.set_input_double(8, uncertainty) if lvcs != 0: bvxm_batch.set_input_from_db(9, lvcs) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) local_cam = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) i0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(2) j0 = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(3) ni = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(4) nj = bvxm_batch.get_output_unsigned(id) return status, local_cam, i0, j0, ni, nj else: return status, dbvalue(0, ""), 0, 0, 0, 0
def render_height_map(world): print("Rendering height map"); bvxm_batch.init_process("bvxmHeightmapOrthoProcess"); bvxm_batch.set_input_from_db(0,world); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); out_d_img = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); out_h_img = dbvalue(id, type); return out_h_img, out_d_img
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_perspective_cam_center(pcam): bvxm_batch.init_process("vpglGetPerspectiveCamCenterProcess") bvxm_batch.set_input_from_db(0, pcam) bvxm_batch.run_process() (x_id, x_type) = bvxm_batch.commit_output(0) x = bvxm_batch.get_output_float(x_id) (y_id, type) = bvxm_batch.commit_output(1) y = bvxm_batch.get_output_float(y_id) (z_id, type) = bvxm_batch.commit_output(2) z = bvxm_batch.get_output_float(z_id) return x, y, z
def get_perspective_camera_center( cam): bvxm_batch.init_process("vpglGetPerspectiveCamCenterProcess"); bvxm_batch.set_input_from_db(0, cam); 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 get_sun_angles(mdata): bvxm_batch.init_process("bradGetSunAnglesProcess") 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) return sun_az, sun_el
def geo_cam_global_to_img(geocam, lon, lat): bvxm_batch.init_process("vpglGeoGlobalToImgProcess"); bvxm_batch.set_input_from_db(0, geocam); bvxm_batch.set_input_double(1, lon); bvxm_batch.set_input_double(2, lat); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); u = bvxm_batch.get_output_int(id); (id, type) = bvxm_batch.commit_output(1); v = bvxm_batch.get_output_int(id); return u, v;
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 render_height_map_expected_with_cam(world, input_cam, ni, nj): bvxm_batch.init_process("bvxmHeightmapExpectedProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_from_db(1, input_cam) bvxm_batch.set_input_unsigned(2, ni) bvxm_batch.set_input_unsigned(3, nj) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_h_img = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) out_var_img = dbvalue(id, type) return out_h_img, out_var_img
def get_view_at_point(persp_cam,x,y,z): bvxm_batch.init_process("vpglGetViewDirectionAtPointProcess"); bvxm_batch.set_input_from_db(0,persp_cam); bvxm_batch.set_input_float(1,x); bvxm_batch.set_input_float(2,y); bvxm_batch.set_input_float(3,z); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); theta=bvxm_batch.get_output_float(id); (id,type) = bvxm_batch.commit_output(1); phi=bvxm_batch.get_output_float(id); return theta, phi;
def project_point(camera,x,y,z): bvxm_batch.init_process('vpglProjectProcess'); bvxm_batch.set_input_from_db(0,camera); bvxm_batch.set_input_float(1,x); bvxm_batch.set_input_float(2,y); bvxm_batch.set_input_float(3,z); bvxm_batch.run_process(); (id,type) = bvxm_batch.commit_output(0); u = bvxm_batch.get_output_float(id); (id,type) = bvxm_batch.commit_output(1); v = bvxm_batch.get_output_float(id); return (u,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 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 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 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 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) thres = 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) (id, type) = bvxm_batch.commit_output(7) outimg = dbvalue(id, type) return thres, tp, tn, fp, fn, tpr, fpr, outimg
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 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 isfm_rational_camera( trackfile, output_folder, pixel_radius): bvxm_batch.init_process("vpglIsfmRationalCameraProcess"); bvxm_batch.set_input_string(0, trackfile); bvxm_batch.set_input_string(1, output_folder); bvxm_batch.set_input_float(2, pixel_radius); ## pixel radius to count for inliers if not bvxm_batch.run_process(): return None, -1.0, -1.0 (id, type) = bvxm_batch.commit_output(0); cam = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); error = bvxm_batch.get_output_float(id); (id, type) = bvxm_batch.commit_output(2); inliers = bvxm_batch.get_output_float(id); return cam,error,inliers
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 update_appearance(img, cam, world, app_type, bin_index=0, scale_index=0, use_cache = 0): bvxm_batch.init_process("bvxmUpdateProcess"); bvxm_batch.set_input_from_db(0,img); bvxm_batch.set_input_from_db(1,cam); bvxm_batch.set_input_from_db(2,world); bvxm_batch.set_input_string(3,app_type); bvxm_batch.set_input_unsigned(4,bin_index); ## set bin index to be 0 for all images bvxm_batch.set_input_unsigned(5,scale_index); bvxm_batch.set_input_unsigned(6,use_cache); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); density_img = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); density_mask_img = dbvalue(id, type); return density_img, density_mask_img
def render_exp_image(cam, ni, nj, world, app_model, bin_index=0, scale_index=0): bvxm_batch.init_process("bvxmRenderExpectedImageProcess"); bvxm_batch.set_input_from_db(0,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_string(4,app_model); bvxm_batch.set_input_unsigned(5,bin_index); ## set bin index to be 0 for all images bvxm_batch.set_input_unsigned(6,scale_index); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); out_img = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); out_conf_img = dbvalue(id, type); return out_img, out_conf_img
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 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_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_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 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 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 create_scene_large_scale(roi_kml, scene_root, world_dir, dem_folder, world_size=500.0, voxel_size=1.0, height_diff=120.0, height_sub=25.0, land_folder=""): bvxm_batch.init_process("bvxmCreateSceneXmlLargeScaleProcess") bvxm_batch.set_input_string(0, roi_kml) bvxm_batch.set_input_string(1, scene_root) bvxm_batch.set_input_string(2, world_dir) bvxm_batch.set_input_string(3, dem_folder) bvxm_batch.set_input_string(4, land_folder) bvxm_batch.set_input_float(5, world_size) bvxm_batch.set_input_float(6, voxel_size) bvxm_batch.set_input_float(7, height_diff) bvxm_batch.set_input_float(8, height_sub) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) n_scenes = bvxm_batch.get_output_unsigned(id) return n_scenes else: return 0
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 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 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 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 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 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 load_rational_camera_from_txt(file_path): bvxm_batch.init_process("vpglLoadRationalCameraFromTXTProcess") 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 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 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 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 find_resource_pair(res, name, tol=10.0): bvxm_batch.init_process("volmFindResourcePairProcess") bvxm_batch.set_input_from_db(0, res) bvxm_batch.set_input_string(1, name) bvxm_batch.set_input_double(2, tol) statuscode = bvxm_batch.run_process() (f_id, f_type) = bvxm_batch.commit_output(0) full_path = bvxm_batch.get_output_string(f_id) bvxm_batch.remove_data(f_id) (n_id, n_type) = bvxm_batch.commit_output(1) pair_name = bvxm_batch.get_output_string(n_id) bvxm_batch.remove_data(n_id) (p_id, p_type) = bvxm_batch.commit_output(2) full_path_pair_name = bvxm_batch.get_output_string(p_id) bvxm_batch.remove_data(p_id) return statuscode, full_path, pair_name, full_path_pair_name
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 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 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 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 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 convert_to_local_coordinates2(lvcs, lat, lon, el): bvxm_batch.init_process('vpglConvertToLocalCoordinatesProcess2') bvxm_batch.set_input_from_db(0, lvcs) bvxm_batch.set_input_float(1, lat) bvxm_batch.set_input_float(2, lon) bvxm_batch.set_input_float(3, el) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) x = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(1) y = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(2) z = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) return (x, y, z)
def persp2genWmargin(pcam, ni, nj, margin, level=0): bvxm_batch.init_process("vpglConvertToGenericCameraWithMarginProcess") bvxm_batch.set_input_from_db(0, pcam) bvxm_batch.set_input_unsigned(1, ni) bvxm_batch.set_input_unsigned(2, nj) bvxm_batch.set_input_unsigned(3, level) bvxm_batch.set_input_int(4, margin) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) gcam = dbvalue(id, type) (id, type) = bvxm_batch.commit_output(1) ni = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(2) nj = bvxm_batch.get_output_unsigned(id) (id, type) = bvxm_batch.commit_output(3) new_pers_cam = dbvalue(id, type) return (gcam, ni, nj, new_pers_cam)
def create_local_rational_camera(rational_cam_fname, lvcs_fname): bvxm_batch.init_process('vpglCreateLocalRationalCameraProcess') bvxm_batch.set_input_string(0, rational_cam_fname) bvxm_batch.set_input_string(1, lvcs_fname) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) return cam
def load_affine_camera(file_path, viewing_dist=1000): bvxm_batch.init_process("vpglLoadAffineCameraProcess") bvxm_batch.set_input_string(0, file_path) bvxm_batch.set_input_double(1, viewing_dist) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cam = dbvalue(id, type) return cam
def volm_id_color_img(id_img, id_to_color_txt=""): bvxm_batch.init_process("volmGenerateColorClassMapProcess") bvxm_batch.set_input_from_db(0, id_img) bvxm_batch.set_input_string(1, id_to_color_txt) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) out_img = dbvalue(id, type) return out_img
def convert_local_to_global_coordinates(lvcs, x, y, z): bvxm_batch.init_process('vpglConvertLocalToGlobalCoordinatesProcess') bvxm_batch.set_input_from_db(0, lvcs) bvxm_batch.set_input_float(1, x) bvxm_batch.set_input_float(2, y) bvxm_batch.set_input_float(3, z) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) lat = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(1) lon = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) (id, type) = bvxm_batch.commit_output(2) el = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) return (lat, lon, el)
def get_cloud_coverage(mdata): bvxm_batch.init_process("bradGetCloudCoverageProcess") bvxm_batch.set_input_from_db(0, mdata) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) cloud_coverage = bvxm_batch.get_output_float(id) bvxm_batch.remove_data(id) return cloud_coverage
def get_sun_angles_date_time(lat, lon, year, month, day, hour, minute): bvxm_batch.init_process("bradGetSunAnglesDateTimeProcess") bvxm_batch.set_input_float(0, lat) bvxm_batch.set_input_float(1, lon) bvxm_batch.set_input_int(2, year) bvxm_batch.set_input_int(3, month) bvxm_batch.set_input_int(4, day) bvxm_batch.set_input_int(5, hour) bvxm_batch.set_input_int(6, minute) 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) return sun_az, sun_el