def img_registration_by_rmse(src_img, tgr_img, sx, sy, sz=0.0, pixel_res=1.0, invalid_pixel=-9999.0, mask_img=None): bvxm_batch.init_process("vilImageRegistrationProcess") bvxm_batch.set_input_from_db(0, src_img) bvxm_batch.set_input_from_db(1, tgr_img) bvxm_batch.set_input_unsigned(2, sx) bvxm_batch.set_input_unsigned(3, sy) bvxm_batch.set_input_double(4, sz) bvxm_batch.set_input_double(5, pixel_res) bvxm_batch.set_input_float(6, invalid_pixel) if mask_img: bvxm_batch.set_input_from_db(7, mask_img) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) trans_x = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) trans_y = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) trans_z = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) rmse_z = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(4) var_z = bvxm_batch.get_output_double(id) return trans_x, trans_y, trans_z, rmse_z, var_z else: return -1.0, -1.0, -1.0, -1.0, -1.0
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, extension=500.0, land_folder=""): batch.init_process("bvxmCreateSceneXmlLargeScaleProcess") batch.set_input_string(0, roi_kml) batch.set_input_string(1, scene_root) batch.set_input_string(2, world_dir) batch.set_input_string(3, dem_folder) batch.set_input_string(4, land_folder) batch.set_input_float(5, world_size) batch.set_input_float(6, voxel_size) batch.set_input_float(7, height_diff) batch.set_input_float(8, height_sub) batch.set_input_float(9, extension) status = batch.run_process() if status: (id, type) = batch.commit_output(0) n_scenes = batch.get_output_unsigned(id) batch.remove_data(id) return n_scenes else: return 0
def img_registration_by_rmse(src_img, tgr_img, sx, sy, sz = 0.0, pixel_res=1.0, invalid_pixel=-9999.0, mask_img=None): bvxm_batch.init_process("vilImageRegistrationProcess") bvxm_batch.set_input_from_db(0, src_img) bvxm_batch.set_input_from_db(1, tgr_img) bvxm_batch.set_input_unsigned(2,sx) bvxm_batch.set_input_unsigned(3,sy) bvxm_batch.set_input_double(4, sz) bvxm_batch.set_input_double(5, pixel_res) bvxm_batch.set_input_float(6,invalid_pixel) if mask_img: bvxm_batch.set_input_from_db(7,mask_img) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) trans_x = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(1) trans_y = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(2) trans_z = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(3) rmse_z = bvxm_batch.get_output_double(id) (id, type) = bvxm_batch.commit_output(4) var_z = bvxm_batch.get_output_double(id) return trans_x, trans_y, trans_z, rmse_z, var_z else: return -1.0, -1.0, -1.0, -1.0, -1.0
def rpc_registration(world, cropped_cam, cropped_edge_image, uncertainty, shift_3d_flag=0, scale=0, is_uncertainty_float=0): batch.init_process("bvxmRpcRegistrationProcess") batch.set_input_from_db(0, world) batch.set_input_from_db(1, cropped_cam) batch.set_input_from_db(2, cropped_edge_image) batch.set_input_bool(3, shift_3d_flag) if is_uncertainty_float == 1: print "uncertainty = ", uncertainty batch.set_input_float(4, uncertainty) else: batch.set_input_from_db(4, uncertainty) batch.set_input_unsigned(5, scale) batch.run_process() (cam_id, cam_type) = batch.commit_output(0) cam = dbvalue(cam_id, cam_type) (expected_edge_image_id, expected_edge_image_type) = batch.commit_output(1) expected_edge_image = dbvalue(expected_edge_image_id, expected_edge_image_type) (offset_u_id, offset_u_type) = batch.commit_output(2) offset_u = batch.get_output_double(offset_u_id) (offset_v_id, offset_v_type) = batch.commit_output(3) offset_v = batch.get_output_double(offset_v_id) return cam, expected_edge_image, offset_u, offset_v
def scale_and_offset_values(img,scale,offset): bvxm_batch.init_process("vilScaleAndOffsetValuesProcess") bvxm_batch.set_input_from_db(0,img) bvxm_batch.set_input_float(1,scale) bvxm_batch.set_input_float(2,offset) bvxm_batch.run_process() return
def scale_and_offset_values(img, scale, offset): bvxm_batch.init_process("vilScaleAndOffsetValuesProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, scale) bvxm_batch.set_input_float(2, offset) bvxm_batch.run_process() return
def detect_shadow_rgb(img,threshold) : bvxm_batch.init_process("vilShadowDetectionProcess"); bvxm_batch.set_input_from_db(0,img) bvxm_batch.set_input_float(1, threshold); bvxm_batch.run_process(); (o_id,o_type) = bvxm_batch.commit_output(0); region_img = dbvalue(o_id,o_type); return region_img;
def detect_shadow_rgb(img, threshold): bvxm_batch.init_process("vilShadowDetectionProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, threshold) bvxm_batch.run_process() (o_id, o_type) = bvxm_batch.commit_output(0) region_img = dbvalue(o_id, o_type) return region_img
def bvxm_truncate_image(img, min_value, max_value): bvxm_batch.init_process("vilTruncateImageProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, min_value) bvxm_batch.set_input_float(2, max_value) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
def bvxm_truncate_image(img,min_value,max_value): bvxm_batch.init_process("vilTruncateImageProcess") bvxm_batch.set_input_from_db(0,img) bvxm_batch.set_input_float(1,min_value) bvxm_batch.set_input_float(2,max_value) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) img_out = dbvalue(id,type) return img_out
def threshold_image(img, value, threshold_above=True): bvxm_batch.init_process("vilThresholdImageProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, value) bvxm_batch.set_input_bool(2, threshold_above) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) mask = dbvalue(id, type) return mask
def threshold_image(img, value, threshold_above=True): bvxm_batch.init_process("vilThresholdImageProcess") bvxm_batch.set_input_from_db(0,img) bvxm_batch.set_input_float(1,value) bvxm_batch.set_input_bool(2,threshold_above) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) mask = dbvalue(id,type) return mask
def init_float_img(ni, nj, np, val): bvxm_batch.init_process("vilInitFloatImageProcess") bvxm_batch.set_input_unsigned(0, ni) bvxm_batch.set_input_unsigned(1, nj) bvxm_batch.set_input_unsigned(2, np) bvxm_batch.set_input_float(3, val) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
def bvxm_stretch_image(img, min_value, max_value, output_type_str='float'): bvxm_batch.init_process("vilStretchImageProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, min_value) bvxm_batch.set_input_float(2, max_value) bvxm_batch.set_input_string(3, output_type_str) bvxm_batch.run_process() (id, type) = bvxm_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
def init_float_img(ni,nj,np,val): bvxm_batch.init_process("vilInitFloatImageProcess") bvxm_batch.set_input_unsigned(0,ni) bvxm_batch.set_input_unsigned(1,nj) bvxm_batch.set_input_unsigned(2,np) bvxm_batch.set_input_float(3,val) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) img_out = dbvalue(id,type) return img_out
def bvxm_stretch_image(img, min_value, max_value, output_type_str='float'): bvxm_batch.init_process("vilStretchImageProcess") bvxm_batch.set_input_from_db(0,img) bvxm_batch.set_input_float(1,min_value) bvxm_batch.set_input_float(2,max_value) bvxm_batch.set_input_string(3,output_type_str) bvxm_batch.run_process() (id,type) = bvxm_batch.commit_output(0) img_out = dbvalue(id,type) return img_out
def image_to_vrml_points(out_e_img, out_h_img, output_filename, prob_thres, max_scene_height): batch.init_process("bvrmlImageToPointsProcess") batch.set_input_from_db(0, out_e_img) batch.set_input_from_db(1, out_h_img) batch.set_input_string(2, output_filename) batch.set_input_float(3, prob_thres) batch.set_input_float(4, max_scene_height) batch.run_process() (id, type) = batch.commit_output(0) out_img = dbvalue(id, type) return out_img
def dilate_image_disk(in_img, disk_size): bvxm_batch.init_process("vilImageDilateDiskProcess") bvxm_batch.set_input_from_db(0, in_img) bvxm_batch.set_input_float(1, disk_size) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) out_img = dbvalue(id, type) return out_img else: return None
def update_edges(world, cropped_cam, cropped_edge_image, edge_prob_mask_size=21, edge_prob_mask_sigma=1.0, scale=0): batch.init_process("bvxmUpdateEdgesProcess") batch.set_input_from_db(0, world) batch.set_input_from_db(1, cropped_cam) batch.set_input_from_db(2, cropped_edge_image) batch.set_input_unsigned(3, 0) batch.set_input_int(4, edge_prob_mask_size) batch.set_input_float(5, edge_prob_mask_sigma) # batch.set_params_process(update_params_xml); # # "./bvxmUpdateEdgesProcess.xml"); batch.run_process()
def threshold_image_inside(img, min_thres, max_thres, threshold_inside=True): bvxm_batch.init_process("vilThresholdImageInsideProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, min_thres) bvxm_batch.set_input_float(2, max_thres) bvxm_batch.set_input_bool(3, threshold_inside) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) mask = dbvalue(id, type) return mask else: return None
def detect_shadow_ridge(region_img, blob_size_t, sun_angle): bvxm_batch.init_process("vilShadowRidgeDetectionProcess") bvxm_batch.set_input_from_db(0, region_img) bvxm_batch.set_input_int(1, blob_size_t) bvxm_batch.set_input_float(2, sun_angle) bvxm_batch.run_process() (o_id, o_type) = bvxm_batch.commit_output(0) region_img = dbvalue(o_id, o_type) (o_id, o_type) = bvxm_batch.commit_output(1) out_img = dbvalue(o_id, o_type) (o_id, o_type) = bvxm_batch.commit_output(2) dist_img = dbvalue(o_id, o_type) return region_img, out_img, dist_img
def detect_shadow_ridge(region_img,blob_size_t, sun_angle) : bvxm_batch.init_process("vilShadowRidgeDetectionProcess"); bvxm_batch.set_input_from_db(0,region_img) bvxm_batch.set_input_int(1, blob_size_t); bvxm_batch.set_input_float(2, sun_angle); bvxm_batch.run_process(); (o_id,o_type) = bvxm_batch.commit_output(0); region_img = dbvalue(o_id,o_type); (o_id,o_type) = bvxm_batch.commit_output(1); out_img = dbvalue(o_id,o_type); (o_id,o_type) = bvxm_batch.commit_output(2); dist_img = dbvalue(o_id,o_type); return region_img, out_img, dist_img;
def edge_detection(img, noise_multiplier = 1.5, smooth = 1.5, auto_threshold = False, junctionp = False, aggressive_junc_closure = False ): bvxm_batch.init_process("vilEdgeDetectionProcess"); bvxm_batch.set_input_from_db(0, img); bvxm_batch.set_input_float(1, noise_multiplier); bvxm_batch.set_input_float(2, smooth); bvxm_batch.set_input_bool(3, auto_threshold); bvxm_batch.set_input_bool(4, junctionp); bvxm_batch.set_input_bool(5, aggressive_junc_closure); status = bvxm_batch.run_process(); if status: (id, type) = bvxm_batch.commit_output(0); edge_img = dbvalue(id, type); return edge_img; else: return 0;
def generate_xyz_from_dem_multi(world, img_folder, geoid_height, fill_in_value=-1.0): batch.init_process("bvxmDemToXYZProcess2") batch.set_input_from_db(0, world) batch.set_input_string(1, img_folder) batch.set_input_double(2, geoid_height) batch.set_input_float(3, fill_in_value) result = batch.run_process() if result: (xi_id, xi_type) = batch.commit_output(0) x_img = dbvalue(xi_id, xi_type) (yi_id, yi_type) = batch.commit_output(1) y_img = dbvalue(yi_id, yi_type) (zi_id, zi_type) = batch.commit_output(2) z_img = dbvalue(zi_id, zi_type) else: x_img = 0 y_img = 0 z_img = 0 return x_img, y_img, z_img
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, extension = 500.0, land_folder=""): batch.init_process("bvxmCreateSceneXmlLargeScaleProcess") batch.set_input_string(0, roi_kml) batch.set_input_string(1, scene_root) batch.set_input_string(2, world_dir) batch.set_input_string(3, dem_folder) batch.set_input_string(4, land_folder) batch.set_input_float(5, world_size) batch.set_input_float(6, voxel_size) batch.set_input_float(7, height_diff) batch.set_input_float(8, height_sub) batch.set_input_float(9, extension) status = batch.run_process() if status: (id, type) = batch.commit_output(0) n_scenes = batch.get_output_unsigned(id) batch.remove_data(id) return n_scenes else: return 0
def edge_detection(img, noise_multiplier=1.5, smooth=1.5, auto_threshold=False, junctionp=False, aggressive_junc_closure=False): bvxm_batch.init_process("vilEdgeDetectionProcess") bvxm_batch.set_input_from_db(0, img) bvxm_batch.set_input_float(1, noise_multiplier) bvxm_batch.set_input_float(2, smooth) bvxm_batch.set_input_bool(3, auto_threshold) bvxm_batch.set_input_bool(4, junctionp) bvxm_batch.set_input_bool(5, aggressive_junc_closure) status = bvxm_batch.run_process() if status: (id, type) = bvxm_batch.commit_output(0) edge_img = dbvalue(id, type) return edge_img else: return 0
def rpc_registration(world, cropped_cam, cropped_edge_image, uncertainty, shift_3d_flag=0, scale=0, is_uncertainty_float=0): batch.init_process("bvxmRpcRegistrationProcess") batch.set_input_from_db(0, world) batch.set_input_from_db(1, cropped_cam) batch.set_input_from_db(2, cropped_edge_image) batch.set_input_bool(3, shift_3d_flag) if is_uncertainty_float == 1: print "uncertainty = ", uncertainty batch.set_input_float(4, uncertainty) else: batch.set_input_from_db(4, uncertainty) batch.set_input_unsigned(5, scale) batch.run_process() (cam_id, cam_type) = batch.commit_output(0) cam = dbvalue(cam_id, cam_type) (expected_edge_image_id, expected_edge_image_type) = batch.commit_output(1) expected_edge_image = dbvalue( expected_edge_image_id, expected_edge_image_type) (offset_u_id, offset_u_type) = batch.commit_output(2) offset_u = batch.get_output_double(offset_u_id) (offset_v_id, offset_v_type) = batch.commit_output(3) offset_v = batch.get_output_double(offset_v_id) return cam, expected_edge_image, offset_u, offset_v
mask_img_id = batch.commit_output(0) print("Convert density to prob map") batch.init_process("brecDensityToProbMapProcess") batch.set_params_process("./density_to_prob_map_params.xml") batch.set_input_from_db(0, out_img_id) batch.run_process() prob_map_id = batch.commit_output(0) for j in range(j_size): print("Threshold prob map") batch.init_process("brecProbMapThresholdProcess") batch.set_input_from_db(0, prob_map_id) batch.set_input_from_db(1, mask_img_id) batch.set_input_from_db(2, cropped_image_id) batch.set_input_float(3, j_arr[j]) batch.run_process() thres_img_id = batch.commit_output(0) print("Saving Thresholded Image") batch.init_process("SaveImageViewProcess") batch.set_input_from_db(0, thres_img_id) batch.set_input_string( 1, output_path + "thres" + str(i) + "_" + str(j_arr[j]) + ".png") batch.run_process() # ground-truth polygons for change areas need to be prepared via tools in bwm_main and saved as binary files # each test image need to have a separate parameter xml file that records the test image dimensions after ROI cropping process # polygonal regions need to be marked wrt to cropped ROI coordinate # frame (i.e. first crop the image, then open the cropped version in # bwm_main for ground-truthing)
gt_mask_id = bvxm_batch.commit_output(1); print("Saving GT Image"); bvxm_batch.init_process("SaveImageViewProcess"); bvxm_batch.set_input_from_db(0,gt_byte_id); bvxm_batch.set_input_string(1,output_path+"test_img_"+str(i)+"_gt.png"); bvxm_batch.run_process(); npasses = 1; sigma = 0.05; print("Updating change map"); bvxm_batch.init_process("brecUpdateChangesProcess"); bvxm_batch.set_input_from_db(0,out_img_id); bvxm_batch.set_input_from_db(1,curr_image_id); bvxm_batch.set_input_unsigned(2,npasses); bvxm_batch.set_input_float(3,sigma); bvxm_batch.run_process(); out_updated_img_id = bvxm_batch.commit_output(0); out_updated_byte_img_id = bvxm_batch.commit_output(1); print("Saving Image"); bvxm_batch.init_process("SaveImageViewProcess"); bvxm_batch.set_input_from_db(0,out_updated_byte_img_id); bvxm_batch.set_input_string(1,output_path+"change_map_updated_n"+str(npasses)+"_sigma_"+str(sigma)+"_"+str(i)+".png"); bvxm_batch.run_process(); print("Run the ROC process"); bvxm_batch.init_process("brecProbMapROCProcess"); bvxm_batch.set_input_from_db(0,out_updated_img_id); bvxm_batch.set_input_from_db(1,mask_img_id); bvxm_batch.set_input_from_db(2,gt_mask_id);
print("Saving GT Image") batch.init_process("SaveImageViewProcess") batch.set_input_from_db(0, gt_byte_id) batch.set_input_string( 1, output_path + "test_img_" + str(i) + "_gt.png") batch.run_process() npasses = 1 sigma = 0.05 print("Updating change map") batch.init_process("brecUpdateChangesProcess") batch.set_input_from_db(0, out_img_id) batch.set_input_from_db(1, curr_image_id) batch.set_input_unsigned(2, npasses) batch.set_input_float(3, sigma) batch.run_process() out_updated_img_id = batch.commit_output(0) out_updated_byte_img_id = batch.commit_output(1) print("Saving Image") batch.init_process("SaveImageViewProcess") batch.set_input_from_db(0, out_updated_byte_img_id) batch.set_input_string(1, output_path + "change_map_updated_n" + str( npasses) + "_sigma_" + str(sigma) + "_" + str(i) + ".png") batch.run_process() print("Run the ROC process") batch.init_process("brecProbMapROCProcess") batch.set_input_from_db(0, out_updated_img_id) batch.set_input_from_db(1, mask_img_id)
def create_scene_xml(scene_xml, world_dir, lvcs, lvcs_file, dim_x, dim_y, dim_z, voxel_size=1.0, corner_x=0.0, corner_y=0.0, corner_z=0.0, min_ocp_prob=0.001, max_ocp_prob=0.999, max_scale=1): batch.init_process("bvxmCreateSceneXmlProcess") batch.set_input_string(0, scene_xml) batch.set_input_string(1, world_dir) batch.set_input_float(2, corner_x) batch.set_input_float(3, corner_y) batch.set_input_float(4, corner_z) batch.set_input_unsigned(5, dim_x) batch.set_input_unsigned(6, dim_y) batch.set_input_unsigned(7, dim_z) batch.set_input_float(8, voxel_size) batch.set_input_from_db(9, lvcs) batch.set_input_string(10, lvcs_file) batch.set_input_float(11, min_ocp_prob) batch.set_input_float(12, max_ocp_prob) batch.set_input_unsigned(13, max_scale) return batch.run_process()
data_dir = "/Users/isa/Experiments/CapitolSFM/few_windows"; output_dir = "/Users/isa/Experiments/CapitolSFM/few_windows"; if not os.path.isdir( output_dir + "/"): os.mkdir( output_dir + "/"); #print("Load Voxel Grid"); #bvxm_batch.init_process("bvxmLoadGridProcess"); #bvxm_batch.set_input_string(0, data_dir +"/KL_gaussf1.vox"); #bvxm_batch.set_input_string(1,"bsta_gauss_f1"); #bvxm_batch.run_process(); #(world_id,world_type)= bvxm_batch.commit_output(0); #app_grid = dbvalue(world_id,world_type); print("Load Voxel Grid"); bvxm_batch.init_process("bvxmLoadGridProcess"); bvxm_batch.set_input_string(0, data_dir +"/ocp.vox"); bvxm_batch.set_input_string(1,"float"); bvxm_batch.run_process(); (world_id,world_type)= bvxm_batch.commit_output(0); ocp_grid = dbvalue(world_id,world_type); print("Writing Orientation Grid"); bvxm_batch.init_process("bvxmSaveRGBAGridVrmlProcess"); bvxm_batch.set_input_from_db(0,ocp_grid); bvxm_batch.set_input_float(1,0.3); bvxm_batch.set_input_string(2,output_dir + "/ocp_s.wrl"); bvxm_batch.run_process();
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); bvxm_batch.init_process("vilSaveImageViewProcess"); bvxm_batch.set_input_from_db(0,cropped_edge_image); bvxm_batch.set_input_string(1,"output_cropped_edge_image_"+str_pad+str(i)+".jpg"); bvxm_batch.run_process(); if i<num_train: 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); if i==0: bvxm_batch.set_input_float(3,0); else: bvxm_batch.set_input_from_db(3,n_normal); bvxm_batch.set_input_unsigned(4,0); bvxm_batch.set_params_process("./bvxmUpdateEdgesProcess.xml"); bvxm_batch.run_process(); (n_normal_id,n_normal_type) = bvxm_batch.commit_output(0); n_normal = dbvalue(n_normal_id,n_normal_type); else: 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,0); bvxm_batch.set_input_from_db(4,uncertainty); bvxm_batch.set_input_from_db(5,n_normal);
mask_img_id = bvxm_batch.commit_output(0) print("Convert density to prob map") bvxm_batch.init_process("brecDensityToProbMapProcess") bvxm_batch.set_params_process("./density_to_prob_map_params.xml") bvxm_batch.set_input_from_db(0, out_img_id) bvxm_batch.run_process() prob_map_id = bvxm_batch.commit_output(0) for j in range(j_size): print("Threshold prob map") bvxm_batch.init_process("brecProbMapThresholdProcess") bvxm_batch.set_input_from_db(0, prob_map_id) bvxm_batch.set_input_from_db(1, mask_img_id) bvxm_batch.set_input_from_db(2, cropped_image_id) bvxm_batch.set_input_float(3, j_arr[j]) bvxm_batch.run_process() thres_img_id = bvxm_batch.commit_output(0) print("Saving Thresholded Image") bvxm_batch.init_process("SaveImageViewProcess") bvxm_batch.set_input_from_db(0, thres_img_id) bvxm_batch.set_input_string( 1, output_path + "thres" + str(i) + "_" + str(j_arr[j]) + ".png") bvxm_batch.run_process() # ground-truth polygons for change areas need to be prepared via tools in bwm_main and saved as binary files # each test image need to have a separate parameter xml file that records the test image dimensions after ROI cropping process # polygonal regions need to be marked wrt to cropped ROI coordinate # frame (i.e. first crop the image, then open the cropped version in # bwm_main for ground-truthing)
print("Compass edge detector Image"); bvxm_batch.init_process("bilCompassEdgeDetectorProcess"); bvxm_batch.set_input_from_db(0,cropped_image); bvxm_batch.set_input_unsigned(1,8); bvxm_batch.set_input_double(2,2.0); bvxm_batch.set_input_double(3,0.4); bvxm_batch.run_process(); (cropped_edge_image_id,cropped_edge_image_type) = bvxm_batch.commit_output(0); cropped_edge_image = dbvalue(cropped_edge_image_id,cropped_edge_image_type); 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,0); bvxm_batch.set_input_float(4,25); bvxm_batch.set_input_float(5,0); bvxm_batch.set_input_unsigned(6,0); bvxm_batch.run_process(); (id, type) = bvxm_batch.commit_output(0); corrected_cam = dbvalue(id, type); (id, type) = bvxm_batch.commit_output(1); corrected_img = dbvalue(id, type); cam_name_local="./camera"+str(i)+".txt"; print(" saving camera "); bvxm_batch.init_process("vpglSaveRationalCameraProcess"); bvxm_batch.set_input_from_db(0,corrected_cam); bvxm_batch.set_input_string(1,cam_name_local); bvxm_batch.run_process();
batch.set_input_from_db(0, cropped_image) batch.set_input_unsigned(1, 8) batch.set_input_double(2, 2.0) batch.set_input_double(3, 0.4) batch.run_process() (cropped_edge_image_id, cropped_edge_image_type) = batch.commit_output(0) cropped_edge_image = dbvalue(cropped_edge_image_id, cropped_edge_image_type) batch.init_process("bvxmRpcRegistrationProcess") batch.set_input_from_db(0, world) batch.set_input_from_db(1, cropped_cam) batch.set_input_from_db(2, cropped_edge_image) batch.set_input_bool(3, 0) batch.set_input_float(4, 25) batch.set_input_float(5, 0) batch.set_input_unsigned(6, 0) batch.run_process() (id, type) = batch.commit_output(0) corrected_cam = dbvalue(id, type) (id, type) = batch.commit_output(1) corrected_img = dbvalue(id, type) cam_name_local = "./camera" + str(i) + ".txt" print(" saving camera ") batch.init_process("vpglSaveRationalCameraProcess") batch.set_input_from_db(0, corrected_cam) batch.set_input_string(1, cam_name_local) batch.run_process()
bvxm_batch.set_input_string(1,"output_lidar_edges.tif"); bvxm_batch.run_process(); bvxm_batch.init_process("bvxmUpdateEdgesLidarProcess"); bvxm_batch.set_input_from_db(0,lidar_height); bvxm_batch.set_input_from_db(1,lidar_edges); bvxm_batch.set_input_from_db(2,lidar_edges_prob); bvxm_batch.set_input_from_db(3,lidar_camera); bvxm_batch.set_input_from_db(4,world); bvxm_batch.set_input_unsigned(5,0); bvxm_batch.run_process(); bvxm_batch.init_process("bvxmSaveEdgesRawProcess"); bvxm_batch.set_input_from_db(0,world); bvxm_batch.set_input_string(1,"output_edges.raw"); bvxm_batch.set_input_float(2,0); bvxm_batch.set_input_unsigned(3,0); bvxm_batch.run_process(); ################## updating with LIDAR print("Creating Lidar"); bvxm_batch.init_process("bvxmLidarInitProcess"); bvxm_batch.set_params_process("lidar_params.xml"); bvxm_batch.set_input_string(0,"C:/test_images/BaghdadLIDAR/dem_1m_a1_baghdad_tile39.tif"); bvxm_batch.set_input_string(1,"C:/test_images/BaghdadLIDAR/dem_1m_a2_baghdad_tile39.tif"); bvxm_batch.set_input_from_db(2,world); bvxm_batch.run_process(); (cam_id,cam_type)=bvxm_batch.commit_output(0); cam=dbvalue(cam_id,cam_type); (lidar_id, lidar_type)=bvxm_batch.commit_output(1); lidar=dbvalue(lidar_id, lidar_type);
print("Saving GT Image") bvxm_batch.init_process("SaveImageViewProcess") bvxm_batch.set_input_from_db(0, gt_byte_id) bvxm_batch.set_input_string( 1, output_path + "test_img_" + str(i) + "_gt.png") bvxm_batch.run_process() npasses = 1 sigma = 0.05 print("Updating change map") bvxm_batch.init_process("brecUpdateChangesProcess") bvxm_batch.set_input_from_db(0, out_img_id) bvxm_batch.set_input_from_db(1, curr_image_id) bvxm_batch.set_input_unsigned(2, npasses) bvxm_batch.set_input_float(3, sigma) bvxm_batch.run_process() out_updated_img_id = bvxm_batch.commit_output(0) out_updated_byte_img_id = bvxm_batch.commit_output(1) print("Saving Image") bvxm_batch.init_process("SaveImageViewProcess") bvxm_batch.set_input_from_db(0, out_updated_byte_img_id) bvxm_batch.set_input_string( 1, output_path + "change_map_updated_n" + str(npasses) + "_sigma_" + str(sigma) + "_" + str(i) + ".png") bvxm_batch.run_process() print("Run the ROC process") bvxm_batch.init_process("brecProbMapROCProcess") bvxm_batch.set_input_from_db(0, out_updated_img_id)
bvxm_batch.set_input_string(1, "output_lidar_edges.tif") bvxm_batch.run_process() bvxm_batch.init_process("bvxmUpdateEdgesLidarProcess") bvxm_batch.set_input_from_db(0, lidar_height) bvxm_batch.set_input_from_db(1, lidar_edges) bvxm_batch.set_input_from_db(2, lidar_edges_prob) bvxm_batch.set_input_from_db(3, lidar_camera) bvxm_batch.set_input_from_db(4, world) bvxm_batch.set_input_unsigned(5, 0) bvxm_batch.run_process() bvxm_batch.init_process("bvxmSaveEdgesRawProcess") bvxm_batch.set_input_from_db(0, world) bvxm_batch.set_input_string(1, "output_edges.raw") bvxm_batch.set_input_float(2, 0) bvxm_batch.set_input_unsigned(3, 0) bvxm_batch.run_process() # updating with LIDAR print("Creating Lidar") bvxm_batch.init_process("bvxmLidarInitProcess") bvxm_batch.set_params_process("lidar_params.xml") bvxm_batch.set_input_string( 0, "C:/test_images/BaghdadLIDAR/dem_1m_a1_baghdad_tile39.tif") bvxm_batch.set_input_string( 1, "C:/test_images/BaghdadLIDAR/dem_1m_a2_baghdad_tile39.tif") bvxm_batch.set_input_from_db(2, world) bvxm_batch.run_process() (cam_id, cam_type) = bvxm_batch.commit_output(0) cam = dbvalue(cam_id, cam_type)
batch.init_process("bilCompassEdgeDetectorProcess") batch.set_input_from_db(0, cropped_image) batch.set_input_unsigned(1, 8) batch.set_input_double(2, 2.0) batch.set_input_double(3, 0.4) batch.run_process() (cropped_edge_image_id, cropped_edge_image_type) = batch.commit_output(0) cropped_edge_image = dbvalue( cropped_edge_image_id, cropped_edge_image_type) batch.init_process("bvxmRpcRegistrationProcess") batch.set_input_from_db(0, world) batch.set_input_from_db(1, cropped_cam) batch.set_input_from_db(2, cropped_edge_image) batch.set_input_bool(3, 0) batch.set_input_float(4, 25) batch.set_input_float(5, 0) batch.set_input_unsigned(6, 0) batch.run_process() (id, type) = batch.commit_output(0) corrected_cam = dbvalue(id, type) (id, type) = batch.commit_output(1) corrected_img = dbvalue(id, type) cam_name_local = "./camera" + str(i) + ".txt" print(" saving camera ") batch.init_process("vpglSaveRationalCameraProcess") batch.set_input_from_db(0, corrected_cam) batch.set_input_string(1, cam_name_local) batch.run_process()