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, and closes the camera.
  • Webcam — releases the VideoCapture device.
  • 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.

After disconnecting, the camera stops serving its BabyROS communication topics and cannot be connected again; create a new camera instance to reconnect.

Returns ​

TypeDescription
Nonedisconnect() has no return value on any camera.

Raises ​

disconnect() does not raise. Calling it on a camera that is not connected logs a warning and returns, and an error while releasing the device is logged as a warning rather than raised.

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.