def load_projective_camera(file_path): boxm2_batch.init_process("vpglLoadProjCameraProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def get_3d_point_from_index(scene,cache,block_index, index): #Warning, you probably shouldn't be doing this! boxm2_batch.init_process("boxm2CppGet3dPointFromIndexProcess"); boxm2_batch.set_input_from_db(0, scene); boxm2_batch.set_input_from_db(1, cache); boxm2_batch.set_input_int(2, block_index[0]); boxm2_batch.set_input_int(3, block_index[1]); boxm2_batch.set_input_int(4, block_index[2]); boxm2_batch.set_input_int(5, index); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); x=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(1); y=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(2); z=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(3); xs=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(4); ys=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(5); zs=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(6); leaf=boxm2_batch.get_output_int(id); boxm2_batch.remove_data(id); return ((x, y, z), (xs, ys, zs), leaf)
def load_rational_camera_nitf(file_path): boxm2_batch.init_process("vpglLoadRationalCameraNITFProcess") boxm2_batch.set_input_string(0, file_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) cam = dbvalue(id, type) return cam
def load_classifier(classifier_name): boxm2_batch.init_process("sdetLoadTextureClassifierProcess"); boxm2_batch.set_input_string(0,classifier_name); boxm2_batch.run_process(); (tclsf_id, tclsf_type)=boxm2_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
def load_dictionary(dictionary_name): boxm2_batch.init_process("sdetLoadTextureDictionaryProcess"); boxm2_batch.set_input_string(0,dictionary_name); boxm2_batch.run_process(); (tclsf_id, tclsf_type)=boxm2_batch.commit_output(0); tclsf = dbvalue(tclsf_id, tclsf_type); return tclsf
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 generate_roc(tclsf, class_out_prob_img, class_out_color_img, orig_img, prefix_for_bin_files, positive_category_name,category_id_file): boxm2_batch.init_process("sdetTextureClassifierROCProcess"); boxm2_batch.set_input_from_db(0, tclsf); boxm2_batch.set_input_from_db(1, class_out_prob_img); boxm2_batch.set_input_from_db(2, class_out_color_img); boxm2_batch.set_input_from_db(3, orig_img); boxm2_batch.set_input_string(4, prefix_for_bin_files); boxm2_batch.set_input_string(5, positive_category_name); boxm2_batch.set_input_string(6, category_id_file); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); tp = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(1); tn = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(2); fp = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(3); fn = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(4); tpr = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(5); fpr = boxm2_batch.get_bbas_1d_array_float(id); boxm2_batch.remove_data(id); (id,type) = boxm2_batch.commit_output(6); outimg = dbvalue(id,type); return tp, tn, fp, fn, tpr, fpr, outimg;
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 import_triangle_mesh(scene, cache, ply_filename, occupied_prob=0.99): boxm2_batch.init_process("boxm2ImportTriangleMeshProcess") boxm2_batch.set_input_from_db(0,scene) boxm2_batch.set_input_from_db(1,cache) boxm2_batch.set_input_string(2,ply_filename) boxm2_batch.set_input_float(3,occupied_prob) boxm2_batch.run_process()
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 paint_mesh(scene,cache,in_file,out_file): boxm2_batch.init_process("boxm2PaintMeshProcess"); 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_string(3,out_file); boxm2_batch.run_process();
def load_mesh(filename): boxm2_batch.init_process("boxm2LoadMeshProcess"); boxm2_batch.set_input_string(0,filename); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); mesh = dbvalue(id, type); return mesh;
def gen_tex_mesh(mesh,in_img_dir, in_cam_dir,out_dir): boxm2_batch.init_process("boxm2TextureMeshProcess"); boxm2_batch.set_input_from_db(0,mesh); boxm2_batch.set_input_string(1,in_img_dir); boxm2_batch.set_input_string(2,in_cam_dir); boxm2_batch.set_input_string(3,out_dir); boxm2_batch.run_process();
def load_atmospheric_parameters(filename): boxm2_batch.init_process("bradLoadAtmosphericParametersProcess") boxm2_batch.set_input_string(0,filename) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id,type) return atm_params
def load_eigenspace(filename): boxm2_batch.init_process("bradLoadEigenspaceProcess"); boxm2_batch.set_input_string(0, filename); boxm2_batch.run_process(); (eig_id,eig_type)=boxm2_batch.commit_output(0); eig = dbvalue(eig_id, eig_type); return eig;
def texture_classifier_kernel_margin(dictionary): boxm2_batch.init_process("sdetTextureClassifierKernelMarginProcess"); boxm2_batch.set_input_string(0,dictionary); boxm2_batch.run_process(); (m_id, m_type) = boxm2_batch.commit_output(0); margin = boxm2_batch.get_output_int(m_id); return margin;
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 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 load_joint_hist3d(filename): boxm2_batch.init_process("bstaLoadJointHist3dProcess"); boxm2_batch.set_input_string(0,filename); boxm2_batch.run_process(); (h_id,h_type) = boxm2_batch.commit_output(0); h = dbvalue(h_id, h_type); return h
def offset_cam_using_3d_box(camera, lower_left_lon, lower_left_lat, lower_left_elev, upper_right_lon, upper_right_lat, upper_right_elev, uncertainty, lvcs=None): boxm2_batch.init_process("vpglOffsetCamUsing3DboxProcess"); boxm2_batch.set_input_from_db(0, camera); boxm2_batch.set_input_double(1, lower_left_lon); boxm2_batch.set_input_double(2, lower_left_lat); boxm2_batch.set_input_double(3, lower_left_elev); boxm2_batch.set_input_double(4, upper_right_lon); boxm2_batch.set_input_double(5, upper_right_lat); boxm2_batch.set_input_double(6, upper_right_elev); boxm2_batch.set_input_double(7, uncertainty); if lvcs: boxm2_batch.set_input_from_db(8, lvcs); status = boxm2_batch.run_process(); if status: (id, type) = boxm2_batch.commit_output(0); local_cam = dbvalue(id, type); (id, type) = boxm2_batch.commit_output(1); i0 = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id); (id, type) = boxm2_batch.commit_output(2); j0 = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id); (id, type) = boxm2_batch.commit_output(3); ni = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id); (id, type) = boxm2_batch.commit_output(4); nj = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id); return status, local_cam, i0, j0, ni, nj; else: return status, dbvalue(0, ""), 0, 0, 0, 0;
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 load_lvcs(lvcs_filename): boxm2_batch.init_process("vpglLoadLVCSProcess"); boxm2_batch.set_input_string(0, lvcs_filename); boxm2_batch.run_process(); (lvcs_id, lvcs_type) = boxm2_batch.commit_output(0); lvcs = dbvalue(lvcs_id, lvcs_type); return lvcs;
def get_3d_from_cams( cams, points ): assert( len(cams) == len(points) and len(cams) > 1 ); #list of points will just be [u1,v1,u2,v2...]; ptlist = []; for p in points: ptlist.append(p[0]); ptlist.append(p[1]); #list of cam ids (type will be checked in C++); camlist = []; for cam in cams: camlist.append(cam.id); boxm2_batch.init_process("vpglGenerate3dPointFromCamsProcess"); boxm2_batch.set_input_unsigned_array(0, camlist); boxm2_batch.set_input_int_array(1, ptlist); boxm2_batch.run_process(); (id, type) = boxm2_batch.commit_output(0); x=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id, type) = boxm2_batch.commit_output(1); y=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); (id, type) = boxm2_batch.commit_output(2); z=boxm2_batch.get_output_float(id); boxm2_batch.remove_data(id); return x,y,z;
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 convert_local_rational_perspective_camera(local_cam) : boxm2_batch.init_process("vpglConvertLocalRationalToPerspectiveProcess"); boxm2_batch.set_input_from_db(0, local_cam); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
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 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 load_local_rational_camera(file_path) : boxm2_batch.init_process("vpglLoadLocalRationalCameraProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
def load_perspective_camera(file_path) : boxm2_batch.init_process("vpglLoadPerspectiveCameraProcess"); boxm2_batch.set_input_string(0, file_path); boxm2_batch.run_process(); (id,type) = boxm2_batch.commit_output(0); cam = dbvalue(id,type); return cam;
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): boxm2_batch.init_process("vpglCropImgUsing3DboxProcess") boxm2_batch.set_input_from_db(0, img_res) boxm2_batch.set_input_from_db(1, camera) boxm2_batch.set_input_double(2, lower_left_lon) boxm2_batch.set_input_double(3, lower_left_lat) boxm2_batch.set_input_double(4, lower_left_elev) boxm2_batch.set_input_double(5, upper_right_lon) boxm2_batch.set_input_double(6, upper_right_lat) boxm2_batch.set_input_double(7, upper_right_elev) boxm2_batch.set_input_double(8, uncertainty) if lvcs: boxm2_batch.set_input_from_db(9, lvcs) status = boxm2_batch.run_process() if status: (id, type) = boxm2_batch.commit_output(0) local_cam = dbvalue(id, type) (id, type) = boxm2_batch.commit_output(1) i0 = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(2) j0 = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(3) ni = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(4) nj = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) return status, local_cam, i0, j0, ni, nj else: return status, dbvalue(0, ""), 0, 0, 0, 0
def scene_illumination_info(scene): boxm2_batch.init_process("boxm2SceneIlluminationInfoProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.run_process() (lon_id, lon_type) = boxm2_batch.commit_output(0) longitude = boxm2_batch.get_output_float(lon_id) (lat_id, lat_type) = boxm2_batch.commit_output(1) latitude = boxm2_batch.get_output_float(lat_id) (nb_id, nb_type) = boxm2_batch.commit_output(2) nbins = boxm2_batch.get_output_int(nb_id) return longitude, latitude, nbins
def resample_perspective_camera(cam, size0, size1): boxm2_batch.init_process("vpglResamplePerspectiveCameraProcess") boxm2_batch.set_input_from_db(0, cam) boxm2_batch.set_input_int(1, size0[0]) boxm2_batch.set_input_int(2, size0[1]) boxm2_batch.set_input_int(3, size1[0]) boxm2_batch.set_input_int(4, size1[1]) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out = dbvalue(id, type) return out
def grey_to_rgb(img, color_txt): boxm2_batch.init_process("vilGreyToRGBProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_string(1, color_txt) result = boxm2_batch.run_process() if result: (id, type) = boxm2_batch.commit_output(0) outimg = dbvalue(id, type) else: outimg = 0 return outimg
def crop_image_res(img_res, i0, j0, ni, nj): boxm2_batch.init_process("vilCropImageResProcess") boxm2_batch.set_input_from_db(0, img_res) boxm2_batch.set_input_unsigned(1, i0) boxm2_batch.set_input_unsigned(2, j0) boxm2_batch.set_input_unsigned(3, ni) boxm2_batch.set_input_unsigned(4, nj) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
def image_range(img): boxm2_batch.init_process('vilImageRangeProcess') boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) minVal = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) maxVal = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return minVal, maxVal
def image_size(img): boxm2_batch.init_process('vilImageSizeProcess') boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) ni = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) nj = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) return ni, nj
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 geo2generic(geocam, ni, nj, scene_height, level): boxm2_batch.init_process("vpglConvertGeoCameraToGenericProcess") boxm2_batch.set_input_from_db(0, geocam) boxm2_batch.set_input_int(1, ni) boxm2_batch.set_input_int(2, nj) boxm2_batch.set_input_double(3, scene_height) boxm2_batch.set_input_int(4, level) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def geo_cam_global_to_img(geocam, lon, lat): boxm2_batch.init_process("vpglGeoGlobalToImgProcess") boxm2_batch.set_input_from_db(0, geocam) boxm2_batch.set_input_double(1, lon) boxm2_batch.set_input_double(2, lat) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) u = boxm2_batch.get_output_int(id) (id, type) = boxm2_batch.commit_output(1) v = boxm2_batch.get_output_int(id) return u, v
def get_perspective_cam_center(pcam): boxm2_batch.init_process("vpglGetPerspectiveCamCenterProcess") boxm2_batch.set_input_from_db(0, pcam) boxm2_batch.run_process() (x_id, x_type) = boxm2_batch.commit_output(0) x = boxm2_batch.get_output_float(x_id) (y_id, type) = boxm2_batch.commit_output(1) y = boxm2_batch.get_output_float(y_id) (z_id, type) = boxm2_batch.commit_output(2) z = boxm2_batch.get_output_float(z_id) return x, y, z
def load_geotiff_cam(tfw_filename, lvcs=0, utm_zone=0, utm_hemisphere=0): boxm2_batch.init_process("vpglLoadGeoCameraProcess") boxm2_batch.set_input_string(0, tfw_filename) if lvcs != 0: 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 get_rational_camera_offsets(cam_in): boxm2_batch.init_process('vpglGetRationalCameraOffsetsProcess') boxm2_batch.set_input_from_db(0, cam_in) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) offset_u = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) offset_v = boxm2_batch.get_output_double(id) boxm2_batch.remove_data(id) return (offset_u, offset_v)
def write_perspective_cam_vrml(vrml_filename, pcam, camera_rad, axis_length, r, g, b): boxm2_batch.init_process("bvrmlWritePerspectiveCamProcess") boxm2_batch.set_input_string(0, vrml_filename) boxm2_batch.set_input_from_db(1, pcam) boxm2_batch.set_input_float(2, camera_rad) boxm2_batch.set_input_float(3, axis_length) boxm2_batch.set_input_float(4, r) boxm2_batch.set_input_float(5, g) boxm2_batch.set_input_float(6, b) boxm2_batch.run_process()
def create_atmospheric_parameters(airlight=0.0, skylight=0.0, optical_depth=0.0): boxm2_batch.init_process("bradCreateAtmosphericParametersProcess") boxm2_batch.set_input_float(0, airlight) boxm2_batch.set_input_float(1, skylight) boxm2_batch.set_input_float(2, optical_depth) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id, type) return atm_params
def gen_mesh(z_img, x_img, y_img, out_dir): boxm2_batch.init_process("boxm2ExportMeshProcess") boxm2_batch.set_input_from_db(0, z_img) boxm2_batch.set_input_from_db(1, x_img) boxm2_batch.set_input_from_db(2, y_img) boxm2_batch.set_input_string(3, out_dir) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mesh = dbvalue(id, type) return mesh
def extract_cell_centers(scene, cache, prob_thresh=0.0): if cache.type == "boxm2_cache_sptr": 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, prob_thresh) #prob t return boxm2_batch.run_process() else: print "ERROR: Cache type not recognized: ", cache.type return False
def get_sun_angles(mdata): boxm2_batch.init_process("bradGetSunAnglesProcess") boxm2_batch.set_input_from_db(0, mdata) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) sun_az = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) sun_el = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return sun_az, sun_el
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 sun_angles(image_path): boxm2_batch.init_process('bbasSunAnglesProcess') boxm2_batch.set_input_string(0, image_path) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) sun_el = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) (id, type) = boxm2_batch.commit_output(1) sun_az = boxm2_batch.get_output_float(id) boxm2_batch.remove_data(id) return (sun_az, sun_el)
def update_parents_alpha(scene, cache, device) : if cache.type == "boxm2_opencl_cache_sptr": print("Update Parents Alpha"); boxm2_batch.init_process("boxm2OclUpdateParentsAlphaProcess"); boxm2_batch.set_input_from_db(0,device); boxm2_batch.set_input_from_db(1,scene); boxm2_batch.set_input_from_db(2,cache); return boxm2_batch.run_process(); else : print "ERROR: Cache type not recognized: ", cache.type; return False;
def save_sun_index(output_file_name, longitude, latitude, year, hour, minute, radius): boxm2_batch.init_process("bradSaveSunIndexProcess") boxm2_batch.set_input_string(0, output_file_name) boxm2_batch.set_input_float(1, longitude) boxm2_batch.set_input_float(2, latitude) boxm2_batch.set_input_int(3, year) boxm2_batch.set_input_int(4, hour) boxm2_batch.set_input_int(5, minute) boxm2_batch.set_input_int(6, radius) boxm2_batch.run_process()
def blob_change_detection(change_img, thresh, depth1=None, depth2=None): boxm2_batch.init_process("boxm2BlobChangeDetectionProcess") boxm2_batch.set_input_from_db(0, change_img) boxm2_batch.set_input_float(1, thresh) if (depth1 and depth2): boxm2_batch.set_input_from_db(2, depth1) boxm2_batch.set_input_from_db(3, depth2) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) blobImg = dbvalue(id, type) return blobImg
def update_PusingQ(scene,device,opencl_cache,operation = 2,view_ident=""): #print("Init Manager"); boxm2_batch.init_process("boxm2OclUpdateUsingQProcess"); boxm2_batch.set_input_from_db(0, device); boxm2_batch.set_input_from_db(1, scene); boxm2_batch.set_input_from_db(2, opencl_cache); boxm2_batch.set_input_int(3, operation); boxm2_batch.set_input_string(4, view_ident); status = boxm2_batch.run_process(); if(status != True): print "Error in Running Aux Q ";
def clear_cache(cache): if cache.type == "boxm2_cache_sptr": boxm2_batch.init_process("boxm2ClearCacheProcess") boxm2_batch.set_input_from_db(0, cache) boxm2_batch.run_process() elif cache.type == "boxm2_opencl_cache_sptr": boxm2_batch.init_process("boxm2ClearOpenclCacheProcess") boxm2_batch.set_input_from_db(0, cache) boxm2_batch.run_process() else: print "ERROR: Cache type needs to be boxm2_cache_sptr, not ", cache.type
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 vrml_write_point(vrml_filename, coords, radius, r, g, b): boxm2_batch.init_process("bvrmlWritePointProcess") boxm2_batch.set_input_string(0, vrml_filename) boxm2_batch.set_input_float(1, coords[0]) # x boxm2_batch.set_input_float(2, coords[1]) # y boxm2_batch.set_input_float(3, coords[2]) # z boxm2_batch.set_input_float(4, radius) # radius boxm2_batch.set_input_float(5, r) # red boxm2_batch.set_input_float(6, g) # green boxm2_batch.set_input_float(7, b) # blue boxm2_batch.run_process()
def create_stream_cache(scene, type_id_fname, image_id_fname, mem=2.0): boxm2_batch.init_process("boxm2CreateStreamCacheProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_string(1, type_id_fname) boxm2_batch.set_input_string(2, image_id_fname) boxm2_batch.set_input_float(3, mem) #number of gigabytes available for stream cache boxm2_batch.run_process() (cache_id, cache_type) = boxm2_batch.commit_output(0) strcache = dbvalue(cache_id, cache_type) return strcache
def solve_apply_gain_offset(mimg, timg, mimg_mask=None): boxm2_batch.init_process("bripSolveGainOffsetProcess") boxm2_batch.set_input_from_db(0, mimg) boxm2_batch.set_input_from_db(1, timg) if mimg_mask is not None: boxm2_batch.set_input_from_db(2, mimg_mask) out_img = None if boxm2_batch.run_process() is not False: (id, type) = boxm2_batch.commit_output(0) out_img = dbvalue(id, type) return out_img
def ocl_info(): print("Init Manager") boxm2_batch.init_process("boclInitManagerProcess") boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) mgr = dbvalue(id, type) print("Get OCL info") boxm2_batch.init_process("bocl_info_process") boxm2_batch.set_input_from_db(0, mgr) 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()