Skip to content

Disconnect

SUMMARY

Disconnect stops acquisition, releases device resources, and shuts down any BabyROS nodes registered inside the camera instance. Always pair it with Connect inside a try / finally block so the device is freed even if an exception is raised.

Available on: IDS, Webcam, Intel RealSense.

The Skill

python
camera.disconnect()

The Code

The disconnect call is identical across cameras. The recommended pattern is to place it in a finally block so it runs regardless of how the script exits.

python
try:
    camera.connect()
    # ... acquire frames, set parameters, etc.
finally:
    camera.disconnect()

The Explanation of the Code

disconnect performs the vendor-specific teardown needed to release the device cleanly:

  • IDS — stops acquisition, releases all allocated buffers, closes the IDS Peak library, and shuts down BabyROS nodes registered inside the IDS instance.
  • Webcam — releases the VideoCapture device and shuts down BabyROS nodes registered inside the Webcam instance.
  • RealSense — stops the RealSense pipeline and releases all USB resources.

The finally block guarantees disconnect runs even if an exception is raised during acquisition, which prevents the device from being left in an unusable state until the next process restart.

Where to Use the Skill

Always pair Disconnect with Connect. When using BabyROS, also call node.SessionManager.delete() after disconnect to tear down the BabyROS session — see Publish Video with BabyROS for the full pattern.