Skip to content

Connect

SUMMARY

Connect opens a connection to the camera hardware so frames can be acquired. It initializes the underlying vendor SDK, opens the device, allocates buffers or starts the pipeline, and registers any BabyROS nodes the camera class exposes.

Always pair it with Disconnect inside a try / finally block so the device is freed even if an exception is raised.

All subsequent operations on the camera require an active connection.

Available on: All cameras.

The Skill

python
camera.connect()

For RealSense, optional stream parameters can be passed to connect:

python
camera.connect(width=640, height=480, fps=30)

The Code

python
from loguru import logger
from telekinesis.medulla.cameras import webcam

camera = webcam.Webcam(name="my_webcam_camera", camera_id=0)
try:
    camera.connect()
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import ids

camera = ids.IDS(
    name="my_ids_camera",
    serial_number="4108909352",
    load_factory_defaults=False,
)
try:
    camera.connect()
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import realsense

camera = realsense.RealSense(name="my_realsense_camera")
try:
    camera.connect()
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()
python
from loguru import logger
from telekinesis.medulla.cameras import zivid

camera = zivid.Zivid(name="my_zivid_camera")
try:
    camera.connect()
except Exception as e:
    logger.error(f"Unable to connect to the camera. {type(e).__name__}: {e}")
finally:
    camera.disconnect()

The Explanation of the Code

connect performs the vendor-specific initialization needed before any frame can be acquired:

  • IDS — opens the device by serial_number through the IDS Peak library and allocates the acquisition buffers needed to receive frames from the sensor. With load_factory_defaults=False, parameters previously configured in IDS Peak Cockpit are preserved.
  • Webcam — opens the device via OpenCV's VideoCapture using the integer camera_id reported by the OS (0 for the first camera) and verifies that frames can be read.
  • RealSense — initializes the RealSense pipeline with default stream settings, enabling the depth and colour streams. No serial number is required; the class connects to the first available device automatically. Optional width, height, and fps parameters configure both the colour and depth streams simultaneously.
  • Zivid — initializes the Zivid SDK application and connects to the first available Zivid camera. Default capture settings are created with a single 3D acquisition and a single 2D colour acquisition. Use load_settings after connecting to apply a configuration exported from Zivid Studio.

WARNING

Make sure to disconnect from the camera with disconnect() at the end of your script to avoid a freezing terminal when the script finishes.

Where to Use the Skill

Connect is the first call against any Medulla camera. Pair it with Disconnect inside a try / finally block so resources are released regardless of how the script exits. See Capture Color Image for the full pattern in practice.