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 export_stack(scene,cache,outdir,identifier): 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_string(3,identifier); boxm2_batch.run_process();
def invert_float_image(img): boxm2_batch.init_process("vilInvertFloatImageProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) inverted_img = dbvalue(id, type) return inverted_img
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): 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); 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) (id, type) = boxm2_batch.commit_output(2); j0 = boxm2_batch.get_output_unsigned(id) (id, type) = boxm2_batch.commit_output(3); ni = boxm2_batch.get_output_unsigned(id) (id, type) = boxm2_batch.commit_output(4); nj = boxm2_batch.get_output_unsigned(id) return status, local_cam, i0, j0, ni, nj; else: return status, dbvalue(0, ""), 0, 0, 0, 0;
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 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 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 scale_and_offset_values(img, scale, offset): boxm2_batch.init_process("vilScaleAndOffsetValuesProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_float(1, scale) boxm2_batch.set_input_float(2, offset) boxm2_batch.run_process() return
def debayer(img): boxm2_batch.init_process("vilDebayerBGGRToRGBProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) outimg = dbvalue(id, type) return outimg
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 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 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 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 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 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 histogram_equalize(img): boxm2_batch.init_process("vilHistogramEqualizeProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_equalized = dbvalue(id, type) return img_equalized
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 fill_holes(img): boxm2_batch.init_process("vilFillHolesInRegionsProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) outimg = dbvalue(id, type) return outimg
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 gen_error_point_cloud(scene,cache,filename,thresh = 0.3): boxm2_batch.init_process("boxm2ExportErrorPointCloudProcess"); boxm2_batch.set_input_from_db(0,scene); boxm2_batch.set_input_from_db(1,cache); boxm2_batch.set_input_string(2,filename); #ply filename boxm2_batch.set_input_float(3,thresh); #prob threshold boxm2_batch.run_process();
def BGR_to_RGB(inimg): boxm2_batch.init_process("vilBGRToRGBProcess") boxm2_batch.set_input_from_db(0, inimg) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out_img = dbvalue(id, type) return out_img
def median_filter_image(img, neighborhood_radius): boxm2_batch.init_process("vilMedianFilterProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_int(1, neighborhood_radius) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) filt_img = dbvalue(id, type) return filt_img
def add_responses_to_filter_bank(tclsf, img_name, img, filter_folder, filter_name): boxm2_batch.init_process("sdetAddResponsestoFilterBankProcess"); boxm2_batch.set_input_from_db(0,tclsf); # classifier instance boxm2_batch.set_input_string(1,img_name); boxm2_batch.set_input_from_db(2,img); 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.run_process();
def atmospheric_correct(image, sun_z): boxm2_batch.init_process('bbasAtmosphericCorrProcess') boxm2_batch.set_input_from_db(0,image) boxm2_batch.set_input_float(1,sun_z) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) image_corrected = dbvalue(id,type) return image_corrected
def query_cell_data(scene,cache,point): boxm2_batch.init_process("boxm2CppQueryCellDataProcess"); boxm2_batch.set_input_from_db(0, scene); boxm2_batch.set_input_from_db(1, cache); boxm2_batch.set_input_float(2, point[0]); boxm2_batch.set_input_float(3, point[1]); boxm2_batch.set_input_float(4, point[2]); boxm2_batch.run_process();
def prob_as_expected(image,atomicity): boxm2_batch.init_process("bslExpectedImageProcess") boxm2_batch.set_input_from_db(0,image) boxm2_batch.set_input_float(1,atomicity) boxm2_batch.run_process() (id,type) = boxm2_batch.commit_output(0) image_prob = dbvalue(id,type) return image_prob
def perspective_camera_distance(cam1, cam2): boxm2_batch.init_process('vpglPerspCamDistanceProcess') boxm2_batch.set_input_from_db(0,cam1) boxm2_batch.set_input_from_db(1,cam2) boxm2_batch.run_process() (dist_id,type) = boxm2_batch.commit_output(0) dist = boxm2_batch.get_output_float(dist_id); return dist
def sun_dir_bin(meta,illum_bin_filename): boxm2_batch.init_process("bradSunDirBinProcess"); boxm2_batch.set_input_from_db(0,meta); boxm2_batch.set_input_string(1,illum_bin_filename); boxm2_batch.run_process(); (id,type)=boxm2_batch.commit_output(0); bin = boxm2_batch.get_output_int(id); return bin;
def get_number_of_planes(img): boxm2_batch.init_process("vilGetNumberOfPlanesProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) n_planes = boxm2_batch.get_output_unsigned(id) boxm2_batch.remove_data(id) return n_planes
def query_cell_brdf(scene, cache, point, model_type): boxm2_batch.init_process("boxm2CppQueryCellBrdfProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_float(2, point[0]) boxm2_batch.set_input_float(3, point[1]) boxm2_batch.set_input_float(4, point[2]) boxm2_batch.set_input_string(5, model_type) boxm2_batch.run_process()
def arf_next_frame(rawStream): boxm2_batch.init_process("bilArfReadFrameProcess") boxm2_batch.set_input_from_db(0, rawStream) 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 update_with_quality(scene, cache, cam, img, q_img, identifier=""): boxm2_batch.init_process("boxm2CppUpdateUsingQualityProcess") 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, q_img) boxm2_batch.set_input_string(5, identifier) boxm2_batch.run_process()
def visualize_change(change_img, in_img, thresh=.5): boxm2_batch.init_process("boxm2OclVisualizeChangeProcess") boxm2_batch.set_input_from_db(0, change_img) boxm2_batch.set_input_from_db(1, in_img) boxm2_batch.set_input_float(2, thresh) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) vis_img = dbvalue(id, type) return vis_img
def fuse_beliefs(image1, image2, atomicity): boxm2_batch.init_process("bslFusionProcess") boxm2_batch.set_input_from_db(0, image1) boxm2_batch.set_input_from_db(1, image2) boxm2_batch.set_input_float(2, atomicity) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) fused_image = dbvalue(id, type) return fused_image
def correct_rational_camera(cam_in, offset_x, offset_y): boxm2_batch.init_process('vpglCorrectRationalCameraProcess') boxm2_batch.set_input_from_db(0, cam_in) boxm2_batch.set_input_double(1, offset_x) boxm2_batch.set_input_double(2, offset_y) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) corrected_cam = dbvalue(id, type) return corrected_cam
def rotate_perspective_camera(cam_in, theta, phi): boxm2_batch.init_process('vpglRotatePerspCamProcess') boxm2_batch.set_input_from_db(0, cam_in) boxm2_batch.set_input_float(1, theta) boxm2_batch.set_input_float(2, phi) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) rot_cam = dbvalue(id, type) return rot_cam
def load_geotiff_from_header(filename, lvcs=0): boxm2_batch.init_process("vpglLoadGeotiffCamFromHeaderProcess") boxm2_batch.set_input_string(0, filename) if lvcs != 0: boxm2_batch.set_input_from_db(1, lvcs) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def translate_geo_camera(geocam, x, y): boxm2_batch.init_process("vpglTranslateGeoCameraProcess") boxm2_batch.set_input_from_db(0, geocam) boxm2_batch.set_input_double(1, x) boxm2_batch.set_input_double(2, y) boxm2_batch.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam
def pixel(img, point): boxm2_batch.init_process("vilPixelValueProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_int(1, int(point[0])) boxm2_batch.set_input_int(2, int(point[1])) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) val = boxm2_batch.get_output_float(id) return val
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 gen_error_point_cloud(scene, cache, filename, thresh=0.3): boxm2_batch.init_process("boxm2ExportErrorPointCloudProcess") boxm2_batch.set_input_from_db(0, scene) boxm2_batch.set_input_from_db(1, cache) boxm2_batch.set_input_string(2, filename) #ply filename boxm2_batch.set_input_float(3, thresh) #prob threshold boxm2_batch.run_process()
def sun_dir_bin(meta, illum_bin_filename): boxm2_batch.init_process("bradSunDirBinProcess") boxm2_batch.set_input_from_db(0, meta) boxm2_batch.set_input_string(1, illum_bin_filename) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) bin = boxm2_batch.get_output_int(id) boxm2_batch.remove_data(id) return bin
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) (id, type) = boxm2_batch.commit_output(1) nj = boxm2_batch.get_output_unsigned(id) return ni, nj
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) (id, type) = boxm2_batch.commit_output(1) maxVal = boxm2_batch.get_output_float(id) return minVal, maxVal
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 gradient_angle(Ix, Iy): boxm2_batch.init_process('vilGradientAngleProcess') boxm2_batch.set_input_from_db(0, Ix) boxm2_batch.set_input_from_db(1, Iy) boxm2_batch.run_process() #x image (id, type) = boxm2_batch.commit_output(0) angleImg = dbvalue(id, type) return angleImg
def undistort_image(img, param_file, iters): boxm2_batch.init_process("vilUndistortImageProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_string(1, param_file) boxm2_batch.set_input_int(2, iters) boxm2_batch.run_process() (o_id, o_type) = boxm2_batch.commit_output(0) out_img = dbvalue(o_id, o_type) return out_img
def binary_img_op(img1, img2, operation="sum"): boxm2_batch.init_process("vilBinaryImageOpProcess") boxm2_batch.set_input_from_db(0, img1) boxm2_batch.set_input_from_db(1, img2) boxm2_batch.set_input_string(2, operation) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) out = dbvalue(id, type) return out
def persp2gen(pcam, ni, nj, level=0): boxm2_batch.init_process("vpglConvertToGenericCameraProcess") boxm2_batch.set_input_from_db(0, pcam) boxm2_batch.set_input_unsigned(1, ni) boxm2_batch.set_input_unsigned(2, nj) boxm2_batch.set_input_unsigned(3, level) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) gcam = dbvalue(id, type) return gcam
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 binary_edge_detection(img, max_size, min_size, threshold_id=255): boxm2_batch.init_process("vilBinaryEdgeDetectionProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_unsigned(1, max_size) boxm2_batch.set_input_unsigned(2, min_size) boxm2_batch.set_input_unsigned(3, threshold_id) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) edge_img = dbvalue(id, type) return edge_img
def stretch_image(img, min_value, max_value, output_type_str='float'): boxm2_batch.init_process("vilStretchImageProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_float(1, min_value) boxm2_batch.set_input_float(2, max_value) boxm2_batch.set_input_string(3, output_type_str) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img_out = dbvalue(id, type) return img_out
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_atmospheric_parameters(image, metadata, mean_reflectance=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) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) atm_params = dbvalue(id, type) return atm_params
def radiometrically_calibrate(cropped_image, meta): boxm2_batch.init_process("bradNITFAbsRadiometricCalibrationProcess") boxm2_batch.set_input_from_db(0, cropped_image) boxm2_batch.set_input_from_db(1, meta) status = boxm2_batch.run_process() cropped_img_cal = None if status: (id, type) = boxm2_batch.commit_output(0) cropped_img_cal = dbvalue(id, type) return cropped_img_cal
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 resize(img, ni, nj, pixel="float"): boxm2_batch.init_process("vilResampleProcess") boxm2_batch.set_input_from_db(0, img) boxm2_batch.set_input_int(1, ni) boxm2_batch.set_input_int(2, nj) boxm2_batch.set_input_string(3, pixel) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) img = dbvalue(id, type) return img
def convert_to_generic_camera(cam_in, ni, nj, level=0): boxm2_batch.init_process('vpglConvertToGenericCameraProcess') boxm2_batch.set_input_from_db(0, cam_in) boxm2_batch.set_input_unsigned(1, ni) boxm2_batch.set_input_unsigned(2, nj) boxm2_batch.set_input_unsigned(3, level) boxm2_batch.run_process() (id, type) = boxm2_batch.commit_output(0) generic_cam = dbvalue(id, type) return generic_cam
def create_perspective_camera2(pcam, cent_x, cent_y, cent_z): boxm2_batch.init_process("vpglCreatePerspectiveCameraProcess2") boxm2_batch.set_input_from_db(0, pcam) 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.run_process() (c_id, c_type) = boxm2_batch.commit_output(0) cam = dbvalue(c_id, c_type) return cam