from cam_server import PipelineClient from cam_server.utils import get_host_port_from_stream_address from bsread import source, SUB # Define the camera name you want to read. camera_name = "SLG-LCAM-C011" # First create the pipeline for the selected camera. client = PipelineClient() instance_id, stream_address = client.create_instance_from_config({"camera_name": camera_name}) # Extract the stream host and port from the stream_address. stream_host, stream_port = get_host_port_from_stream_address(stream_address) # Check if your instance is running on the server. if instance_id not in client.get_server_info()["active_instances"]: raise ValueError("Requested pipeline is not running.") # Open connection to the stream. When exiting the 'with' section, the source disconnects by itself. with source(host=stream_host, port=stream_port, mode=SUB) as input_stream: input_stream.connect() # Read one message. message = input_stream.receive() # Print out the received stream data - dictionary. print("Dictionary with data:\n", message.data.data) # Print out the X center of mass. print("X center of mass: ", message.data.data["x_center_of_mass"].value)