| | |
| | | from typing import List |
| | | import numpy as np |
| | | import cv2 |
| | | import requests |
| | | |
| | | # # add python path of src to sys.path |
| | | # src_path = os.path.join(__file__, *(['..'] * 2)) |
| | |
| | | def __init__(self, |
| | | queue_list:List[queue.Queue], |
| | | queue_tags:List[str], |
| | | task_folder:dict[str,str]): |
| | | task_folder:dict[str,str], |
| | | replay_host:str): |
| | | super().__init__() |
| | | |
| | | self.queue_list = queue_list |
| | | self.queue_tags = queue_tags |
| | | self.queue_num = 0 |
| | | self.task_folder = task_folder |
| | | self.replay_host = replay_host |
| | | self.is_stop = False |
| | | |
| | | assert len(self.queue_list) == len(self.queue_tags) |
| | |
| | | |
| | | # display the info to the console |
| | | curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S') |
| | | print(f"[x] {curr_time}|(From {msg_source}): {msg_context}" ) |
| | | notice_str = f"[x] {curr_time}|(From {msg_source}): {msg_context}" |
| | | print(notice_str) |
| | | replay_to_(host = self.replay_host, |
| | | message=notice_str, |
| | | message_type="logs", |
| | | taskuuid=taskuuid) |
| | | |
| | | # next msg |
| | | count += 1 |
| | |
| | | |
| | | # display the info to the console |
| | | curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S') |
| | | print(f"[x] {curr_time}|(From {msg_source}): image{id} saved!" ) |
| | | notice_str = f"[x] {curr_time}|(From {msg_source}): image{id} saved!" |
| | | print(notice_str) |
| | | replay_to_(host = self.replay_host, |
| | | message=notice_str, |
| | | message_type="images", |
| | | taskuuid=taskuuid) |
| | | |
| | | # next image item |
| | | id += 1 |
| | |
| | | filename = f"{msg_timestamp}-{msg_source}-pointcloud{id}" |
| | | write_ply(data_array,save_folder,filename) |
| | | |
| | | # display the info to the console |
| | | curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S') |
| | | notice_str = f"[x] {curr_time}|(From {msg_source}): ply{id} saved!" |
| | | print(notice_str) |
| | | replay_to_(host = self.replay_host, |
| | | message=notice_str, |
| | | message_type="plys", |
| | | taskuuid=taskuuid) |
| | | |
| | | # next ply item |
| | | id += 1 |
| | | |
| | |
| | | |
| | | raise NotImplementedError("NOT IMPLEMENT!") |
| | | |
| | | |
| | | def replay_to_(host:str, |
| | | message:str, |
| | | message_type:str, |
| | | taskuuid:str, |
| | | ): |
| | | |
| | | if taskuuid != "init": |
| | | try: |
| | | # target = host+taskuuid |
| | | target = host |
| | | print(f"Send message to [{target}]") |
| | | payload = {"taskid":taskuuid, "messagetype":message_type, "message": message} |
| | | r = requests.post(target,params = payload,timeout=3) |
| | | print("send success!") |
| | | except Exception as e: |
| | | print(e) |
| | | print("send error!") |
| | | pass |
| | | |
| | | |
| | | def send_logs_tool(logs:List[str], |
| | |
| | | # end the outer while loop and triminate this function |
| | | |
| | | else: |
| | | print("[x] NO poindcloud has been captured!") |
| | | print("[x] NO pointcloud has been captured!") |
| | | run = False |
| | | else: |
| | | time.sleep(3) |