Example #1
0
def crawl_panos_in_district_area(
    district='南山区',
    key='name',
    fn='/home/pcl/Data/minio_server/input/Shenzhen_boundary_district_level_wgs.geojson'
):
    area = gpd.read_file(fn)
    area.query(f"{key} =='{district}'", inplace=True)
    if area.shape[0] == 0:
        return None

    area = area.iloc[0].geometry
    features = get_features('line', geom=area)
    panos = get_features('point', geom=area)

    res = []
    count = 0
    for rid in tqdm(features.RID.unique(), district):
        info, _ = traverse_panos_by_rid(rid, panos, log=None, all=True)
        res += info
        count += 1
        # if count > 500: break
    print(len(res))

    return res
Example #2
0
def count_panos_num_by_area():
    """Count panos number in several area.

    Returns:
        [type]: [description]
    """
    areas = gpd.read_file(
        '/home/pcl/Data/minio_server/input/Shenzhen_boundary_district_level_wgs_with_Dapeng.geojson'
    )
    res = {}
    for index, district in tqdm(areas.iterrows()):
        panos = get_features('point', geom=district.geometry)
        res[district.name_cn] = panos.shape[0]

    # df = gpd.sjoin(left_df=area, right_df=DB_panos, op='contains').groupby('name')[['DIR']].count()

    return res
def get_panos_imgs_by_bbox(bbox=[113.92348,22.57034, 113.94372,22.5855], vis=True, with_folder=False):
    """给定一个区域,获取所有的panos

    Args:
        bbox (list, optional): [description]. Defaults to [113.92348,22.57034, 113.94372,22.5855].
        vis (bool, optional): [description]. Defaults to True.
        with_folder (bool, optional): [description]. Defaults to False.

    Returns:
        [type]: [description]
    """
    res = []
    features = get_features('line', bbox=bbox)
    if vis: map_visualize(features)

    for rid in tqdm(features.RID.unique(), desc='get_panos_imgs_by_bbox'):
        info, _ = traverse_panos_by_rid(rid, DB_panos, log=pano_API_log, all=False)
        res += info
    print( 'total number of pano imgs: ', len(res))
    
    if not with_folder:
        res = [ i.split('/')[-1] for  i in res]
    
    return res
from pano_img import traverse_panos_by_rid, pano_API_log
from road_network import OSM_road_network 
# from road_matching import * # df_edges: osm_shenzhen.edges

from db.features_API import get_features
from utils.utils import load_config
from utils.classes import Digraph
from utils.df_helper import query_df, load_df_memo
from utils.geo_plot_helper import map_visualize
from utils.img_process import plt_2_Image, cv2_2_Image, combine_imgs
from utils.spatialAnalysis import create_polygon_by_bbox, linestring_length
from model.lstr import draw_pred_lanes_on_img, lstr_pred, lstr_pred_by_pid

# DB_panos, DB_roads = load_DB_panos(), load_DB_roads()
df_edges = get_features('edge')
DB_panos = get_features('point')
DB_roads = get_features('line')

config = load_config()
LSTR_DEBUG_FOLDER = config['data']['tmp']
df_memo = load_df_memo(config['data']['df_pred_memo'])
VISITED = set()
ROAD_PANO_COUNT_DICT = {}

#%%

"""deprecated funcs"""

def _get_revert_df_edges(road_id, df_edges, vis=False):
    """create the revert direction edge of rid in OSM file
from utils.spatialAnalysis import *
from labels.label_helper import crop_img_for_lable
from road_network import OSM_road_network

import warnings

warnings.filterwarnings('ignore')

# TODO 梳理函数名,感觉现在的很乱
_, DB_panos, DB_connectors, DB_roads = load_from_DB(False)

config = load_config()
pano_dir = config['data']['pano_dir']
pano_group_dir = config['data']['pano_group_dir']

df_edges = get_features('edge')


#%%
# 辅助函数
def _matching_panos_path_to_network(road,
                                    DB_roads=DB_roads,
                                    vis=True,
                                    vis_step=False,
                                    save_fig=True,
                                    buffer_thres=0.00005,
                                    angel_thres=30):
    """Find the matching path of panos for a special road based on the frechet distance

    Args:
        road ([type]): [description]