def interpolate_perspective_cameras(cam0, cam1, ncams, outdir): boxm2_batch.init_process("vpglInterpolatePerspectiveCamerasProcess") boxm2_batch.set_input_from_db(0, cam0) boxm2_batch.set_input_from_db(1, cam1) boxm2_batch.set_input_unsigned(2, ncams) boxm2_batch.set_input_string(3, outdir) return boxm2_batch.run_process()
def initialize_rng(seed=0): boxm2_batch.init_process("bstaInitializeRandomSeedProcess"); boxm2_batch.set_input_unsigned(0,seed); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0) rng = dbvalue(id,type) return rng
def extract_color_features(scene, cache, data_type, index): boxm2_batch.init_process("boxm2ExtractColorFeaturesProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, data_type) boxm2_batch.set_input_unsigned(3, index) boxm2_batch.run_process()
def extract_surface_features(scene, cache, type, index): boxm2_batch.init_process("boxm2ExtractSurfaceFeaturesProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, type) boxm2_batch.set_input_unsigned(3, index) boxm2_batch.run_process()
def remove_from_db(dbvals): if not isinstance(dbvals, (list, tuple)): dbvals = [dbvals] for dbval in dbvals: boxm2_batch.init_process("bbasRemoveFromDbProcess") boxm2_batch.set_input_unsigned(0, dbval.id) boxm2_batch.run_process()
def initialize_rng(seed=0): boxm2_batch.init_process("bstaInitializeRandomSeedProcess") boxm2_batch.set_input_unsigned(0, seed) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) rng = dbvalue(id, type) return rng
def remove_from_db(dbvals) : if not isinstance(dbvals, (list, tuple)) : dbvals = [dbvals] for dbval in dbvals: boxm2_batch.init_process("bbasRemoveFromDbProcess") boxm2_batch.set_input_unsigned(0, dbval.id); 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 get_info_along_ray(scene,cache,cam,u,v,prefix,identifier="") : print("Ray Probe"); boxm2_batch.init_process("boxm2CppRayProbeProcess"); 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_unsigned(3,u); boxm2_batch.set_input_unsigned(4,v); boxm2_batch.set_input_string(5,prefix); boxm2_batch.set_input_string(6,identifier); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); len_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(1); alpha_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(2); vis_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(3); tabs_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(4); res_array_1d = boxm2_batch.get_bbas_1d_array_float(id); if (prefix != "") : (id, type) = boxm2_batch.commit_output(5); data_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(6); nelems = boxm2_batch.get_output_int(id); return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d,res_array_1d, data_array_1d, nelems; else : return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d,res_array_1d;
def get_generic_cam_ray(cam, u, v): boxm2_batch.init_process("vpglGetGenericCamRayProcess"); boxm2_batch.set_input_from_db(0, cam); boxm2_batch.set_input_unsigned(1, u); boxm2_batch.set_input_unsigned(2, v); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); orig_x = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(1); orig_y = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(2); orig_z = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(3); dir_x = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(4); dir_y = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(5); dir_z = boxm2_batch.get_output_double(id); boxm2_batch.remove_data(id); return orig_x, orig_y, orig_z, dir_x, dir_y, dir_z;
def import_point_cloud(scene, cache, in_file, min_octree_depth=2): boxm2_batch.init_process("boxm2ImportPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, in_file) boxm2_batch.set_input_unsigned(3, min_octree_depth) boxm2_batch.run_process()
def test_classifier_clouds(tclsf, dictionary_name, image_resource, i, j, width, height, block_size, percent_cat_name, category_id_file=""): boxm2_batch.init_process("sdetTextureClassifySatelliteCloudsProcess"); boxm2_batch.set_input_from_db(0, tclsf); boxm2_batch.set_input_string(1, dictionary_name); boxm2_batch.set_input_from_db(2, image_resource); boxm2_batch.set_input_unsigned(3, i); boxm2_batch.set_input_unsigned(4, j); boxm2_batch.set_input_unsigned(5, width); boxm2_batch.set_input_unsigned(6, height); boxm2_batch.set_input_unsigned(7, block_size); boxm2_batch.set_input_string(8, category_id_file); boxm2_batch.set_input_string(9, percent_cat_name); status = boxm2_batch.run_process(); if status: (out_id, out_type)=boxm2_batch.commit_output(0); out_crop = dbvalue(out_id, out_type); (out_id, out_type)=boxm2_batch.commit_output(1); out_id_map = dbvalue(out_id, out_type); (out_id, out_type)=boxm2_batch.commit_output(2); out_rgb_map = dbvalue(out_id, out_type); (percent_id, percent_type) = boxm2_batch.commit_output(3); percent = boxm2_batch.get_output_float(percent_id); boxm2_batch.remove_data(percent_id) return out_crop, out_id_map, out_rgb_map, percent else: out_crop = 0; out_id_map = 0; out_rgb_map = 0; percent = 100; return out_crop, out_id_map, out_rgb_map, percent
def get_generic_cam_ray(cam, u, v): boxm2_batch.init_process("vpglGetGenericCamRayProcess") boxm2_batch.set_input_from_db(0, cam) boxm2_batch.set_input_unsigned(1, u) boxm2_batch.set_input_unsigned(2, v) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) orig_x = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) orig_y = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(2) orig_z = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(3) dir_x = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(4) dir_y = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(5) dir_z = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) return orig_x, orig_y, orig_z, dir_x, dir_y, dir_z
def get_info_along_ray(scene, cache, cam, u, v, prefix, identifier=""): print("Ray Probe") boxm2_batch.init_process("boxm2CppRayProbeProcess") 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_unsigned(3, u) boxm2_batch.set_input_unsigned(4, v) boxm2_batch.set_input_string(5, prefix) boxm2_batch.set_input_string(6, identifier) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) len_array_1d = boxm2_batch.get_bbas_1d_array_float(id) (id, type) = boxm2_batch.commit_output(1) alpha_array_1d = boxm2_batch.get_bbas_1d_array_float(id) (id, type) = boxm2_batch.commit_output(2) vis_array_1d = boxm2_batch.get_bbas_1d_array_float(id) (id, type) = boxm2_batch.commit_output(3) tabs_array_1d = boxm2_batch.get_bbas_1d_array_float(id) (id, type) = boxm2_batch.commit_output(4) res_array_1d = boxm2_batch.get_bbas_1d_array_float(id) if (prefix != ""): (id, type) = boxm2_batch.commit_output(5) data_array_1d = boxm2_batch.get_bbas_1d_array_float(id) (id, type) = boxm2_batch.commit_output(6) nelems = boxm2_batch.get_output_int(id) return len_array_1d, alpha_array_1d, vis_array_1d, tabs_array_1d, res_array_1d, data_array_1d, nelems else: return len_array_1d, alpha_array_1d, vis_array_1d, tabs_array_1d, res_array_1d
def affine_rectify_images(img1, affine_cam1, img2, affine_cam2, min_x, min_y, min_z, max_x, max_y, max_z, n_points=100): boxm2_batch.init_process("vpglAffineRectifyImagesProcess") boxm2_batch.set_input_from_db(0, img1) boxm2_batch.set_input_from_db(1, affine_cam1) boxm2_batch.set_input_from_db(2, img2) boxm2_batch.set_input_from_db(3, affine_cam2) boxm2_batch.set_input_double(4, min_x) boxm2_batch.set_input_double(5, min_y) boxm2_batch.set_input_double(6, min_z) boxm2_batch.set_input_double(7, max_x) boxm2_batch.set_input_double(8, max_y) boxm2_batch.set_input_double(9, max_z) boxm2_batch.set_input_unsigned(10, n_points) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out_img1 = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(1) out_cam1 = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(2) out_img2 = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(3) out_cam2 = dbvalue(id, type) return out_img1, out_cam1, out_img2, out_cam2
def import_point_cloud(scene,cache,in_file,min_octree_depth=2): boxm2_batch.init_process("boxm2ImportPointCloudProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,in_file); boxm2_batch.set_input_unsigned(3, min_octree_depth) boxm2_batch.run_process();
def interpolate_perspective_cameras(cam0,cam1,ncams,outdir): boxm2_batch.init_process("vpglInterpolatePerspectiveCamerasProcess"); boxm2_batch.set_input_from_db(0, cam0); boxm2_batch.set_input_from_db(1, cam1); boxm2_batch.set_input_unsigned(2, ncams); boxm2_batch.set_input_string(3, outdir); return boxm2_batch.run_process();
def generate_depth_maps(depth_scene_file, output_folder, output_name_prefix, downsampling_level=0): boxm2_batch.init_process("bpglGenerateDepthMapsProcess"); boxm2_batch.set_input_string(0,depth_scene_file); boxm2_batch.set_input_unsigned(1,downsampling_level); boxm2_batch.set_input_string(2,output_folder); boxm2_batch.set_input_string(3,output_name_prefix); boxm2_batch.run_process();
def get_info_along_ray(scene,cache,cam,u,v,prefix,identifier="") : print("Ray Probe"); boxm2_batch.init_process("boxm2CppRayProbeProcess"); 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_unsigned(3,u); boxm2_batch.set_input_unsigned(4,v); boxm2_batch.set_input_string(5,prefix); boxm2_batch.set_input_string(6,identifier); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); len_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(1); alpha_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(2); vis_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(3); tabs_array_1d = boxm2_batch.get_bbas_1d_array_float(id); if (prefix != "") : (id, type) = boxm2_batch.commit_output(4); data_array_1d = boxm2_batch.get_bbas_1d_array_float(id); (id, type) = boxm2_batch.commit_output(5); nelems = boxm2_batch.get_output_int(id); return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d, data_array_1d, nelems; else : return len_array_1d, alpha_array_1d, vis_array_1d ,tabs_array_1d;
def trajectory_direct(trajectory, index): boxm2_batch.init_process("boxm2ViewTrajectoryDirectProcess") boxm2_batch.set_input_from_db(0, trajectory) boxm2_batch.set_input_unsigned(1, index) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def get_plane(img, plane_id): boxm2_batch.init_process("vilGetPlaneProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_unsigned(1, plane_id) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_plane = dbvalue(id, type) return img_plane
def img_sum(img, plane_index=0): boxm2_batch.init_process("vilImageSumProcess") boxm2_batch.set_input_from_db(0,img) boxm2_batch.set_input_unsigned(1,plane_index) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) value = boxm2_batch.get_output_double(id) return value
def img_sum(img, plane_index=0): boxm2_batch.init_process("vilImageSumProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_unsigned(1, plane_index) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) value = boxm2_batch.get_output_double(id) return value
def mask_image_using_id(img, id_img, input_id): boxm2_batch.init_process("vilMaskImageUsingIDsProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_from_db(1, id_img) boxm2_batch.set_input_unsigned(2, input_id) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) masked_img = dbvalue(id, type) return masked_img
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 load_geotiff_cam2(filename, ni, nj): boxm2_batch.init_process("vpglLoadGeoCameraProcess2") boxm2_batch.set_input_string(0, filename) boxm2_batch.set_input_unsigned(1, ni) boxm2_batch.set_input_unsigned(2, nj) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def init_float_img(ni, nj, val): boxm2_batch.init_process("vilInitFloatImageProcess") boxm2_batch.set_input_unsigned(0, ni) boxm2_batch.set_input_unsigned(1, nj) boxm2_batch.set_input_float(2, val) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
def apply_filters_cpp(scene, cpp_cache, prob_thres, filter_basename, filter_id, octree_lvl): boxm2_batch.init_process("boxm2CppFilterResponseProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cpp_cache); boxm2_batch.set_input_float(2, prob_thres); boxm2_batch.set_input_string(3, filter_basename); boxm2_batch.set_input_unsigned(4, filter_id); #id kernel --> read the kernel from filter_basename + str(filter_id) + ".txt" boxm2_batch.set_input_unsigned(5, octree_lvl); #octree level to run kernel boxm2_batch.run_process();
def load_geotiff_cam2(filename, ni, nj): boxm2_batch.init_process("vpglLoadGeoCameraProcess2"); boxm2_batch.set_input_string(0, filename); boxm2_batch.set_input_unsigned(1, ni); boxm2_batch.set_input_unsigned(2, nj); boxm2_batch.run_process(); (c_id,c_type) = boxm2_batch.commit_output(0); cam = dbvalue(c_id,c_type); return cam;
def load_geotiff_cam(tfw_filename, lvcs, utm_zone, utm_hemisphere): boxm2_batch.init_process("vpglLoadGeoCameraProcess"); boxm2_batch.set_input_string(0, tfw_filename); boxm2_batch.set_input_from_db(1, lvcs); boxm2_batch.set_input_int(2, utm_zone); boxm2_batch.set_input_unsigned(3, utm_hemisphere); boxm2_batch.run_process() (c_id,c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id,c_type); return cam
def load_geotiff_cam(tfw_filename, lvcs, utm_zone, utm_hemisphere): boxm2_batch.init_process("vpglLoadGeoCameraProcess") boxm2_batch.set_input_string(0, tfw_filename) boxm2_batch.set_input_from_db(1, lvcs) boxm2_batch.set_input_int(2, utm_zone) boxm2_batch.set_input_unsigned(3, utm_hemisphere) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def texture_classifier(tcl, dictionary, img, block_size=64): boxm2_batch.init_process("sdetTextureClassifierProcess"); boxm2_batch.set_input_from_db(0, tcl); boxm2_batch.set_input_string(1,dictionary); boxm2_batch.set_input_from_db(2, img); boxm2_batch.set_input_unsigned(3,block_size); # size of blocks boxm2_batch.run_process(); (img_id, img_type) = boxm2_batch.commit_output(0); img_classified = dbvalue(img_id, img_type); return img_classified
def arf_seek_frame(rawStream, frame) : boxm2_batch.init_process("bilArfSeekFrameProcess") boxm2_batch.set_input_from_db(0,rawStream); boxm2_batch.set_input_unsigned(1,frame); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); img = dbvalue(id,type); (id, type) = boxm2_batch.commit_output(1); time = boxm2_batch.get_output_unsigned(id); return img, time
def threshold_image(img, value, threshold_above=True, id=255): 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.set_input_unsigned(3, id) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mask = dbvalue(id, type) return mask
def seek_frame(rawStream, frame): boxm2_batch.init_process("bilSeekFrameProcess") boxm2_batch.set_input_from_db(0, rawStream) boxm2_batch.set_input_unsigned(1, frame) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img = dbvalue(id, type) #(id, type) = boxm2_batch.commit_output(1); #time = boxm2_batch.get_output_unsigned(id); return img
def texture_classifier(tcl, dictionary, img, block_size=64): boxm2_batch.init_process("sdetTextureClassifierProcess") boxm2_batch.set_input_from_db(0, tcl) boxm2_batch.set_input_string(1, dictionary) boxm2_batch.set_input_from_db(2, img) boxm2_batch.set_input_unsigned(3, block_size) # size of blocks boxm2_batch.run_process() (img_id, img_type) = boxm2_batch.commit_output(0) img_classified = dbvalue(img_id, img_type) return img_classified
def generate_depth_maps(depth_scene_file, output_folder, output_name_prefix, downsampling_level=0): boxm2_batch.init_process("bpglGenerateDepthMapsProcess") boxm2_batch.set_input_string(0, depth_scene_file) boxm2_batch.set_input_unsigned(1, downsampling_level) boxm2_batch.set_input_string(2, output_folder) boxm2_batch.set_input_string(3, output_name_prefix) boxm2_batch.run_process()
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 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 arf_seek_frame(rawStream, frame): boxm2_batch.init_process("bilArfSeekFrameProcess") boxm2_batch.set_input_from_db(0, rawStream) boxm2_batch.set_input_unsigned(1, frame) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(1) time = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) return img, time
def texture_classifier_exp_img(tclsf, dict_expected, fimage, fexp, block_size=64): boxm2_batch.init_process("sdetExpImgClassifierProcess"); boxm2_batch.set_input_from_db(0, tclsf); boxm2_batch.set_input_string(1,dict_expected); boxm2_batch.set_input_from_db(2, fimage); boxm2_batch.set_input_from_db(3, fexp); boxm2_batch.set_input_unsigned(4,64); boxm2_batch.run_process(); (text_class_id, text_class_type) = boxm2_batch.commit_output(0); text_class = dbvalue(text_class_id, text_class_type); return text_class;
def update_sun_visibilities(scene, device, ocl_cache, cache, sun_camera, ni, nj, prefix_name): boxm2_batch.init_process("boxm2OclUpdateSunVisibilitiesProcess") boxm2_batch.set_input_from_db(0, device) boxm2_batch.set_input_from_db(1, scene) boxm2_batch.set_input_from_db(2, ocl_cache) boxm2_batch.set_input_from_db(3, cache) boxm2_batch.set_input_from_db(4, sun_camera) boxm2_batch.set_input_unsigned(5, ni) boxm2_batch.set_input_unsigned(6, nj) boxm2_batch.set_input_string(7, prefix_name) boxm2_batch.run_process()
def apply_filters_cpp(scene, cpp_cache, prob_thres, filter_basename, filter_id, octree_lvl): boxm2_batch.init_process("boxm2CppFilterResponseProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cpp_cache) boxm2_batch.set_input_float(2, prob_thres) boxm2_batch.set_input_string(3, filter_basename) boxm2_batch.set_input_unsigned(4, filter_id) #id kernel --> read the kernel from filter_basename + str(filter_id) + ".txt" boxm2_batch.set_input_unsigned(5, octree_lvl) #octree level to run kernel boxm2_batch.run_process()
def perspective_camera_from_scene(scene, cent_x, cent_y, cent_z, ni, nj): boxm2_batch.init_process("vpglPerspCameraFromSceneProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_float(1, cent_x) boxm2_batch.set_input_float(2, cent_y) boxm2_batch.set_input_float(3, cent_z) boxm2_batch.set_input_unsigned(4, ni) boxm2_batch.set_input_unsigned(5, nj) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def test_classifier(tclsf, block_size, category_id_file=""): boxm2_batch.init_process("sdetTextureClassifierProcess2"); boxm2_batch.set_input_from_db(0, tclsf); boxm2_batch.set_input_unsigned(1, block_size); boxm2_batch.set_input_string(2, category_id_file); boxm2_batch.run_process(); (out_id, out_type)=boxm2_batch.commit_output(0); out = dbvalue(out_id, out_type); (out_id, out_type)=boxm2_batch.commit_output(1); out_color = dbvalue(out_id, out_type); (out_id, out_type)=boxm2_batch.commit_output(2); out_id = dbvalue(out_id, out_type); return out, out_color, out_id
def render_multi(scene, mcache, cam, ni=1280, nj=720, ident_string="", tnear=100000.0, tfar=100000.0): boxm2_batch.init_process("boxm2MultiRenderProcess") 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_unsigned(3, ni) boxm2_batch.set_input_unsigned(4, nj) boxm2_batch.set_input_string(5, ident_string) boxm2_batch.set_input_float(6, tnear) boxm2_batch.set_input_float(7, tfar) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) exp_image = dbvalue(id, type) return exp_image
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 image_mutual_info(image1, image2, min_val, max_val, n_bins): boxm2_batch.init_process("bripImageMutualInfoProcess") boxm2_batch.set_input_from_db(0, image1) boxm2_batch.set_input_from_db(1, image2) boxm2_batch.set_input_double(2, min_val) boxm2_batch.set_input_double(3, max_val) boxm2_batch.set_input_unsigned(4, n_bins) status = boxm2_batch.run_process() if status: (id, type) = boxm2_batch.commit_output(0) mutual_info = boxm2_batch.get_output_double(id) return mutual_info else: return -1.0
def compute_affine_from_local_rational(cropped_cam, min_x, min_y, min_z, max_x, max_y, max_z, n_points=100): boxm2_batch.init_process("vpglComputeAffineFromRationalProcess"); boxm2_batch.set_input_from_db(0, cropped_cam); boxm2_batch.set_input_double(1, min_x); boxm2_batch.set_input_double(2, min_y); boxm2_batch.set_input_double(3, min_z); boxm2_batch.set_input_double(4, max_x); boxm2_batch.set_input_double(5, max_y); boxm2_batch.set_input_double(6, max_z); boxm2_batch.set_input_unsigned(7, n_points); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); out_cam = dbvalue(id, type); return out_cam
def classify_image(eig, h_no, h_atmos, input_image_filename, tile_ni, tile_nj): boxm2_batch.init_process("bradClassifyImageProcess"); boxm2_batch.set_input_from_db(0, eig); boxm2_batch.set_input_from_db(1, h_no); boxm2_batch.set_input_from_db(2, h_atmos); boxm2_batch.set_input_string(3, input_image_filename); boxm2_batch.set_input_unsigned(4, tile_ni); boxm2_batch.set_input_unsigned(5, tile_nj); boxm2_batch.run_process(); (vid, vtype) = boxm2_batch.commit_output(0); q_img = dbvalue(vid, vtype); (vid, vtype) = boxm2_batch.commit_output(1); q_img_orig_size = dbvalue(vid, vtype); return q_img, q_img_orig_size
def gen_point_cloud(scene,cache,filename,thresh = 0.3,depth=3): boxm2_batch.init_process("boxm2ExtractPointCloudProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_float(2,thresh); #prob threshold boxm2_batch.set_input_unsigned(3,depth); #prob threshold boxm2_batch.run_process(); 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,filename); boxm2_batch.set_input_float(4,0.5); boxm2_batch.run_process();
def load_perspective_camera_from_kml_file(NI, NJ, kml_file) : boxm2_batch.init_process("vpglLoadPerspCameraFromKMLFileProcess"); boxm2_batch.set_input_unsigned(0, NI); boxm2_batch.set_input_unsigned(1, NJ); boxm2_batch.set_input_string(2, kml_file); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); (id,type) = boxm2_batch.commit_output(1); longitude = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(2); latitude = boxm2_batch.get_output_double(id); (id,type) = boxm2_batch.commit_output(3); altitude = boxm2_batch.get_output_double(id); return cam, longitude, latitude, altitude;
def gen_color_point_cloud(scene, cache, filename, thresh=0.3, ident="", depth=3): boxm2_batch.init_process("boxm2ExtractPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_float(2, thresh) # prob threshold boxm2_batch.set_input_unsigned(3, depth) # prob threshold boxm2_batch.run_process() boxm2_batch.init_process("boxm2ExportColorPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, filename) boxm2_batch.set_input_float(3, thresh) boxm2_batch.set_input_string(4, ident) boxm2_batch.run_process()