Пример #1
0
def ground_filter_aligned_data(fn, args):
    #[pointcloud_path, ground_filtering_out_dir, r, x_offset, y_offset, geoid, sigma_geoid] = args
    pts_dir, ref_dir, tmp_dir, out_dir, r, x_offset, y_offset, geoid, sigma_geoid, radius, res_list = args
    
    m,n = fn[:17].split('_')
    [mm,nn] = coord(m, n, r, x_offset, y_offset)

    if fn not in os.listdir(ref_dir):
        return False
    
    # Load mms
    data_mms = read_bin_xyzrid_scale(pts_dir + fn, 12)
    
    # Rough filter based on given DTM
    data_mms = filter_by_reference(data_mms, ref_dir + fn, geoid, sigma_geoid)
    
    if len(data_mms) < 200:
        return False

    data_mms = global2local(data_mms, mm, nn)
    reduced, _  = ground_filter(data_mms, radius, res_list, r, is_plot = False)
    
    if len(reduced) < 200:
        return False

    write_points_double(local2global(reduced, mm, nn)[:,:3], 
                        out_dir + fn)
    return True
Пример #2
0
def apply_height_updates_folder(list_pts,
                                pts_dir,
                                dict_update_pts,
                                res_ref,
                                res_update,
                                out_dir,
                                args,
                                global_shift=0,
                                is_xyz=False):

    r, x_offset, y_offset = args

    for fn in tqdm(list_pts):

        m, n = fn[:17].split('_')
        [mm, nn] = coord(m, n, r, x_offset, y_offset)

        # Apply updates
        data_updates = dict_update_pts[fn]

        # Load mms original points
        if is_xyz:
            data_mms = load_corr_mms(fn, pts_dir, args)

        else:
            data_mms = read_bin_xyzrid_scale(pts_dir + fn, 12)

            # Trans to local system
            data_mms = global2local(data_mms, mm, nn)

        data_updated = apply_height_updates(data_mms, data_updates, res_update,
                                            r, global_shift)

        # Write updated points
        if len(data_updated) > 0:
            write_points_double(local2global(data_updated[:, :3], mm, nn),
                                out_dir + '//' + fn)
Пример #3
0
pathA = geo_ground_filtering_out_dir
pathB = final_dir
pathC = rest_dir

listA = os.listdir(pathA)
listB = os.listdir(pathB)
listC = os.listdir(pathC)
 
#fns_dtm = ['ffffff9', 'ffffffa', 'ffffffb', 'ffffffc', 'ffffffd', 'ffffffe', 'fffffff', 
#           '0000000', '0000001', '0000002', '0000003', '0000004', '0000005', '0000006']

#fns_dtm = ['ffffffe', 'fffffff', 
#           '0000000', '0000001', '0000002', '0000003', '0000004', '0000005', '0000006']

fns_dtm = ['ffffffc', 'ffffffd', 'ffffffe']
           
for fn_dtm in fns_dtm:
    
    print(fn_dtm)
    
    data_dtm = []
    
    for flist, fpath in zip([listA, listB, listC], [pathA, pathB, pathC]):
        sublist = [fn for fn in flist if fn_dtm == fn[:7]]
        for fn in tqdm(sublist):
            data_mms = read_bin_double(fpath + fn, 7)
            data_dtm.extend(data_mms)
    
    write_points_double(data_dtm, out_dtm_dir + fn_dtm + '.ply')
Пример #4
0
        data_updated = []
        for key, value in d_mms.iteritems():
            sub_mms = data_mms[value]
            update_value = data_update[d_update[key][0], 2]
            data_updated.extend(sub_mms -
                                [0, 0, update_value])  # Must be minus here
        data_updated = np.array(data_updated)

        _ = calc_difference_mms_ref(data_updated, data_ref, 0.5, r, shift)

        if len(data_output) != len(data_mms):
            print('updated for ', fn, len(data_output) / float(len(data_mms)))

        if len(data_output) > 0:
            write_points_double(local2global(data_updated, mm, nn),
                                out_dir + '//' + fn)

# Trash
#    # Generate update grid in 0.1m
#    xnew = np.arange(0.05, r, res_update)
#    ynew = np.arange(0.05, r, res_update)
#    xx, yy = np.meshgrid(xnew, ynew)
#    xxf = xx.flatten()
#    yyf = yy.flatten()
#
#    coords9n = get_neighbour_matrix(9)
#    coords = np.array(coords9n)
#    xn = coords[:,0]
#    yn = coords[:,1]

#    ref_out_dir = out_path + 'ref\\'
Пример #5
0
list_mms = os.listdir(mms_dir)

if len(os.listdir(mms_local_dir)) == 0:

    # Move to local coordinate system
    from tqdm import tqdm
    from environmentSetting import r, x_offset, y_offset
    from lib.cell2world import coord
    from lib.load import load_mms
    from lib.ply import write_points_double
    for fn in tqdm(list_mms):
        m, n = fn[:17].split('_')
        [mm, nn] = coord(m, n, r, x_offset, y_offset)
        args = mms_dir, 0, 0, r, x_offset, y_offset
        data_mms = load_mms(fn, args)
        write_points_double(data_mms[:, :3], mms_local_dir + '//' + fn)

else:

    #absolute path of executive software cloudcompare v2.11
    CCPath = r"C:/Program Files/CloudCompare/"
    os.chdir(CCPath)

    # Feature names
    features = [
        "FEATURE OMNIVARIANCE", "FEATURE SURFACE_VARIATION",
        "CURV NORMAL_CHANGE"
    ]
    radius = 0.25
    features_cmd = " ".join(
        ["-" + feat + " " + str(radius) for feat in features])
Пример #6
0
 """
 from lib.apply_transform import apply_height_updates_folder
 apply_height_updates_folder(list_mms, mms_dir, dict_update_pts, res_ref, res_update, 
                             gr_utm_dir, (r, x_offset, y_offset), shift, is_xyz = True)
 
 
 """    
 # Save updates values to tile ply
 """
 from lib.cell2world import coord
 from lib.ply import write_points_double
 from lib.util import global2local, local2global
 for fn, update_values in dict_update_pts.iteritems():
     m,n = fn[:17].split('_')
     [mm,nn] = coord(m, n, r, x_offset, y_offset)
     write_points_double(local2global(update_values[:,:3], mm, nn), 
                         updates_dir + '//' + fn)
 
 
 # Calculate difference and report
 dict_shift_value, list_shift_img = calc_height_diff_entire(tmp_dir, project_name, gr_utm_dir, ref_dir, 
                                                            is_after_dtm_alignment = True)
 
 """
 # Proc to final merged dtm
 """
 raster_size = r/res_ref #30
 radius = 1
 
 from lib.update import update_dtm
 from lib.produceDTM import local_to_UTM, local_to_UTM_update_ref, local_to_UTM_rest_ref
 
Пример #7
0
        #    plt.figure()
        #    plt.imshow(difference)

        _ = calc_difference_mms_ref(data_mms, data_ref, 0.5, r)

        neigh_list = search_neigh_tiles(fn)
        data_update = generate_updates_mms(dict_shift_value, neigh_list)

        d_update = rasterize(data_update, res_update, dim=2)
        d_mms = rasterize(data_mms, res_update, dim=2)

        data_updated = []
        for key, value in d_mms.iteritems():
            sub_mms = data_mms[value]
            update_value = data_update[d_update[key][0], 2]
            data_updated.extend(sub_mms -
                                [0, 0, update_value])  # Must be minus here
        data_updated = np.array(data_updated)

        _ = calc_difference_mms_ref(data_updated, data_ref, 0.5, r)

        if len(data_output) != len(data_mms):
            print('updated for ', fn, len(data_output) / float(len(data_mms)))

        if len(data_output) > 0:
            #write_points(data_output, out_dir + '//_' + fn)

            #            write_points(data_updated, out_dir + '//' + fn)

            write_points_double(data_updated + [mm, nn, 0],
                                out_dir + '//' + fn)