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])