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: All cameras.

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.
  • Zivid — releases the Zivid SDK application and camera resources so the device can be used by other programs (e.g. Zivid Studio).

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.

Parameter Configuration ​

disconnect() takes no parameters.

Returns ​

TypeDescription
boolIDS, Webcam, RealSense: True if the camera was connected and is now disconnected, False if it was already disconnected.
NoneZivid: no return value.

Raises ​

ExceptionCondition
RuntimeErrorZivid only — the Zivid SDK fails to release the camera.

IDS, Webcam, and RealSense tolerate being called while not connected and do not raise; Zivid logs a warning and returns instead of raising in that case.

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.