Exemplo n.º 1
0
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();
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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;
Exemplo n.º 7
0
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();
Exemplo n.º 8
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();
Exemplo n.º 9
0
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();
Exemplo n.º 10
0
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()
Exemplo n.º 11
0
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();
Exemplo n.º 12
0
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
Exemplo n.º 13
0
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
Exemplo n.º 14
0
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;
Exemplo n.º 15
0
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
Exemplo n.º 16
0
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;
Exemplo n.º 17
0
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
Exemplo n.º 18
0
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;
Exemplo n.º 19
0
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;
Exemplo n.º 20
0
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
Exemplo n.º 21
0
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();
Exemplo n.º 22
0
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;
Exemplo n.º 23
0
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;
Exemplo n.º 24
0
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
Exemplo n.º 25
0
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;
Exemplo n.º 26
0
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;
Exemplo n.º 27
0
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
Exemplo n.º 28
0
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;
Exemplo n.º 29
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();
Exemplo n.º 30
0
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
Exemplo n.º 31
0
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()
Exemplo n.º 32
0
def vrml_write_line(vrml_filename, pt1_coords, pt2_coords, r, g, b):
    boxm2_batch.init_process("bvrmlWriteLineProcess")
    boxm2_batch.set_input_string(0, vrml_filename)
    boxm2_batch.set_input_float(1, pt1_coords[0])
    # x
    boxm2_batch.set_input_float(2, pt1_coords[1])
    # y
    boxm2_batch.set_input_float(3, pt1_coords[2])
    # z
    boxm2_batch.set_input_float(4, pt2_coords[0])
    # x
    boxm2_batch.set_input_float(5, pt2_coords[1])
    # y
    boxm2_batch.set_input_float(6, pt2_coords[2])
    # z
    boxm2_batch.set_input_float(7, r)
    # red
    boxm2_batch.set_input_float(8, g)
    # green
    boxm2_batch.set_input_float(9, b)
    # blue
    boxm2_batch.run_process()
Exemplo n.º 33
0
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)
    (id, type) = boxm2_batch.commit_output(1)
    y = boxm2_batch.get_output_float(id)
    (id, type) = boxm2_batch.commit_output(2)
    z = boxm2_batch.get_output_float(id)
    return x, y, z
Exemplo n.º 34
0
def add_aux_info_to_ply(scene, cache, file_in, file_out):
    if cache.type == "boxm2_cache_sptr":
        print("Adding aux info to ply points")
        boxm2_batch.init_process("boxm2_add_aux_info_to_ply_process")
        boxm2_batch.set_input_from_db(0, scene)
        boxm2_batch.set_input_from_db(1, cache)
        boxm2_batch.set_input_string(2, file_in)
        boxm2_batch.set_input_string(3, file_out)
        #output aux (prob, vis, normal magnitdue)
        return boxm2_batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Exemplo n.º 35
0
def update_auxQ(scene,device,opencl_cache,cam, img, ident="", view_ident=""):
  #print("Init Manager");
  boxm2_batch.init_process("boxm2OclUpdateAuxQPerViewProcess");
  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_from_db(3, cam);
  boxm2_batch.set_input_from_db(4, img);
  boxm2_batch.set_input_string(5, ident);
  boxm2_batch.set_input_string(6, view_ident);
  status = boxm2_batch.run_process();
  if(status != True):
	print "Error in Running Aux Q ";
Exemplo n.º 36
0
def convert_local_rational_to_generic(cam_in, ni, nj, min_z, max_z, level=0):
    boxm2_batch.init_process('vpglConvertLocalRationalToGenericProcess')
    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_float(3, min_z)
    boxm2_batch.set_input_float(4, max_z)
    boxm2_batch.set_input_unsigned(5, level)
    if not boxm2_batch.run_process():
        return None
    (id, type) = boxm2_batch.commit_output(0)
    generic_cam = dbvalue(id, type)
    return generic_cam
Exemplo n.º 37
0
def update_aux_per_view(scene,
                        cache,
                        img,
                        cam,
                        imgString,
                        device=None,
                        mask=None):
    if cache.type == "boxm2_cache_sptr":
        print "boxm2_batch CPU update aux per view not yet implemented"
    elif cache.type == "boxm2_opencl_cache_sptr" and device:
        boxm2_batch.init_process("boxm2OclUpdateAuxPerViewProcess")
        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, imgString)
        if mask:
            boxm2_batch.set_input_from_db(6, mask)
        boxm2_batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
Exemplo n.º 38
0
def gen_point_cloud(scene,
                    cache,
                    filename,
                    thresh=0.3,
                    vis_thresh=0.5,
                    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, vis_thresh)
    boxm2_batch.set_input_float(6, thresh)
    boxm2_batch.run_process()
Exemplo n.º 39
0
def interpolate_normals(scene, cache, device, filters):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Interpolating Normal")
        boxm2_batch.init_process(
            "boxm2_ocl_aggregate_normal_from_filter_vector_process")
        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, filters)
        return boxm2_batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Exemplo n.º 40
0
def filter_scene_data(scene, cache, device, filters, filter_idx):
    if cache.type == "boxm2_opencl_cache_sptr":
        print("Filtering Scene Data")
        boxm2_batch.init_process("boxm2_ocl_filter_scene_data_process")
        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, filters)
        boxm2_batch.set_input_int(4, filter_idx)
        return boxm2_batch.run_process()
    else:
        print "ERROR: Cache type not recognized: ", cache.type
        return False
Exemplo n.º 41
0
def render_height_map(scene, cache, device=None):
    if cache.type == "boxm2_cache_sptr":
        print "boxm2_adaptor, render height map cpp process not implemented"

    elif cache.type == "boxm2_opencl_cache_sptr" and device:
        boxm2_batch.init_process("boxm2OclRenderExpectedHeightMapProcess")
        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.run_process()

        #z_img
        (id, type) = boxm2_batch.commit_output(0)
        z_image = dbvalue(id, type)

        #var image
        (id, type) = boxm2_batch.commit_output(1)
        var_image = dbvalue(id, type)

        #x_img
        (id, type) = boxm2_batch.commit_output(2)
        x_image = dbvalue(id, type)

        #y_img
        (id, type) = boxm2_batch.commit_output(3)
        y_image = dbvalue(id, type)

        #prob_img
        (id, type) = boxm2_batch.commit_output(4)
        prob_image = dbvalue(id, type)

        #appearance_img
        (id, type) = boxm2_batch.commit_output(5)
        app_image = dbvalue(id, type)

        return z_image, var_image, x_image, y_image, prob_image, app_image
    else:
        print "ERROR: Cache type not recognized: ", cache.type
Exemplo n.º 42
0
def pixel_wise_roc(cd_img, gt_img, mask_img=None):
    boxm2_batch.init_process("vilPixelwiseRocProcess")
    boxm2_batch.set_input_from_db(0, cd_img)
    boxm2_batch.set_input_from_db(1, gt_img)
    if mask_img:
        boxm2_batch.set_input_from_db(2, mask_img)
    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(6)
    outimg = dbvalue(id, type)
    # return tuple of true positives, true negatives, false positives, etc..
    return (tp, tn, fp, fn, outimg)
Exemplo n.º 43
0
def find_sun_dir_bin(metadata, output_file):
    boxm2_batch.init_process("bradSunDirBinProcess")
    boxm2_batch.set_input_from_db(0, metadata)
    boxm2_batch.set_input_string(1, output_file)
    status = boxm2_batch.run_process()
    bin, angle = None, None
    if status:
        (bin_id, bin_type) = boxm2_batch.commit_output(0)
        bin = boxm2_batch.get_output_int(bin_id)
        boxm2_batch.remove_data(bin_id)
        (angle_id, angle_type) = boxm2_batch.commit_output(1)
        angle = boxm2_batch.get_output_float(angle_id)
        boxm2_batch.remove_data(angle_id)
    return bin, angle
Exemplo n.º 44
0
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
Exemplo n.º 45
0
def create_scene_and_blocks(scene_dir,
                            app_model,
                            obs_model,
                            lon1,
                            lat1,
                            elev1,
                            lon2,
                            lat2,
                            elev2,
                            vox_size,
                            block_len_xy,
                            block_len_z,
                            num_bins=0,
                            xml_name="scene"):
    boxm2_batch.init_process("boxm2CreateSceneAndBlocksProcess")
    boxm2_batch.set_input_string(0, scene_dir)
    boxm2_batch.set_input_string(1, app_model)
    boxm2_batch.set_input_string(2, obs_model)
    boxm2_batch.set_input_float(3, lon1)
    boxm2_batch.set_input_float(4, lat1)
    boxm2_batch.set_input_float(5, elev1)
    boxm2_batch.set_input_float(6, lon2)
    boxm2_batch.set_input_float(7, lat2)
    boxm2_batch.set_input_float(8, elev2)
    boxm2_batch.set_input_float(9, vox_size)
    boxm2_batch.set_input_float(10, block_len_xy)
    boxm2_batch.set_input_float(11, block_len_z)
    boxm2_batch.set_input_int(12, num_bins)
    boxm2_batch.run_process()
    (scene_id, scene_type) = boxm2_batch.commit_output(0)
    scene = dbvalue(scene_id, scene_type)

    print("Write Scene")
    boxm2_batch.init_process("boxm2WriteSceneXMLProcess")
    boxm2_batch.set_input_from_db(0, scene)
    boxm2_batch.set_input_string(1, xml_name)
    boxm2_batch.run_process()
Exemplo n.º 46
0
def load_image(file_path):
    boxm2_batch.init_process("vilLoadImageViewProcess")
    boxm2_batch.set_input_string(0, file_path)
    status = boxm2_batch.run_process()
    img = ni = nj = None
    if status:
        (id, type) = boxm2_batch.commit_output(0)
        (ni_id, ni_type) = boxm2_batch.commit_output(1)
        (nj_id, nj_type) = boxm2_batch.commit_output(2)
        ni = boxm2_batch.get_output_unsigned(ni_id)
        nj = boxm2_batch.get_output_unsigned(nj_id)
        img = dbvalue(id, type)
        boxm2_batch.remove_data(ni_id)
        boxm2_batch.remove_data(nj_id)
    return img, ni, nj
Exemplo n.º 47
0
def query_cell(scene, cache, point, model_name, model_type):
    #Point should be 3 len, for a x, y, z coordinate OR
    #4 in lenght, blk_i, blk_j, blk_k, index

    if len(point) == 3:
        (blk, index) = get_index_from_3d_point(scene, cache, point)
        point = blk + (index, )

    boxm2_batch.init_process("boxm2CppQueryCellProcess")
    boxm2_batch.set_input_from_db(0, scene)
    boxm2_batch.set_input_from_db(1, cache)
    boxm2_batch.set_input_int(2, point[0])
    boxm2_batch.set_input_int(3, point[1])
    boxm2_batch.set_input_int(4, point[2])
    boxm2_batch.set_input_int(5, point[3])
    boxm2_batch.set_input_string(6, model_name)
    boxm2_batch.set_input_string(7, model_type)
    boxm2_batch.run_process()

    (id, type) = boxm2_batch.commit_output(0)
    data = boxm2_batch.get_bbas_1d_array_float(id)
    boxm2_batch.remove_data(id)

    return data
Exemplo n.º 48
0
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)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(1)
    alpha_array_1d = boxm2_batch.get_bbas_1d_array_float(id)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(2)
    vis_array_1d = boxm2_batch.get_bbas_1d_array_float(id)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(3)
    tabs_array_1d = boxm2_batch.get_bbas_1d_array_float(id)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(4)
    res_array_1d = boxm2_batch.get_bbas_1d_array_float(id)
    boxm2_batch.remove_data(id)
    if (prefix != ""):
        (id, type) = boxm2_batch.commit_output(5)
        data_array_1d = boxm2_batch.get_bbas_1d_array_float(id)
        boxm2_batch.remove_data(id)
        (id, type) = boxm2_batch.commit_output(6)
        nelems = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(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
Exemplo n.º 49
0
def solve_apply_gain_offset_constraints(mimg,
                                        timg,
                                        weight=1.0,
                                        mimg_mask=None):
    boxm2_batch.init_process("bripSolveGainOffsetConstraintsProcess")
    boxm2_batch.set_input_from_db(0, mimg)
    boxm2_batch.set_input_from_db(1, timg)
    boxm2_batch.set_input_from_db(2, weight)
    if mimg_mask is not None:
        boxm2_batch.set_input_from_db(3, 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
Exemplo n.º 50
0
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()
Exemplo n.º 51
0
def get_index_from_3d_point(scene, cache, point):
    boxm2_batch.init_process("boxm2CppGetIndexFrom3dPointProcess")
    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()

    (id, type) = boxm2_batch.commit_output(0)
    blk_i = boxm2_batch.get_output_int(id)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(1)
    blk_j = boxm2_batch.get_output_int(id)
    boxm2_batch.remove_data(id)
    (id, type) = boxm2_batch.commit_output(2)
    blk_k = boxm2_batch.get_output_int(id)
    boxm2_batch.remove_data(id)

    (id, type) = boxm2_batch.commit_output(3)
    index = boxm2_batch.get_output_int(id)
    boxm2_batch.remove_data(id)

    return ((blk_i, blk_j, blk_k), index)
Exemplo n.º 52
0
def refine(scene, cache, thresh=0.3, device=None):
    if cache.type == "boxm2_cache_sptr":
        print "boxm2_batch CPU refine"
        boxm2_batch.init_process("boxm2CppRefineProcess")
        boxm2_batch.set_input_from_db(0, scene)
        boxm2_batch.set_input_from_db(1, cache)
        boxm2_batch.set_input_float(2, thresh)
        boxm2_batch.run_process()
        return 0
    elif cache.type == "boxm2_opencl_cache_sptr" and device:
        print "boxm2_batch GPU refine"
        boxm2_batch.init_process("boxm2OclRefineProcess")
        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_float(3, thresh)
        boxm2_batch.run_process()

        #get and report cells output
        (id, type) = boxm2_batch.commit_output(0)
        nCells = boxm2_batch.get_output_int(id)
        return nCells
    else:
        print "ERROR: Cache type unrecognized: ", cache.type
Exemplo n.º 53
0
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
Exemplo n.º 54
0
def roi_init_geotiff(scene, geocam, geotiff_img_name, level=0):
    boxm2_batch.init_process("boxm2RoiInitGeotiffProcess")
    boxm2_batch.set_input_from_db(0, scene)
    boxm2_batch.set_input_from_db(1, geocam)
    boxm2_batch.set_input_string(2, geotiff_img_name)
    boxm2_batch.set_input_unsigned(3, level)
    result = boxm2_batch.run_process()
    if result:
        (id, type) = boxm2_batch.commit_output(0)
        gcam = dbvalue(id, type)
        (id, type) = boxm2_batch.commit_output(1)
        cropped_image = dbvalue(id, type)
    else:
        gcam = 0
        cropped_image = 0
    return result, gcam, cropped_image
Exemplo n.º 55
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, 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_string(7, bbox_file); #bb filename
    return boxm2_batch.run_process();
  else : 
    print "ERROR: Cache type not recognized: ", cache.type; 
    return False;
Exemplo n.º 56
0
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)
    status = boxm2_batch.run_process()
    atm_params = None
    if status:
        (id, type) = boxm2_batch.commit_output(0)
        atm_params = dbvalue(id, type)
    return atm_params
Exemplo n.º 57
0
def box_2d_intersection(in_kml, out_kml=""):
    boxm2_batch.init_process("bvgl2DBoxIntersectionProcess")
    boxm2_batch.set_input_string(0,  in_kml)
    boxm2_batch.set_input_string(1, out_kml)
    status = boxm2_batch.run_process()
    if status:
        (id, type) = boxm2_batch.commit_output(0)
        ll_lon = boxm2_batch.get_output_double(id)
        (id, type) = boxm2_batch.commit_output(1)
        ll_lat = boxm2_batch.get_output_double(id)
        (id, type) = boxm2_batch.commit_output(2)
        ur_lon = boxm2_batch.get_output_double(id)
        (id, type) = boxm2_batch.commit_output(3)
        ur_lat = boxm2_batch.get_output_double(id)
        return True, ll_lon, ll_lat, ur_lon, ur_lat
    else:
        return False, 0.0, 0.0, 0.0, 0.0
Exemplo n.º 58
0
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
Exemplo n.º 59
0
def load_opencl(scene_str, device_string="gpu"):
    scene = load_scene(scene_str)

    ###############################################################
    # Create cache, opencl manager, device, and gpu cache
    ###############################################################
    print("Create Main Cache")
    boxm2_batch.init_process("boxm2CreateCacheProcess")
    boxm2_batch.set_input_from_db(0, scene)
    boxm2_batch.set_input_string(1, "lru")
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    cache = dbvalue(id, type)

    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 Gpu Device")
    boxm2_batch.init_process("boclGetDeviceProcess")
    boxm2_batch.set_input_string(0, device_string)
    boxm2_batch.set_input_from_db(1, mgr)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    device = dbvalue(id, type)

    print("Create Gpu Cache")
    boxm2_batch.init_process("boxm2CreateOpenclCacheProcess")
    boxm2_batch.set_input_from_db(0, device)
    boxm2_batch.set_input_from_db(1, scene)
    boxm2_batch.run_process()
    (id, type) = boxm2_batch.commit_output(0)
    openclcache = dbvalue(id, type)

    return scene, cache, mgr, device, openclcache
Exemplo n.º 60
0
def nitf_date_time(image_filename):
    boxm2_batch.init_process("vilNITFDateTimeProcess")
    boxm2_batch.set_input_string(0, image_filename)
    status = boxm2_batch.run_process()
    year = month = day = hour = minute = None
    if status:
        (id, type) = boxm2_batch.commit_output(0)
        year = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(id)
        (id, type) = boxm2_batch.commit_output(1)
        month = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(id)
        (id, type) = boxm2_batch.commit_output(2)
        day = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(id)
        (id, type) = boxm2_batch.commit_output(3)
        hour = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(id)
        (id, type) = boxm2_batch.commit_output(4)
        minute = boxm2_batch.get_output_int(id)
        boxm2_batch.remove_data(id)
    return year, month, day, hour, minute