예제 #1
0
def test_classifier_clouds2(tclsf, dictionary_name, image_resource, i, j, width, height, block_size, percent_cat_name, category_id_file=""):
    bvxm_batch.init_process("sdetTextureClassifySatelliteCloudsProcess2")
    bvxm_batch.set_input_from_db(0, tclsf)
    bvxm_batch.set_input_string(1, dictionary_name)
    bvxm_batch.set_input_from_db(2, image_resource)
    bvxm_batch.set_input_unsigned(3, i)
    bvxm_batch.set_input_unsigned(4, j)
    bvxm_batch.set_input_unsigned(5, width)
    bvxm_batch.set_input_unsigned(6, height)
    bvxm_batch.set_input_unsigned(7, block_size)
    bvxm_batch.set_input_string(8, category_id_file)
    bvxm_batch.set_input_string(9, percent_cat_name)
    status = bvxm_batch.run_process()
    if status:
        (out_id, out_type) = bvxm_batch.commit_output(0)
        out_crop = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(1)
        out_id_map = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(2)
        out_rgb_map = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(3)
        percent = bvxm_batch.get_output_float(out_id)
        bvxm_batch.remove_data(out_id)
        return out_crop, out_id_map, out_rgb_map, percent
    else:
        return 0, 0, 0, 100
예제 #2
0
def test_classifier_clouds2(tclsf,
                            dictionary_name,
                            image_resource,
                            i,
                            j,
                            width,
                            height,
                            block_size,
                            percent_cat_name,
                            category_id_file=""):
    bvxm_batch.init_process("sdetTextureClassifySatelliteCloudsProcess2")
    bvxm_batch.set_input_from_db(0, tclsf)
    bvxm_batch.set_input_string(1, dictionary_name)
    bvxm_batch.set_input_from_db(2, image_resource)
    bvxm_batch.set_input_unsigned(3, i)
    bvxm_batch.set_input_unsigned(4, j)
    bvxm_batch.set_input_unsigned(5, width)
    bvxm_batch.set_input_unsigned(6, height)
    bvxm_batch.set_input_unsigned(7, block_size)
    bvxm_batch.set_input_string(8, category_id_file)
    bvxm_batch.set_input_string(9, percent_cat_name)
    status = bvxm_batch.run_process()
    if status:
        (out_id, out_type) = bvxm_batch.commit_output(0)
        out_crop = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(1)
        out_id_map = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(2)
        out_rgb_map = dbvalue(out_id, out_type)
        (out_id, out_type) = bvxm_batch.commit_output(3)
        percent = bvxm_batch.get_output_float(out_id)
        bvxm_batch.remove_data(out_id)
        return out_crop, out_id_map, out_rgb_map, percent
    else:
        return 0, 0, 0, 100
예제 #3
0
def pick_nadir_resource_pair(res,
                             lower_left_lon,
                             lower_left_lat,
                             upper_right_lon,
                             upper_right_lat,
                             satellite_name,
                             out_folder,
                             band_name="PAN",
                             non_cloud_folder=""):
    bvxm_batch.init_process("volmPickNadirResPairProcess")
    bvxm_batch.set_input_from_db(0, res)
    bvxm_batch.set_input_double(1, lower_left_lon)
    bvxm_batch.set_input_double(2, lower_left_lat)
    bvxm_batch.set_input_double(3, upper_right_lon)
    bvxm_batch.set_input_double(4, upper_right_lat)
    bvxm_batch.set_input_string(5, band_name)
    bvxm_batch.set_input_string(6, satellite_name)
    bvxm_batch.set_input_string(7, non_cloud_folder)
    bvxm_batch.set_input_string(8, out_folder)
    statuscode = bvxm_batch.run_process()
    if statuscode:
        (p_id, p_type) = bvxm_batch.commit_output(0)
        pan_path = bvxm_batch.get_output_string(p_id)
        bvxm_batch.remove_data(p_id)
        (m_id, m_type) = bvxm_batch.commit_output(1)
        multi_path = bvxm_batch.get_output_string(m_id)
        bvxm_batch.remove_data(m_id)
    else:
        pan_path = ""
        multi_path = ""
    return statuscode, pan_path, multi_path
예제 #4
0
def get_cloud_coverage(mdata):
    bvxm_batch.init_process("bradGetCloudCoverageProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    cloud_coverage = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return cloud_coverage
예제 #5
0
def get_cloud_coverage(mdata):
    bvxm_batch.init_process("bradGetCloudCoverageProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    cloud_coverage = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return cloud_coverage
예제 #6
0
def get_full_path(res, name):
  bvxm_batch.init_process("volmGetFullPathProcess");
  bvxm_batch.set_input_from_db(0,res);
  bvxm_batch.set_input_string(1,name);
  statuscode=bvxm_batch.run_process();
  (f_id, f_type) = bvxm_batch.commit_output(0);
  full_path = bvxm_batch.get_output_string(f_id);
  bvxm_batch.remove_data(f_id);
  return full_path
예제 #7
0
def get_full_path(res, name):
    bvxm_batch.init_process("volmGetFullPathProcess")
    bvxm_batch.set_input_from_db(0, res)
    bvxm_batch.set_input_string(1, name)
    statuscode = bvxm_batch.run_process()
    (f_id, f_type) = bvxm_batch.commit_output(0)
    full_path = bvxm_batch.get_output_string(f_id)
    bvxm_batch.remove_data(f_id)
    return full_path
예제 #8
0
def get_rational_camera_offsets(cam_in):
    bvxm_batch.init_process('vpglGetRationalCameraOffsetsProcess');
    bvxm_batch.set_input_from_db(0,cam_in);
    bvxm_batch.run_process();
    (id,type) = bvxm_batch.commit_output(0);
    offset_u = bvxm_batch.get_output_double(id);
    bvxm_batch.remove_data(id);
    (id,type) = bvxm_batch.commit_output(1);
    offset_v = bvxm_batch.get_output_double(id);
    bvxm_batch.remove_data(id);
    return (offset_u,offset_v);
예제 #9
0
def get_sun_angles(mdata):
  bvxm_batch.init_process("bradGetSunAnglesProcess")
  bvxm_batch.set_input_from_db(0,mdata)
  bvxm_batch.run_process()
  (id,type) = bvxm_batch.commit_output(0)
  sun_az = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id,type) = bvxm_batch.commit_output(1)
  sun_el = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  return sun_az, sun_el
예제 #10
0
def get_rational_camera_offsets(cam_in):
    bvxm_batch.init_process('vpglGetRationalCameraOffsetsProcess')
    bvxm_batch.set_input_from_db(0, cam_in)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    offset_u = bvxm_batch.get_output_double(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    offset_v = bvxm_batch.get_output_double(id)
    bvxm_batch.remove_data(id)
    return (offset_u, offset_v)
예제 #11
0
def get_sun_angles(mdata):
    bvxm_batch.init_process("bradGetSunAnglesProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    sun_az = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    sun_el = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return sun_az, sun_el
예제 #12
0
def calculate_nitf_gsd(rational_cam, lon1, lat1, elev1, distance = 1000):
  # create a lvcs
  lvcs = create_lvcs(lat1, lon1, elev1, "wgs84")
  lat2, lon2, elev2 = convert_local_to_global_coordinates(lvcs, distance, distance, 0.0)
  # calculate image pixel
  i1, j1 = project_point(rational_cam, lon1, lat1, elev1)
  i2, j2 = project_point(rational_cam, lon2, lat2, elev2)
  gsd_i = distance / (i2-i1)
  gsd_j = distance / (j2-j1)
  if (gsd_i < 0.0): gsd_i = -1*gsd_i
  if (gsd_j < 0.0): gsd_j = -1*gsd_j
  bvxm_batch.remove_data(lvcs.id)
  return gsd_i, gsd_j
예제 #13
0
def calculate_nitf_gsd(rational_cam, lon1, lat1, elev1, distance=1000):
    # create a lvcs
    lvcs = create_lvcs(lat1, lon1, elev1, "wgs84")
    lat2, lon2, elev2 = convert_local_to_global_coordinates(
        lvcs, distance, distance, 0.0)
    # calculate image pixel
    i1, j1 = project_point(rational_cam, lon1, lat1, elev1)
    i2, j2 = project_point(rational_cam, lon2, lat2, elev2)
    gsd_i = distance / (i2 - i1)
    gsd_j = distance / (j2 - j1)
    if (gsd_i < 0.0): gsd_i = -1 * gsd_i
    if (gsd_j < 0.0): gsd_j = -1 * gsd_j
    bvxm_batch.remove_data(lvcs.id)
    return gsd_i, gsd_j
예제 #14
0
def get_sun_angles_date_time(lat, lon, year, month, day, hour, minute):
  bvxm_batch.init_process("bradGetSunAnglesDateTimeProcess")
  bvxm_batch.set_input_float(0,lat)
  bvxm_batch.set_input_float(1,lon)
  bvxm_batch.set_input_int(2,year)
  bvxm_batch.set_input_int(3,month)
  bvxm_batch.set_input_int(4,day)
  bvxm_batch.set_input_int(5,hour)
  bvxm_batch.set_input_int(6,minute)
  bvxm_batch.run_process()
  (id,type) = bvxm_batch.commit_output(0)
  sun_az = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id,type) = bvxm_batch.commit_output(1)
  sun_el = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  return sun_az, sun_el
예제 #15
0
def get_sun_angles_date_time(lat, lon, year, month, day, hour, minute):
    bvxm_batch.init_process("bradGetSunAnglesDateTimeProcess")
    bvxm_batch.set_input_float(0, lat)
    bvxm_batch.set_input_float(1, lon)
    bvxm_batch.set_input_int(2, year)
    bvxm_batch.set_input_int(3, month)
    bvxm_batch.set_input_int(4, day)
    bvxm_batch.set_input_int(5, hour)
    bvxm_batch.set_input_int(6, minute)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    sun_az = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    sun_el = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return sun_az, sun_el
예제 #16
0
def pick_nadir_resource_pair(res, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, satellite_name, out_folder, band_name="PAN", non_cloud_folder=""):
  bvxm_batch.init_process("volmPickNadirResPairProcess");
  bvxm_batch.set_input_from_db(0,res);
  bvxm_batch.set_input_double(1, lower_left_lon);
  bvxm_batch.set_input_double(2, lower_left_lat);
  bvxm_batch.set_input_double(3, upper_right_lon);
  bvxm_batch.set_input_double(4, upper_right_lat);
  bvxm_batch.set_input_string(5, band_name);
  bvxm_batch.set_input_string(6, satellite_name);
  bvxm_batch.set_input_string(7, non_cloud_folder);
  bvxm_batch.set_input_string(8, out_folder)
  statuscode = bvxm_batch.run_process();
  if statuscode:
    (p_id, p_type) = bvxm_batch.commit_output(0);
    pan_path = bvxm_batch.get_output_string(p_id);
    bvxm_batch.remove_data(p_id);
    (m_id, m_type) = bvxm_batch.commit_output(1);
    multi_path = bvxm_batch.get_output_string(m_id);
    bvxm_batch.remove_data(m_id);
  else:
    pan_path = "";
    multi_path = "";
  return statuscode, pan_path, multi_path
예제 #17
0
def find_resource_pair(res, name):
    bvxm_batch.init_process("volmFindResourcePairProcess")
    bvxm_batch.set_input_from_db(0, res)
    bvxm_batch.set_input_string(1, name)
    statuscode = bvxm_batch.run_process()
    (f_id, f_type) = bvxm_batch.commit_output(0)
    full_path = bvxm_batch.get_output_string(f_id)
    bvxm_batch.remove_data(f_id)
    (n_id, n_type) = bvxm_batch.commit_output(1)
    pair_name = bvxm_batch.get_output_string(n_id)
    bvxm_batch.remove_data(n_id)
    (p_id, p_type) = bvxm_batch.commit_output(2)
    full_path_pair_name = bvxm_batch.get_output_string(p_id)
    bvxm_batch.remove_data(p_id)
    return statuscode, full_path, pair_name, full_path_pair_name
예제 #18
0
def find_resource_pair(res, name):
  bvxm_batch.init_process("volmFindResourcePairProcess");
  bvxm_batch.set_input_from_db(0,res);
  bvxm_batch.set_input_string(1,name);
  statuscode=bvxm_batch.run_process();
  (f_id, f_type) = bvxm_batch.commit_output(0);
  full_path = bvxm_batch.get_output_string(f_id);
  bvxm_batch.remove_data(f_id);
  (n_id, n_type) = bvxm_batch.commit_output(1);
  pair_name = bvxm_batch.get_output_string(n_id);
  bvxm_batch.remove_data(n_id);
  (p_id, p_type) = bvxm_batch.commit_output(2);
  full_path_pair_name = bvxm_batch.get_output_string(p_id);
  bvxm_batch.remove_data(p_id);
  return statuscode, full_path, pair_name, full_path_pair_name
예제 #19
0
def find_resource_pair(res, name, tol=10.0):
    bvxm_batch.init_process("volmFindResourcePairProcess")
    bvxm_batch.set_input_from_db(0, res)
    bvxm_batch.set_input_string(1, name)
    bvxm_batch.set_input_double(2, tol)
    statuscode = bvxm_batch.run_process()
    (f_id, f_type) = bvxm_batch.commit_output(0)
    full_path = bvxm_batch.get_output_string(f_id)
    bvxm_batch.remove_data(f_id)
    (n_id, n_type) = bvxm_batch.commit_output(1)
    pair_name = bvxm_batch.get_output_string(n_id)
    bvxm_batch.remove_data(n_id)
    (p_id, p_type) = bvxm_batch.commit_output(2)
    full_path_pair_name = bvxm_batch.get_output_string(p_id)
    bvxm_batch.remove_data(p_id)
    return statuscode, full_path, pair_name, full_path_pair_name
예제 #20
0
def convert_local_to_global_coordinates(lvcs,x,y,z):
    bvxm_batch.init_process('vpglConvertLocalToGlobalCoordinatesProcess');
    bvxm_batch.set_input_from_db(0,lvcs);
    bvxm_batch.set_input_float(1,x);
    bvxm_batch.set_input_float(2,y);
    bvxm_batch.set_input_float(3,z);
    bvxm_batch.run_process();
    (id,type) = bvxm_batch.commit_output(0);
    lat = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    (id,type) = bvxm_batch.commit_output(1);
    lon = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    (id,type) = bvxm_batch.commit_output(2);
    el = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    return (lat,lon,el);
예제 #21
0
def convert_to_local_coordinates(lvcs_filename, lat, lon, el):
    bvxm_batch.init_process('vpglConvertToLocalCoordinatesProcess')
    bvxm_batch.set_input_string(0, lvcs_filename)
    bvxm_batch.set_input_float(1, lat)
    bvxm_batch.set_input_float(2, lon)
    bvxm_batch.set_input_float(3, el)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    x = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    y = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(2)
    z = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return (x, y, z)
예제 #22
0
def convert_to_local_coordinates2(lvcs,lat,lon,el):
    bvxm_batch.init_process('vpglConvertToLocalCoordinatesProcess2');
    bvxm_batch.set_input_from_db(0,lvcs);
    bvxm_batch.set_input_float(1,lat);
    bvxm_batch.set_input_float(2,lon);
    bvxm_batch.set_input_float(3,el);
    bvxm_batch.run_process();
    (id,type) = bvxm_batch.commit_output(0);
    x = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    (id,type) = bvxm_batch.commit_output(1);
    y = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    (id,type) = bvxm_batch.commit_output(2);
    z = bvxm_batch.get_output_float(id);
    bvxm_batch.remove_data(id);
    return (x,y,z);
예제 #23
0
def convert_local_to_global_coordinates(lvcs, x, y, z):
    bvxm_batch.init_process('vpglConvertLocalToGlobalCoordinatesProcess')
    bvxm_batch.set_input_from_db(0, lvcs)
    bvxm_batch.set_input_float(1, x)
    bvxm_batch.set_input_float(2, y)
    bvxm_batch.set_input_float(3, z)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    lat = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    lon = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(2)
    el = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return (lat, lon, el)
예제 #24
0
def convert_to_local_coordinates2(lvcs, lat, lon, el):
    bvxm_batch.init_process('vpglConvertToLocalCoordinatesProcess2')
    bvxm_batch.set_input_from_db(0, lvcs)
    bvxm_batch.set_input_float(1, lat)
    bvxm_batch.set_input_float(2, lon)
    bvxm_batch.set_input_float(3, el)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    x = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    y = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(2)
    z = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    return (x, y, z)
예제 #25
0
def get_image_coverage(mdata):
    bvxm_batch.init_process("bradGetImageCoverageProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    status = bvxm_batch.run_process()
    if status:
        (id, type) = bvxm_batch.commit_output(0)
        ll_lon = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(1)
        ll_lat = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(2)
        ll_elev = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(3)
        ur_lon = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(4)
        ur_lat = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(5)
        ur_elev = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        return ll_lon, ll_lat, ll_elev, ur_lon, ur_lat, ur_elev
    else:
        return 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
예제 #26
0
def get_view_angles(mdata):
  bvxm_batch.init_process("bradGetMetaDataInfoProcess")
  bvxm_batch.set_input_from_db(0, mdata)
  bvxm_batch.run_process()
  (id,type) = bvxm_batch.commit_output(0)
  sun_az = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id,type) = bvxm_batch.commit_output(1)
  sun_el = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(2)
  year = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(3)
  month = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(4)
  day = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(5)
  hour = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(6)
  minutes = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(7)
  seconds = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(8)
  gsd = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(9)
  sat_name = bvxm_batch.get_output_string(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(10)
  view_az = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(11)
  view_el = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  return view_az, view_el
예제 #27
0
def build_edge_world(scene,
                     scene_id,
                     world_dir,
                     n_seed,
                     image_fnames,
                     cropped_imgs,
                     cropped_cams,
                     uncertainties,
                     param_file_dir,
                     corrected_global_cams,
                     out_dir,
                     n_seed_update=1,
                     save=0):

    ## remove the .vox files if any
    edge_files = glob.glob(world_dir + "/edges_*.vox")
    for edge_file_name in edge_files:
        print "removing " + edge_file_name + "..."
        sys.stdout.flush()
        os.remove(edge_file_name)

    t1 = time.time()
    #   out_imgs = out_dir + "img_%d_%s.tif";
    out_edge_imgs = out_dir + "img_%d.tif"
    out_exp_edge_imgs = out_dir + "exp_img_%d.tif"
    cnt_updates = 0

    # create cropped_edge_imgs from cropped_img
    cropped_edge_imgs = []
    for i in range(0, len(cropped_imgs), 1):
        cropped_edge_image = bvxm_detect_edges(
            cropped_imgs[i], param_file_dir + "bvxmDetectEdgesProcess.xml")
        if save:
            bvxm_save_image(cropped_edge_image, out_edge_imgs % i)
        cropped_edge_imgs.append(cropped_edge_image)

    # start update edge world for n_seed_update times to improve the edge world quality
    for n_cnt in range(0, n_seed_update, 1):
        print '-----------------------------'
        print "scene: %d, number of update = %d from total %d updates" % (
            scene_id, n_cnt, n_seed_update)
        print '-----------------------------'
        sys.stdout.flush()
        for i in range(0, len(cropped_edge_imgs), 1):
            cropped_cam = cropped_cams[i]
            cropped_edge_image = cropped_edge_imgs[i]
            uncertainty = uncertainties[i]
            image_name = image_fnames[i]
            if i >= n_seed:
                continue
            else:
                # update edge world using seed
                update_edges(scene, cropped_cam, cropped_edge_image)

    for i in range(0, len(cropped_edge_imgs), 1):
        cropped_cam = cropped_cams[i]
        cropped_edge_image = cropped_edge_imgs[i]
        uncertainty = uncertainties[i]
        image_name = image_fnames[i]
        print '-----------------------------'
        print "scene: %d, image: %d out of %d" % (scene_id, i,
                                                  len(image_fnames))
        print "n_seed = ", n_seed
        print "uncertainty = ", uncertainty
        print '-----------------------------'
        sys.stdout.flush()
        if i >= n_seed:
            cam_cor, expected_edge_image, offset_u, offset_v = rpc_registration(
                scene, cropped_cam, cropped_edge_image, uncertainty, 0, 0, 1)
            if save:
                bvxm_save_image(expected_edge_image,
                                out_exp_edge_imgs % cnt_updates)
            print "-------- will correct with offset_u: " + str(
                offset_u) + " offset_v: " + str(offset_v)
            #       cam_global_cor = correct_rational_camera(cropped_cam, offset_u, offset_v);
            save_rational_camera(cam_cor, corrected_global_cams % image_name)
            # update edge world using corrected camera
            update_edges(scene, cam_cor, cropped_edge_image)
            # clean data
            bvxm_batch.remove_data(expected_edge_image.id)
            #       bvxm_batch.remove_data(cam_global_cor.id);
            bvxm_batch.remove_data(cam_cor.id)
        else:
            continue
#       update_edges(scene, cropped_cam, cropped_edge_image, param_file_dir + "bvxmUpdateEdgesProcess.xml");

        cnt_updates = cnt_updates + 1
        if save:
            bvxm_save_image(cropped_edge_image, out_edge_imgs % cnt_updates)

    # update the seed camera
    print "update the seed images..."
    sys.stdout.flush()
    cnt_updates = 0
    for i in range(0, len(cropped_edge_imgs), 1):
        cropped_cam = cropped_cams[i]
        cropped_edge_image = cropped_edge_imgs[i]
        uncertainty = uncertainties[i]
        image_name = image_fnames[i]
        print '-----------------------------'
        print "scene: %d, image: %d out of %d" % (scene_id, i,
                                                  len(image_fnames))
        print "n_seed = ", n_seed
        print "uncertainty = ", uncertainty
        print '-----------------------------'
        if i >= n_seed:
            continue
        else:
            # update the seed cameras
            cam_cor, expected_edge_image, offset_u, offset_v = rpc_registration(
                scene, cropped_cam, cropped_edge_image, uncertainty, 0, 0, 1)
            if save:
                bvxm_save_image(expected_edge_image,
                                out_exp_edge_imgs % cnt_updates)
                cnt_updates = cnt_updates + 1
            print "-------- will correct the cropped camera with offset_u: " + str(
                offset_u) + " offset_v: " + str(offset_v)
            #       cam_global_cor = correct_rational_camera(cropped_cam, offset_u, offset_v);
            save_rational_camera(cam_cor, corrected_global_cams % image_name)
            # clean data
            bvxm_batch.remove_data(expected_edge_image.id)
            #       bvxm_batch.remove_data(cam_global_cor.id);
            bvxm_batch.remove_data(cam_cor.id)

    # render the ortho map
    out_e_img, out_e_img_byte, out_h_img, ortho_cam = render_ortho_edgemap(
        scene)
    bvxm_save_image(out_e_img,
                    out_dir + "scene_%d_ortho_edge_map.tif" % scene_id)
    bvxm_batch.remove_data(out_e_img.id)
    bvxm_batch.remove_data(out_e_img_byte.id)
    bvxm_batch.remove_data(out_h_img.id)
    bvxm_batch.remove_data(ortho_cam.id)

    t2 = time.time()
    secs = t2 - t1
    mins = secs / 60.0
    print "Scene: " + str(scene_id) + " execution time: " + str(
        secs) + " secs = " + str(mins) + " mins for " + str(
            cnt_updates) + " updates."
예제 #28
0
def build_edge_world(scene, scene_id, world_dir, n_seed, image_fnames, cropped_imgs, cropped_cams,
                     uncertainties, param_file_dir, corrected_global_cams, out_dir, n_seed_update = 1,
                     save=0):

  ## remove the .vox files if any
  edge_files = glob.glob(world_dir + "/edges_*.vox");
  for edge_file_name in edge_files:
    print "removing " + edge_file_name + "...";
    sys.stdout.flush()
    os.remove(edge_file_name);

  t1 = time.time();
#   out_imgs = out_dir + "img_%d_%s.tif";
  out_edge_imgs = out_dir + "img_%d.tif";
  out_exp_edge_imgs = out_dir + "exp_img_%d.tif"
  cnt_updates = 0;

  # create cropped_edge_imgs from cropped_img
  cropped_edge_imgs = []
  for i in range(0,len(cropped_imgs),1):
    cropped_edge_image = bvxm_detect_edges(cropped_imgs[i], param_file_dir + "bvxmDetectEdgesProcess.xml");
    if save:
      bvxm_save_image(cropped_edge_image, out_edge_imgs % i);
    cropped_edge_imgs.append(cropped_edge_image)

  # start update edge world for n_seed_update times to improve the edge world quality
  for n_cnt in range(0, n_seed_update, 1):
    print '-----------------------------';
    print "scene: %d, number of update = %d from total %d updates" % (scene_id, n_cnt, n_seed_update);
    print '-----------------------------';
    sys.stdout.flush()
    for i in range(0, len(cropped_edge_imgs), 1):
      cropped_cam = cropped_cams[i]
      cropped_edge_image = cropped_edge_imgs[i]
      uncertainty = uncertainties[i]
      image_name = image_fnames[i]
      if i >= n_seed:
        continue
      else:
        # update edge world using seed
        update_edges(scene, cropped_cam, cropped_edge_image);

  for i in range(0, len(cropped_edge_imgs), 1):
    cropped_cam = cropped_cams[i]
    cropped_edge_image = cropped_edge_imgs[i]
    uncertainty = uncertainties[i]
    image_name = image_fnames[i]
    print '-----------------------------';
    print "scene: %d, image: %d out of %d" % (scene_id, i, len(image_fnames));
    print "n_seed = ", n_seed
    print "uncertainty = ", uncertainty
    print '-----------------------------';
    sys.stdout.flush();
    if i >= n_seed:
      cam_cor, expected_edge_image, offset_u, offset_v = rpc_registration(scene, cropped_cam, cropped_edge_image, uncertainty, 0, 0, 1);
      if save:
        bvxm_save_image(expected_edge_image, out_exp_edge_imgs % cnt_updates);
      print "-------- will correct with offset_u: " + str(offset_u) + " offset_v: " + str(offset_v);
#       cam_global_cor = correct_rational_camera(cropped_cam, offset_u, offset_v);
      save_rational_camera(cam_cor,corrected_global_cams % image_name);
      # update edge world using corrected camera
      update_edges(scene, cam_cor, cropped_edge_image);
      # clean data
      bvxm_batch.remove_data(expected_edge_image.id)
#       bvxm_batch.remove_data(cam_global_cor.id);
      bvxm_batch.remove_data(cam_cor.id)
    else:
      continue;
#       update_edges(scene, cropped_cam, cropped_edge_image, param_file_dir + "bvxmUpdateEdgesProcess.xml");

    cnt_updates = cnt_updates+1;
    if save:
      bvxm_save_image(cropped_edge_image, out_edge_imgs % cnt_updates);

  # update the seed camera
  print "update the seed images..."
  sys.stdout.flush()
  cnt_updates = 0
  for i in range(0, len(cropped_edge_imgs), 1):
    cropped_cam = cropped_cams[i]
    cropped_edge_image = cropped_edge_imgs[i]
    uncertainty = uncertainties[i]
    image_name = image_fnames[i]
    print '-----------------------------';
    print "scene: %d, image: %d out of %d" % (scene_id, i, len(image_fnames));
    print "n_seed = ", n_seed
    print "uncertainty = ", uncertainty
    print '-----------------------------';
    if i >= n_seed:
      continue;
    else:
      # update the seed cameras
      cam_cor, expected_edge_image, offset_u, offset_v = rpc_registration(scene, cropped_cam, cropped_edge_image, uncertainty, 0, 0, 1);
      if save:
        bvxm_save_image(expected_edge_image, out_exp_edge_imgs % cnt_updates);
        cnt_updates = cnt_updates + 1
      print "-------- will correct the cropped camera with offset_u: " + str(offset_u) + " offset_v: " + str(offset_v);
#       cam_global_cor = correct_rational_camera(cropped_cam, offset_u, offset_v);
      save_rational_camera(cam_cor,corrected_global_cams % image_name);
      # clean data
      bvxm_batch.remove_data(expected_edge_image.id)
#       bvxm_batch.remove_data(cam_global_cor.id);
      bvxm_batch.remove_data(cam_cor.id)


  # render the ortho map
  out_e_img, out_e_img_byte, out_h_img, ortho_cam = render_ortho_edgemap(scene);
  bvxm_save_image(out_e_img, out_dir + "scene_%d_ortho_edge_map.tif" % scene_id);
  bvxm_batch.remove_data(out_e_img.id);
  bvxm_batch.remove_data(out_e_img_byte.id);
  bvxm_batch.remove_data(out_h_img.id);
  bvxm_batch.remove_data(ortho_cam.id);

  t2 = time.time();
  secs = t2-t1;
  mins = secs/60.0;
  print "Scene: " + str(scene_id) + " execution time: " +str(secs) + " secs = " + str(mins) + " mins for " + str(cnt_updates) + " updates.";
예제 #29
0
def get_metadata_info(mdata):
  bvxm_batch.init_process("bradGetMetaDataInfoProcess")
  bvxm_batch.set_input_from_db(0, mdata)
  bvxm_batch.run_process()
  (id,type) = bvxm_batch.commit_output(0)
  sun_az = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id,type) = bvxm_batch.commit_output(1)
  sun_el = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(2)
  year = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(3)
  month = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(4)
  day = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(5)
  hour = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(6)
  minutes = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(7)
  seconds = bvxm_batch.get_output_int(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(8)
  gsd = bvxm_batch.get_output_float(id)
  bvxm_batch.remove_data(id)
  (id, type) = bvxm_batch.commit_output(9)
  sat_name = bvxm_batch.get_output_string(id)
  bvxm_batch.remove_data(id)
  return sun_az, sun_el, year, month, day, hour, minutes, seconds, gsd, sat_name
예제 #30
0
def get_metadata_info2(mdata):
    bvxm_batch.init_process("bradGetMetaDataInfoProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    bvxm_batch.run_process()
    (id, type) = bvxm_batch.commit_output(0)
    sun_az = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(1)
    sun_el = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(2)
    year = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(3)
    month = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(4)
    day = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(5)
    hour = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(6)
    minutes = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(7)
    seconds = bvxm_batch.get_output_int(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(8)
    gsd = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(9)
    sat_name = bvxm_batch.get_output_string(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(10)
    view_az = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(11)
    view_el = bvxm_batch.get_output_float(id)
    bvxm_batch.remove_data(id)
    (id, type) = bvxm_batch.commit_output(12)
    band = bvxm_batch.get_output_string(id)
    return sun_az, sun_el, year, month, day, hour, minutes, seconds, gsd, sat_name, view_az, view_el, band
예제 #31
0
def get_image_coverage(mdata):
    bvxm_batch.init_process("bradGetImageCoverageProcess")
    bvxm_batch.set_input_from_db(0, mdata)
    status = bvxm_batch.run_process()
    if status:
        (id, type) = bvxm_batch.commit_output(0)
        ll_lon = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(1)
        ll_lat = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(2)
        ll_elev = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(3)
        ur_lon = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(4)
        ur_lat = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        (id, type) = bvxm_batch.commit_output(5)
        ur_elev = bvxm_batch.get_output_double(id)
        bvxm_batch.remove_data(id)
        return ll_lon, ll_lat, ll_elev, ur_lon, ur_lat, ur_elev
    else:
        return 0.0, 0.0, 0.0, 0.0, 0.0, 0.0