From 5ff2c94df178fe33fc4143fb0e172e54bb5cbb82 Mon Sep 17 00:00:00 2001 From: weixin_46229132 Date: Thu, 12 Jun 2025 17:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E5=9D=90=E6=A0=87=E7=B3=BB=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E4=BB=A3=E7=A0=81=E9=9A=94=E7=A6=BB=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trans_orthophoto.py => trans_orthophoto.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rename post_pro/trans_orthophoto.py => trans_orthophoto.py (71%) diff --git a/post_pro/trans_orthophoto.py b/trans_orthophoto.py similarity index 71% rename from post_pro/trans_orthophoto.py rename to trans_orthophoto.py index 7d4297b..dc0ca61 100644 --- a/post_pro/trans_orthophoto.py +++ b/trans_orthophoto.py @@ -1,4 +1,5 @@ import logging +import argparse import rasterio from rasterio.warp import calculate_default_transform, reproject, Resampling @@ -6,6 +7,8 @@ from rasterio.warp import calculate_default_transform, reproject, Resampling class TransOrthophoto: def __init__(self): self.logger = logging.getLogger('UAV_Preprocess.TransOrthophoto') + logging.basicConfig(level=logging.INFO, + format='%(asctime)s %(levelname)s %(message)s') def trans_to_epsg4326(self, ori_orthophoto_path: str, output_path: str): # 打开原始文件 @@ -37,8 +40,13 @@ class TransOrthophoto: resampling=Resampling.nearest ) - self.logger.info(f"文件已成功重投影") + self.logger.info(f"文件已成功重投影: {output_path}") -if __name__ == "__main__": - trans = TransOrthophoto() - trans.trans_to_epsg4326(r"G:\ODM_output\test\orthophoto.tif", r"G:\ODM_output\test\orthophoto_epsg4326.tif") \ No newline at end of file + +parser = argparse.ArgumentParser(description="正射影像投影转换为EPSG:4326") +parser.add_argument('--input_img', required=True, help='输入影像路径') +parser.add_argument('--output_img', required=True, help='输出影像路径') +args = parser.parse_args() + +trans = TransOrthophoto() +trans.trans_to_epsg4326(args.input_img, args.output_img)