從影像數據中檢測並提取符合特徵的地物,結果信息輸出到GeoJSON文件中。json
import os import time from iobjectspy import open_datasource from iobjectspy.ai.recognition import detection
#data_dir = '' data_dir = '/home/jovyan/data/smdata/' out_dir = os.path.join(data_dir, 'out/') model_path = os.path.join(data_dir, 'model/det/1') print(model_path) category_name = ['plane']
/home/jovyan/data/smdata/model/det/1
if not os.path.exists(out_dir): os.makedirs(out_dir) def extract_plane_file(): """ 影像文件格式支持 ‘tif’、‘img’(Erdas Image)、'jpg'、'png' 等 目標檢測結果爲GeoJSON文件,包含目標位置、類型等信息 """ start_time = time.time() detection(data_dir + 'plane.tif', category_name, model_path, out_data=out_dir, out_name='out_plane.json') end_time = time.time() print('耗時{}s'.format(end_time-start_time))
if __name__ == '__main__': # 基於影像文件進行飛機目標檢測 extract_plane_file()
INFO:tensorflow:Saver not created because there are no variables in the graph to restore INFO:tensorflow:The specified SavedModel has no variables; no checkpoints were restored. 耗時5.122027635574341s