luxonis / depthai-core

DepthAI C++ Library
MIT License
235 stars 127 forks source link

How do I stop and then restart an Oak-D camera #707

Open bobdavies2000 opened 1 year ago

bobdavies2000 commented 1 year ago

My application supports multiple cameras and when I switch to or from the Oak-D camera everything is working fine. However, when I switch back to the Oak-D camera that was previously active, it doesn't work. I found the device.close() interface and I use that when closing the device. I looked through all the examples and none of them close the camera. Nor do any stop and then restart the camera. Is there a chance you could provide an example that shows how to close and restart a camera?

masterbuchi commented 1 year ago

I would also like to know that. device.close() doesn't really seem to help, because my python-code is throwing an "X_LINK_ERROR" when trying to create a new connection.

themarpe commented 1 year ago

In Python, best is to leave the "device" object get closed from exiting the with scope

In C++ similar, letting the destructor run.


If you have issues reconnecting, for the time being, I suggest waiting a tad between reconnecting, as the device restarts and is temporarily unavailable after being closed