コード例 #1
0
grid[13].set_xlabel('feat = 5K')
grid[14].set_xlabel('feat = 10K')
grid[15].set_xlabel('feat = 20K')
plt.savefig('/Users/venabled/doc/journal1/img/neogeo_grid_out.png', dpi=600)

# Get a truth finder
f5 = tb.open_file('/Users/venabled/data/uvan/fc2_f5.hdf', 'r')
imgs = f5.root.camera.image_raw.compressed.images
img_times = imgs = f5.root.camera.image_raw.compressed.metadata.cols.t_valid
pva = f5.root.nov_span.pva

srtm_path = '/Users/venabled/data/srtm/SRTM1/Region_01'
geoid_file = '/Users/venabled/data/geoid/egm96_15.tiff'
frame_yaml = '/Users/venabled/pysrc/pnpnav/data/fc2_pod_frames.yaml'

finder = pnputils.DEMTileFinder(srtm_path, geoid_file)
finder.load_cam_and_vehicle_frames(frame_yaml)
finder.load_camera_cal('/Users/venabled/pysrc/pnpnav/data/fc2_cam_model.yaml')

corners = np.zeros((img_times.shape[0], 4, 3))
for img_num in np.arange(img_times.shape[0]):
    dt = pva.cols.t_valid - img_times[img_num]
    ii = np.abs(dt).argmin()
    lon_lat_h = np.array([pva[ii]['lon'], pva[ii]['lat'], pva[ii]['height']])
    att = pva[ii]['c_nav_veh'].reshape(3, 3)
    corners[img_num] = finder.get_corners(lon_lat_h, att)[1]
    print('image: %d / %d' % (img_num, img_times.shape[0]))

centers = np.array([corner[:, :2].mean(0) for corner in corners])
bbox = neoextent.bbox_from_extent(extent)
c_wgs = np.hstack((np.array(bbox)[:, [1, 0]], np.zeros((4, 1))))
コード例 #2
0
        # obs_out[img_num] = np.copy(obs_likelihood)


if __name__ == '__main__':
    f5 = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/fc2_f5.hdf', 'r')
    f5featmeta = pd.read_hdf('/media/sean/D2F2E7B2F2E798CD/Users/student/AIEoutput2/feat/feat_meta.hdf')
    img_times = f5.root.camera.image_raw.compressed.metadata.col('t_valid')
    feat_path = f5featmeta.iloc[:, 3]
    descripath = f5featmeta.iloc[:, 4]

    # Get a truth finder
    dted_path = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/srtm'
    geoid_file = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/egm96-15.tif'
    frame_yaml = '/home/sean/ImageAidedNav/pypnp/data/fc2_pod_frames.yaml'

    finder = pnputils.DEMTileFinder(dted_path, geoid_file)
    finder.load_cam_and_vehicle_frames(frame_yaml)
    finder.load_camera_cal('/home/sean/ImageAidedNav/pypnp/data/fc2_cam_model.yaml')

    # Get the Feature Database
    dbf = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/pytables_db.hdf', 'r')
    dbt = dbf.get_node('/sift_db/sift_features_sorted')

    # Set up the output file
    out_tb = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/obs_out_mat7.hdf', 'w')

    # You need boundaries
    txmin = dbt.cols.x[dbt.colindexes['x'][0]].astype(np.int64)
    txmax = dbt.cols.x[dbt.colindexes['x'][-1]].astype(np.int64)
    tymin = dbt.cols.y[dbt.colindexes['y'][0]].astype(np.int64)
    tymax = dbt.cols.y[dbt.colindexes['y'][-1]].astype(np.int64)
コード例 #3
0
def FMOTF(
    f5,
    f5featmeta,
    dted_path,
    geoid_file,
    frame_yaml,
    cam_yaml,
    dbf,
    out_path,
):
    # f5 = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/fc2_f5.hdf', 'r')
    # f5featmeta = pd.read_hdf('/media/sean/D2F2E7B2F2E798CD/Users/student/AIEoutput2/feat/feat_meta.hdf')
    img_times = f5.root.camera.image_raw.compressed.metadata.col('t_valid')
    feat_path = f5featmeta.iloc[:, 3]
    descripath = f5featmeta.iloc[:, 4]

    # Get a truth finder
    # dted_path = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/srtm'
    # geoid_file = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/egm96-15.tif'
    # frame_yaml = '/home/sean/ImageAidedNav/pypnp/data/fc2_pod_frames.yaml'
    # cam_yaml = '/home/sean/ImageAidedNav/pypnp/data/fc2_cam_model.yaml'

    finder = pnputils.DEMTileFinder(dted_path, geoid_file)
    finder.load_cam_and_vehicle_frames(frame_yaml)
    finder.load_camera_cal(cam_yaml)

    # Get the Feature Database
    # dbf = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/pytables_db.hdf', 'r')
    dbt = dbf.get_node('/sift_db/sift_features_sorted')

    # Set up the output file
    # out_path = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/obs_out_mat7.hdf'
    out_tb = tb.open_file(out_path, 'w')

    # You need boundaries
    txmin = dbt.cols.x[dbt.colindexes['x'][0]].astype(np.int64)
    txmax = dbt.cols.x[dbt.colindexes['x'][-1]].astype(np.int64)
    tymin = dbt.cols.y[dbt.colindexes['y'][0]].astype(np.int64)
    tymax = dbt.cols.y[dbt.colindexes['y'][-1]].astype(np.int64)
    xbounds = (txmin, txmax)
    ybounds = (tymin, tymax)
    print(xbounds)
    print(ybounds)
    xb, yb = neoextent.pad_grid(xbounds, ybounds)
    # TODO Redefine xb and yb to be the tiles that encompassed the area defined by the particles and/or confidence ellipse

    f2l_mat = np.array([1E6])
    n_img_feat = np.array([10E3])

    # Create blessings.Terminal instance
    leaf_values, test_d = build_progress(f2l_mat, n_img_feat, img_times)
    tt = Terminal()
    prog_tree = ProgressTree(term=tt)
    prog_tree.make_room(test_d)

    # Full aggregate tile id
    tid, tidcount = np.unique(dbt.cols.pair_id, return_counts=True)
    extent = neoextent.SearchExtent(15, xb, yb, tid, tidcount)
    zoom_depth = 15  # orginal value was 14

    # Ok do whatever
    filters = tb.Filters(complevel=5, complib='blosc')
    atom = tb.Float64Atom()
    neogeo_shape = (img_times.size, 64, 64)
    times_shape = (img_times.size, )
    leaf_ii = 0
    for f2l in f2l_mat:

        f2l_group = out_tb.create_group(out_tb.root, 'loaded_%d' % int(f2l))
        f2l_group.num_feat_loaded = f2l
        db_rows, N = load_all_features(dbt, extent, zoom_depth, f2l)
        flann, t_build_db = build_flann_db(db_rows)
        f2l_group.time_to_build_flann = t_build_db
        obs_shape = (img_times.size, db_rows.shape[0], 4)
        for n_img in n_img_feat:
            n_group = out_tb.create_group(f2l_group, 'feat_%d' % int(n_img))
            n_group.img_feat = n_img
            neogeo_out = out_tb.create_carray(n_group,
                                              'neogeo_out',
                                              atom=atom,
                                              shape=neogeo_shape,
                                              filters=filters)
            obs_out = out_tb.create_carray(n_group,
                                           'obs_out',
                                           atom=atom,
                                           shape=obs_shape,
                                           filters=filters)
            # print(neogeo_out)
            flann_time = out_tb.create_carray(n_group,
                                              'flann_time',
                                              atom=atom,
                                              shape=times_shape,
                                              filters=filters)
            # dbloc = out_tb.create_carray(n_group,'dbloc',atom=atom, shape=dbloc_shape, filters=filters)
            for img_num in np.arange(img_times.size):
                if f5featmeta.num_feat[img_num] > 0:
                    generate_obs(img_num, n_img, db_rows, obs_out, neogeo_out,
                                 flann_time, flann)
                    leaf_values[leaf_ii].value += 1
                    # if np.mod(leaf_values[leaf_ii].value, 5) == 0:
                    #     prog_tree.cursor.restore()
                    #     prog_tree.draw(test_d)

            leaf_ii += 1
            out_tb.flush()

    out_tb.close()
    dbf.close()
    f5.close()