def roi_init(NITF_path, camera, scene, convert_to_8bit, params_fname, margin=0): boxm2_batch.init_process("boxm2RoiInitProcess") boxm2_batch.set_params_process(params_fname) boxm2_batch.set_input_string(0, NITF_path) boxm2_batch.set_input_from_db(1, camera) boxm2_batch.set_input_from_db(2, scene) boxm2_batch.set_input_bool(3, convert_to_8bit) boxm2_batch.set_input_int(4, margin) result = boxm2_batch.run_process() if result: (id, type) = boxm2_batch.commit_output(0) local_cam = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(1) cropped_image = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(2) uncertainty = boxm2_batch.get_output_float(id) else: local_cam = 0 cropped_image = 0 uncertainty = 0 return result, local_cam, cropped_image, uncertainty
def export_stack(scene,cache,outdir,isopacityonly= True): boxm2_batch.init_process("boxm2ExportStackImagesProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,outdir); boxm2_batch.set_input_bool(3,isopacityonly); boxm2_batch.run_process();
def render_z_image(scene, cache, cam, ni=1280, nj=720, normalize=False, device=None): if cache.type == "boxm2_cache_sptr": print "boxm2_batch CPU render depth not yet implemented" elif cache.type == "boxm2_opencl_cache_sptr" and device: boxm2_batch.init_process("boxm2OclRenderExpectedZImageProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_from_db(3, cam) boxm2_batch.set_input_unsigned(4, ni) boxm2_batch.set_input_unsigned(5, nj) boxm2_batch.set_input_bool(6, normalize) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) z_exp_image = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(1) z_var_image = dbvalue(id, type) return z_exp_image, z_var_image else: print "ERROR: Cache type not recognized: ", cache.type
def update_grey(scene, cache, cam, img, device=None, ident="", mask=None, update_alpha=True, var=-1.0): #If no device is passed in, do cpu update if cache.type == "boxm2_cache_sptr": print "boxm2_batch CPU update" boxm2_batch.init_process("boxm2CppUpdateImageProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_from_db(2, cam) boxm2_batch.set_input_from_db(3, img) return boxm2_batch.run_process() elif cache.type == "boxm2_opencl_cache_sptr" and device: print("boxm2_batch GPU update") boxm2_batch.init_process("boxm2OclUpdateProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_from_db(3, cam) boxm2_batch.set_input_from_db(4, img) boxm2_batch.set_input_string(5, ident) if mask: boxm2_batch.set_input_from_db(6, mask) boxm2_batch.set_input_bool(7, update_alpha) boxm2_batch.set_input_float(8, var) return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def update_grey_with_alt(scene, cache, cam, img, device=None, ident="", mask=None, update_alpha=True, var=-1.0, alt_prior=None, alt_density=None): #If no device is passed in, do cpu update if cache.type == "boxm2_cache_sptr": print "ERROR: CPU update not implemented for update_with_alt" elif cache.type == "boxm2_opencl_cache_sptr" and device: print("boxm2_batch GPU update with alt") boxm2_batch.init_process("boxm2OclUpdateWithAltProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_from_db(3, cam) boxm2_batch.set_input_from_db(4, img) boxm2_batch.set_input_string(5, ident) if mask: boxm2_batch.set_input_from_db(6, mask) boxm2_batch.set_input_bool(7, update_alpha) boxm2_batch.set_input_float(8, var) boxm2_batch.set_input_from_db(9, alt_prior) boxm2_batch.set_input_from_db(10, alt_density) boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type
def get_geocam_footprint(geocam, geotiff_filename, out_kml_filename,init_finish=True): boxm2_batch.init_process('vpglGeoFootprintProcess'); boxm2_batch.set_input_from_db(0,geocam); boxm2_batch.set_input_string(1,geotiff_filename); boxm2_batch.set_input_string(2,out_kml_filename); boxm2_batch.set_input_bool(3,init_finish); boxm2_batch.run_process();
def export_points_and_normals( scene, cache, file_out, save_aux=True, prob_thresh=0.0, vis_thresh=0.0, nmag_thresh=0.0, exp_thresh=0.0, bbox_file="", ): if cache.type == "boxm2_cache_sptr": print ("Exporting to oriented point cloud") boxm2_batch.init_process("boxm2ExportOrientedPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, file_out) # output aux (prob, vis, normal magnitdue) boxm2_batch.set_input_bool(3, save_aux) boxm2_batch.set_input_float(4, vis_thresh) # vis threshold boxm2_batch.set_input_float(5, nmag_thresh) # nmag threshold boxm2_batch.set_input_float(6, prob_thresh) # prob threshold # boxm2_batch.set_input_float(7,exp_thresh); #exp threshold # boxm2_batch.set_input_string(8, bbox_file); #bb filename boxm2_batch.set_input_string(7, bbox_file) # bb filename return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def export_points_and_normals(scene, cache, file_out, save_aux=True, prob_thresh=0.0, vis_thresh=0.0, nmag_thresh=0.0, exp_thresh=0.0, bbox_file=""): if cache.type == "boxm2_cache_sptr": print("Exporting to oriented point cloud") boxm2_batch.init_process("boxm2ExportOrientedPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, file_out) boxm2_batch.set_input_bool(3, save_aux) #output aux (prob, vis, normal magnitdue) boxm2_batch.set_input_float(4, vis_thresh) #vis threshold boxm2_batch.set_input_float(5, nmag_thresh) #nmag threshold boxm2_batch.set_input_float(6, prob_thresh) #prob threshold boxm2_batch.set_input_float(7, exp_thresh) #exp threshold boxm2_batch.set_input_string(8, bbox_file) #bb filename return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def get_geocam_footprint(geocam, geotiff_filename, out_kml_filename,init_finish=True): boxm2_batch.init_process('vpglGeoFootprintProcess') boxm2_batch.set_input_from_db(0,geocam); boxm2_batch.set_input_string(1,geotiff_filename); boxm2_batch.set_input_string(2,out_kml_filename); boxm2_batch.set_input_bool(3,init_finish); boxm2_batch.run_process()
def vrml_filter_ply(vrml_filename, ply_file, points_file, dist_threshold,nearest=False): boxm2_batch.init_process("bvrmlFilteredPlyProcess"); boxm2_batch.set_input_string(0,vrml_filename); boxm2_batch.set_input_string(1,ply_file); boxm2_batch.set_input_string(2,points_file); boxm2_batch.set_input_float(3,dist_threshold); boxm2_batch.set_input_bool(4,nearest); boxm2_batch.run_process();
def write_cache(cache, do_clear=0): if cache.type == "boxm2_cache_sptr": boxm2_batch.init_process("boxm2WriteCacheProcess") boxm2_batch.set_input_from_db(0, cache) boxm2_batch.set_input_bool(1, do_clear) boxm2_batch.run_process() else: print "ERROR: Cache type needs to be boxm2_cache_sptr, not ", cache.type
def truncate_nitf_image(img, is_short = True): boxm2_batch.init_process("bripTruncateNITFBitProcess"); boxm2_batch.set_input_from_db(0, img); boxm2_batch.set_input_bool(1, is_short); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); out_img = dbvalue(id, type); return out_img;
def truncate_nitf_image(img, is_short=True, is_scale=True): boxm2_batch.init_process("bripTruncateNITFBitProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_bool(1, is_short) boxm2_batch.set_input_bool(2, is_scale) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out_img = dbvalue(id, type) return out_img
def compute_camera_to_world_homography(cam,plane,inverse = False): boxm2_batch.init_process("vpglComputeImageToWorldHomographyProcess"); boxm2_batch.set_input_from_db(0, cam); boxm2_batch.set_input_float_array(1, plane); boxm2_batch.set_input_bool(2, inverse); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); homg2d = boxm2_batch.get_bbas_1d_array_float(id); return homg2d
def compute_camera_to_world_homography(cam, plane, inverse=False): boxm2_batch.init_process("vpglComputeImageToWorldHomographyProcess") boxm2_batch.set_input_from_db(0, cam) boxm2_batch.set_input_float_array(1, plane) boxm2_batch.set_input_bool(2, inverse) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) homg2d = boxm2_batch.get_bbas_1d_array_float(id) return homg2d
def threshold_image(img, value, threshold_above=True): boxm2_batch.init_process("vilThresholdImageProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_float(1, value) boxm2_batch.set_input_bool(2, threshold_above) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mask = dbvalue(id, type) return mask
def threshold_image(img, value, threshold_above=True): boxm2_batch.init_process("vilThresholdImageProcess") boxm2_batch.set_input_from_db(0,img) boxm2_batch.set_input_float(1,value) boxm2_batch.set_input_bool(2,threshold_above) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) mask = dbvalue(id,type) return mask
def add_to_filter_bank(tclsf, img_name, plane, filter_folder, filter_name, is_gauss_smooth = True): boxm2_batch.init_process("sdetAddtoFilterBankProcess"); boxm2_batch.set_input_from_db(0,tclsf); # classifier instance boxm2_batch.set_input_string(1,img_name); boxm2_batch.set_input_unsigned(2,plane); ## pass which plane to extract the gauss response from boxm2_batch.set_input_string(3,filter_folder); boxm2_batch.set_input_string(4,filter_name); ## pass a unique name to be used to write to filter_folder boxm2_batch.set_input_bool(5,is_gauss_smooth) boxm2_batch.run_process();
def estimate_shadows(image, metadata, atmospheric_params): boxm2_batch.init_process("bradEstimateShadowsProcess") boxm2_batch.set_input_from_db(0, image) boxm2_batch.set_input_from_db(1, metadata) boxm2_batch.set_input_from_db(2, atmospheric_params) boxm2_batch.set_input_bool(3, False) # False returns probability value boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) shadow_probs = dbvalue(id, type) return shadow_probs
def threshold_image_inside(img, min_thres, max_thres, threshold_inside=True): boxm2_batch.init_process("vilThresholdImageInsideProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_float(1, min_thres) boxm2_batch.set_input_float(2, max_thres) boxm2_batch.set_input_bool(3, threshold_inside) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mask = dbvalue(id, type) return mask
def estimate_shadows(image, metadata, atmospheric_params): boxm2_batch.init_process("bradEstimateShadowsProcess") boxm2_batch.set_input_from_db(0,image) boxm2_batch.set_input_from_db(1,metadata) boxm2_batch.set_input_from_db(2,atmospheric_params) boxm2_batch.set_input_bool(3,False) # False returns probability value boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) shadow_probs = dbvalue(id,type) return shadow_probs
def texture_training(tclsf, image, exp_poly_path,texton_dict_path, name_of_category="mod", compute_textons=True): boxm2_batch.init_process("sdetTextureTrainingProcess"); boxm2_batch.set_input_from_db(0,tclsf); boxm2_batch.set_input_bool(1,compute_textons);# compute textons boxm2_batch.set_input_from_db(2,image); boxm2_batch.set_input_string(3,exp_poly_path); boxm2_batch.set_input_string(4,name_of_category); boxm2_batch.set_input_string(5,texton_dict_path); boxm2_batch.run_process(); # write out the texton dictionary on finish boxm2_batch.finish_process();
def convert_reflectance_to_digital_count(reflectance_image, metadata, atmospheric_params, normalize_0_1 = False, max_digital_count = 2047): boxm2_batch.init_process("bradConvertReflectanceToDigitalCountProcess") boxm2_batch.set_input_from_db(0,reflectance_image) boxm2_batch.set_input_from_db(1,metadata) boxm2_batch.set_input_from_db(2,atmospheric_params) boxm2_batch.set_input_bool(3,normalize_0_1) boxm2_batch.set_input_unsigned(4,max_digital_count) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) output_img = dbvalue(id,type) return output_img
def create_mask_image(scene, camera, ni, nj, ground_plane_only=False): boxm2_batch.init_process("boxm2CreateSceneMaskProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, camera) boxm2_batch.set_input_unsigned(2, ni) boxm2_batch.set_input_unsigned(3, nj) boxm2_batch.set_input_bool(4, ground_plane_only) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mask = dbvalue(id, type) return mask
def make_inside_empty(scene, cache, device, use_sum=False): if cache.type == "boxm2_opencl_cache_sptr": print("Flipping Normal") boxm2_batch.init_process("boxm2OclMakeInsideVoxelsEmptyProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_bool(3, use_sum) return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def flip_normals(scene, cache, device, use_sum=False): if cache.type == "boxm2_opencl_cache_sptr": print("Flipping Normal") boxm2_batch.init_process("boxm2OclFlipNormalsUsingVisProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_bool(3, use_sum) return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def estimate_atmospheric_parameters(image, metadata, mean_reflectance = None, constrain_parameters=None): boxm2_batch.init_process("bradEstimateAtmosphericParametersProcess") boxm2_batch.set_input_from_db(0,image) boxm2_batch.set_input_from_db(1,metadata) if mean_reflectance != None: boxm2_batch.set_input_float(2,mean_reflectance) if constrain_parameters != None: boxm2_batch.set_input_bool(3, constrain_parameters) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id,type) return atm_params
def vrml_filter_ply(vrml_filename, ply_file, points_file, dist_threshold, nearest=False): boxm2_batch.init_process("bvrmlFilteredPlyProcess") boxm2_batch.set_input_string(0, vrml_filename) boxm2_batch.set_input_string(1, ply_file) boxm2_batch.set_input_string(2, points_file) boxm2_batch.set_input_float(3, dist_threshold) boxm2_batch.set_input_bool(4, nearest) boxm2_batch.run_process()
def correct_cam_rotation(img, pcam, exp_img, cone_half_angle, n_steps, refine=True): boxm2_batch.init_process('icamCorrectCamRotationProcess') boxm2_batch.set_input_from_db(0,img) boxm2_batch.set_input_from_db(1,pcam) boxm2_batch.set_input_from_db(2,exp_img) boxm2_batch.set_input_float(3,cone_half_angle) boxm2_batch.set_input_unsigned(4,n_steps) boxm2_batch.set_input_bool(5,refine) boxm2_batch.run_process() (m_id,m_type) = boxm2_batch.commit_output(0) mapped_img = dbvalue(m_id,m_type); (c_id,c_type) = boxm2_batch.commit_output(1) corr_cam = dbvalue(c_id,c_type); return mapped_img, corr_cam
def vrml_write_box(vrml_filename, bbox, is_wire, r, g, b): boxm2_batch.init_process("bvrmlWriteBoxProcess"); boxm2_batch.set_input_string(0,vrml_filename); boxm2_batch.set_input_double(1,bbox[0]); # minx boxm2_batch.set_input_double(2,bbox[1]); # miny boxm2_batch.set_input_double(3,bbox[2]); # minz boxm2_batch.set_input_double(4,bbox[3]); # maxx boxm2_batch.set_input_double(5,bbox[4]); # maxy boxm2_batch.set_input_double(6,bbox[5]); # maxz boxm2_batch.set_input_bool(7,is_wire); boxm2_batch.set_input_float(8,r); boxm2_batch.set_input_float(9,g); boxm2_batch.set_input_float(10,b); boxm2_batch.run_process();
def vrml_write_box(vrml_filename, bbox, is_wire, r, g, b): boxm2_batch.init_process("bvrmlWriteBoxProcess") boxm2_batch.set_input_string(0, vrml_filename) boxm2_batch.set_input_double(1, bbox[0]) # minx boxm2_batch.set_input_double(2, bbox[1]) # miny boxm2_batch.set_input_double(3, bbox[2]) # minz boxm2_batch.set_input_double(4, bbox[3]) # maxx boxm2_batch.set_input_double(5, bbox[4]) # maxy boxm2_batch.set_input_double(6, bbox[5]) # maxz boxm2_batch.set_input_bool(7, is_wire) boxm2_batch.set_input_float(8, r) boxm2_batch.set_input_float(9, g) boxm2_batch.set_input_float(10, b) boxm2_batch.run_process()
def convert_reflectance_to_digital_count(reflectance_image, metadata, atmospheric_params, normalize_0_1=False, max_digital_count=2047): boxm2_batch.init_process("bradConvertReflectanceToDigitalCountProcess") boxm2_batch.set_input_from_db(0, reflectance_image) boxm2_batch.set_input_from_db(1, metadata) boxm2_batch.set_input_from_db(2, atmospheric_params) boxm2_batch.set_input_bool(3, normalize_0_1) boxm2_batch.set_input_unsigned(4, max_digital_count) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) output_img = dbvalue(id, type) return output_img
def update_multi(scene, mcache, cam, img, ident="", update_alpha=True, var=-1.0, update_app=True, tnear=100000.0, tfar=0.000001): # If no device is passed in, do cpu update print("boxm2_batch multi GPU update") boxm2_batch.init_process("boxm2MultiUpdateProcess") boxm2_batch.set_input_from_db(0, mcache) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cam) boxm2_batch.set_input_from_db(3, img) boxm2_batch.set_input_string(4, ident) boxm2_batch.set_input_bool(5, update_alpha) boxm2_batch.set_input_float(6, var) boxm2_batch.set_input_bool(7, update_app) boxm2_batch.set_input_float(8, tnear) boxm2_batch.set_input_float(9, tfar) return boxm2_batch.run_process()
def estimate_atmospheric_parameters(image, metadata, mean_reflectance=None, constrain_parameters=None): boxm2_batch.init_process("bradEstimateAtmosphericParametersProcess") boxm2_batch.set_input_from_db(0, image) boxm2_batch.set_input_from_db(1, metadata) if mean_reflectance != None: boxm2_batch.set_input_float(2, mean_reflectance) if constrain_parameters != None: boxm2_batch.set_input_bool(3, constrain_parameters) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id, type) return atm_params
def train_classifier(tclsf, poly_file, category_name, dictionary_name, compute_category_textons, finish_and_write_dictionary): boxm2_batch.init_process("sdetTextureTrainingProcess2"); boxm2_batch.set_input_from_db(0,tclsf); if compute_category_textons: boxm2_batch.set_input_bool(1,1); # compute the textons if this is the last polygon file for the category else: boxm2_batch.set_input_bool(1,0); boxm2_batch.set_input_string(2, poly_file); boxm2_batch.set_input_string(3, category_name); boxm2_batch.set_input_string(4, dictionary_name); boxm2_batch.run_process(); (tclsf_id, tclsf_type)=boxm2_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); if finish_and_write_dictionary: boxm2_batch.finish_process(); return tclsf
def compute_sun_affine_camera(scene, sun_az, sun_el, astro_coords=True): boxm2_batch.init_process("boxm2ComputeSunAffineCameraProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_float(1, sun_el) boxm2_batch.set_input_float(2, sun_az) boxm2_batch.set_input_bool(3, astro_coords) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) sun_cam = dbvalue(id, type) (ni_id, type) = boxm2_batch.commit_output(1) (nj_id, type) = boxm2_batch.commit_output(2) ni = boxm2_batch.get_output_unsigned(ni_id) nj = boxm2_batch.get_output_unsigned(nj_id) boxm2_batch.remove_data(ni_id) boxm2_batch.remove_data(nj_id) return sun_cam, ni, nj
def texture_training(tclsf, image, exp_poly_path, texton_dict_path, name_of_category="mod", compute_textons=True): boxm2_batch.init_process("sdetTextureTrainingProcess") boxm2_batch.set_input_from_db(0, tclsf) boxm2_batch.set_input_bool(1, compute_textons) # compute textons boxm2_batch.set_input_from_db(2, image) boxm2_batch.set_input_string(3, exp_poly_path) boxm2_batch.set_input_string(4, name_of_category) boxm2_batch.set_input_string(5, texton_dict_path) boxm2_batch.run_process() # write out the texton dictionary on finish boxm2_batch.finish_process()
def change_detect(scene, cache, cam, img, exp_img, device=None, rgb=False, n=1, raybelief="", max_mode=False): if cache.type == "boxm2_cache_sptr": print "boxm2_batch CPU change detection" boxm2_batch.init_process("boxm2CppChangeDetectionProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_from_db(2, cam) boxm2_batch.set_input_from_db(3, img) boxm2_batch.set_input_from_db(4, exp_img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cd_img = dbvalue(id, type) return cd_img elif cache.type == "boxm2_opencl_cache_sptr" and device: print "boxm2_batch GPU change detection" boxm2_batch.init_process("boxm2OclChangeDetectionProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_from_db(3, cam) boxm2_batch.set_input_from_db(4, img) boxm2_batch.set_input_from_db(5, exp_img) boxm2_batch.set_input_int(6, n) boxm2_batch.set_input_string(7, raybelief) boxm2_batch.set_input_bool(8, max_mode) boxm2_batch.run_process() if not rgb: (id, type) = boxm2_batch.commit_output(0) cd_img = dbvalue(id, type) else: (id, type) = boxm2_batch.commit_output(1) cd_img = dbvalue(id, type) return cd_img else: print "ERROR: Cache type not recognized: ", cache.type
def correct_cam_rotation(img, pcam, exp_img, cone_half_angle, n_steps, refine=True): boxm2_batch.init_process('icamCorrectCamRotationProcess') boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_from_db(1, pcam) boxm2_batch.set_input_from_db(2, exp_img) boxm2_batch.set_input_float(3, cone_half_angle) boxm2_batch.set_input_unsigned(4, n_steps) boxm2_batch.set_input_bool(5, refine) boxm2_batch.run_process() (m_id, m_type) = boxm2_batch.commit_output(0) mapped_img = dbvalue(m_id, m_type) (c_id, c_type) = boxm2_batch.commit_output(1) corr_cam = dbvalue(c_id, c_type) return mapped_img, corr_cam
def update_rgb(scene, cache, cam, img, device=None, mask="", updateAlpha=True): #If no device is passed in, do cpu update if cache.type == "boxm2_cache_sptr": print "boxm2_batch rgb CPU update not implemented" elif cache.type == "boxm2_opencl_cache_sptr" and device: print("boxm2_batch GPU update") boxm2_batch.init_process("boxm2OclUpdateColorProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, cache) boxm2_batch.set_input_from_db(3, cam) boxm2_batch.set_input_from_db(4, img) boxm2_batch.set_input_string(5, "") #identifier boxm2_batch.set_input_string(6, mask) #mask file boxm2_batch.set_input_bool(7, updateAlpha) boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type
def get_single_nitf_footprint(nitf_filename, out_kml_filename="",isKml = False, metafolder =""): boxm2_batch.init_process('vpglNITFFootprintProcess2'); boxm2_batch.set_input_string(0,nitf_filename); boxm2_batch.set_input_string(1,out_kml_filename); boxm2_batch.set_input_bool(2,isKml); boxm2_batch.set_input_string(3,metafolder); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); llon = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(1); llat = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(2); lele = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(3); rlon = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(4); rlat = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(5); rele = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); return llon, llat, lele, rlon, rlat, rele
def generate_xyz_from_dem(scene, refine_level, geotiff_dem, geoid_height, bilin=False): boxm2_batch.init_process("boxm2DemToXYZProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_unsigned(1, refine_level) boxm2_batch.set_input_string(2, geotiff_dem) boxm2_batch.set_input_double(3, geoid_height) boxm2_batch.set_input_bool(4, bilin) boxm2_batch.run_process() (xi_id, xi_type) = boxm2_batch.commit_output(0) x_img = dbvalue(xi_id, xi_type) (yi_id, yi_type) = boxm2_batch.commit_output(1) y_img = dbvalue(yi_id, yi_type) (zi_id, zi_type) = boxm2_batch.commit_output(2) z_img = dbvalue(zi_id, zi_type) (dem_id, dem_type) = boxm2_batch.commit_output(3) dem_img = dbvalue(dem_id, dem_type) (demr_id, demr_type) = boxm2_batch.commit_output(4) dem_res_img = dbvalue(demr_id, demr_type) return x_img, y_img, z_img, dem_img, dem_res_img
def get_single_nitf_footprint(nitf_filename, out_kml_filename="", isKml=False, metafolder=""): boxm2_batch.init_process('vpglNITFFootprintProcess2') boxm2_batch.set_input_string(0, nitf_filename) boxm2_batch.set_input_string(1, out_kml_filename) boxm2_batch.set_input_bool(2, isKml) boxm2_batch.set_input_string(3, metafolder) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) llon = boxm2_batch.get_output_double(id) (id, type) = boxm2_batch.commit_output(1) llat = boxm2_batch.get_output_double(id) (id, type) = boxm2_batch.commit_output(2) lele = boxm2_batch.get_output_double(id) (id, type) = boxm2_batch.commit_output(3) rlon = boxm2_batch.get_output_double(id) (id, type) = boxm2_batch.commit_output(4) rlat = boxm2_batch.get_output_double(id) (id, type) = boxm2_batch.commit_output(5) rele = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) return llon, llat, lele, rlon, rlat, rele
def write_mcache(mcache, do_clear=0): boxm2_batch.init_process("boxm2WriteMultiCacheProcess") boxm2_batch.set_input_from_db(0, mcache) boxm2_batch.set_input_bool(1, do_clear) boxm2_batch.run_process()