From a38ea664f3fa9d0ec2fac287e4096f1c747e00b1 Mon Sep 17 00:00:00 2001 From: wangziyang <2890199310@qq.com> Date: Mon, 4 Jul 2022 07:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9calculate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/prepare/calculate.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/prepare/calculate.py b/src/prepare/calculate.py index 7182c26..6ab2cb6 100644 --- a/src/prepare/calculate.py +++ b/src/prepare/calculate.py @@ -4,9 +4,41 @@ # @Software: PyCharm # @Function: import os +import sys +import subprocess +import json +import re +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../PaddleClas-release-2.3") +from Search_2D import Astar, plotting, env -os.chdir(r'E:\PaddleClas-release-2.3\PaddleClas-release-2.3\deploy') +def main(): + s_start = (5, 5) + s_goal = (45, 25) + + astar = Astar.AStar(s_start, s_goal, "euclidean") + plot = plotting.Plotting(s_start, s_goal) + + path, visited = astar.searching() + plot.animation(path, visited, "A*") # animation + +# if __name__ == '__main__': +# main() + +os.chdir(r'E:\PaddleClas-release-2.3\PaddleClas-release-2.3\deploy') #### -os.system('python python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="./Trees/test_images/90.jpeg" -o IndexProcess.index_dir="./Trees/index" -o Global.use_gpu=False -o IndexProcess.Image_root="./Trees/gallery/" -o IndexProcess.data_file="./Trees/gallery/tree_list.txt') +result = subprocess.Popen('python python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs="./Trees/test_images/90.jpeg" -o IndexProcess.index_dir="./Trees/index" -o Global.use_gpu=False -o IndexProcess.Image_root="./Trees/gallery/" -o IndexProcess.data_file="./Trees/gallery/tree_list.txt', + shell=False, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding='utf-8', + ) + +string = result.communicate()[0].split("per batch image")[1].replace("'", '"').strip() +ansi_escape = re.compile(r'\n\x1b(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') +result = ansi_escape.sub('', string) +data_json = json.loads(result) +print(data_json[0]) +print(data_json[1]) +print(data_json[2])