dms-client/util/json_util.py
XinYi Song c5481ead05 1、搭建flask框架。
2、整合JPSS,葵花8,GF3,哨兵1,哨兵2,哨兵3,资源2号,环境1号,SNPP等遥感数据解析算法。
3、flask中添加扫描各个卫星扫描任务,定时扫描,数据入库
2021-12-01 14:27:49 +08:00

45 lines
2.1 KiB
Python

import json
import os
def write_info(file_name, file_info):
dir = os.path.dirname(file_name)
if not os.path.exists(dir):
os.makedirs(dir)
with open('{}.json'.format(file_name), 'w', encoding='UTF-8') as fp:
json.dump(file_info, fp, indent=4, sort_keys=False)
def read_json(file_path):
with open(file_path, 'r') as f:
data = json.load(f)
return data
report_data = {"project_no": "628740635893760", "img_path": "2000.png",
"create_time": "2021-06-10T11:17:12.202000+00:00", "labels": [
{"shape": "polygon", "name": "a", "line_width": 2, "width": 750.0, "height": 788.0, "comment": "string",
"color": "rgb(255, 0, 123)", "is_match": "False", "score": 0.0,
"point": [{"x": 114.04715127701375, "y": 53.04518664047151}, {"x": 196.2671905697446, "y": 53.04518664047151},
{"x": 196.2671905697446, "y": 149.4106090373281},
{"x": 114.04715127701375, "y": 149.4106090373281}]},
{"shape": "polygon", "name": "a", "line_width": 2, "width": 750.0, "height": 788.0, "comment": "string",
"color": "rgb(255, 0, 123)", "is_match": "False", "score": 0.0,
"point": [{"x": 284.67583497053045, "y": 64.53831041257367}, {"x": 401.3752455795678, "y": 64.53831041257367},
{"x": 401.3752455795678, "y": 266.1100196463654},
{"x": 284.67583497053045, "y": 266.1100196463654}]},
{"shape": "polygon", "name": "a", "line_width": 2, "width": 750.0, "height": 788.0, "comment": "string",
"color": "rgb(255, 0, 123)", "is_match": "False", "score": 0.0,
"point": [{"x": 501.2770137524558, "y": 148.52652259332024}, {"x": 623.2809430255403, "y": 148.52652259332024},
{"x": 623.2809430255403, "y": 320.0392927308448},
{"x": 501.2770137524558, "y": 320.0392927308448}]}]}
if __name__ == "__main__":
path = os.path.abspath(os.path.dirname(__file__))
print(path)
# write_info('', dict(report_data))
# read_json('d://report.json')
# s = '/group1/628740635893760/ori/images/7 (1).png'
# s1 = s.replace('images', 'labels')
# print(s[2])