nbv_rec_control/utils/communicate_util.py

35 lines
1.1 KiB
Python
Raw Normal View History

2024-10-08 21:28:30 +08:00
import requests
import numpy as np
2024-10-07 16:20:56 +08:00
class CommunicateUtil:
2024-10-09 21:46:13 +08:00
VIEW_HOST = "192.168.1.2:7999" #"10.7.250.52:7999" ##
INFERENCE_HOST = "127.0.0.1"
INFERENCE_PORT = 5000
2024-10-07 16:20:56 +08:00
2024-10-08 21:28:30 +08:00
def get_view_data(init = False) -> dict:
params = {}
params["create_scanner"] = init
response = requests.get(f"http://{CommunicateUtil.VIEW_HOST}/api/data", json=params)
data = response.json()
2024-10-09 21:46:13 +08:00
2024-10-08 21:28:30 +08:00
if not data["success"]:
print(f"Failed to get view data")
return None
2024-10-09 21:46:13 +08:00
image_id = data["image_id"]
depth_image = np.array(data["depth_image"], dtype=np.uint16)
depth_intrinsics = data["depth_intrinsics"]
depth_extrinsics = np.array(data["depth_extrinsics"])
view_data = {
"image_id": image_id,
"depth_image": depth_image,
"depth_intrinsics": depth_intrinsics,
"depth_extrinsics": depth_extrinsics
}
return view_data
2024-10-07 16:20:56 +08:00
2024-10-07 21:48:24 +08:00
def get_inference_data(view_data:dict) -> dict:
data = {}
2024-10-07 16:20:56 +08:00
return data
2024-10-09 21:46:13 +08:00
2024-10-07 16:20:56 +08:00