I am attempting to implement a way to publish/stream cameras in one thread, and then start a fusion instance in a seperate thread.
To do this i have the first task which i wrote as such:
class CameraPublishTask(ObservationTask):
def __init__(self, config, redis_handler, task_name: str = "Camera") -> None:
super().__init__(config, redis_handler, task_name)
def loop(self):
print(f"Entering Loop: {self.task_name}")
cameras = Camera.find_and_build(self.config)
for camera in cameras:
s,p = camera.enable_streaming()
camera.start_publishing()
while True and self.is_running:
for camera in cameras:
if camera.can_capture:
image = camera.capture()
The second task I want to look like so:
class FusionTask(ObservationTask):
def __init__(self,config,redis_handler, task_name: str = "Fusion") -> None:
super().__init__(config,redis_handler, task_name)
def loop(self):
print(f"Entering Loop: {self.task_name}")
self.is_running = True
streaming_props = sl.Camera.get_streaming_device_list()
self.fusion = sl.Fusion()
self.fusion.init(self.config.parse_fusion_params())
self.fusion.enable_positionnal_tracking(self.config.parse_fusion_params_tracking())
for cam in streaming_props:
cam_params = self.config.parse_communication_params()
cam_params.set_for_local_network(port=cam.port,ip=cam.ip)
translation = sl.Translation(0,0,0)
transform = sl.Transform()
transform.set_translation(translation)
cam_id = sl.CameraIdentifier(cam.serial_number)
status = self.fusion.subscribe(
uuid=cam_id,
communication_parameters=cam_params,
pose=transform
)
logging.info(f"Subscribed to Camera {cam_id} with status {status}")
while True and self.is_running:
# DO the thing
self.fusion.close()
Logs:
INFO:root:GPS capture started
INFO:root:Camera capture started
INFO:root:Found cameras: [24837248]
WARNING:root:No cameras matched, defaulting to first camera
INFO:root:Camera 24837248 initialized
INFO:root:Camera 24837248: Configuration Successful
INFO:root:Camera 24837248: Streaming enabled: SUCCESS
INFO:root:Camera 24837248: Started publishing SUCCESS
How do i start camera streaming so that i can use sl.Camera.get_streaming_device_list() in other thread/proces?