On this point, I have a question. If depthai-core has zero error handling, why doesn't example code contain try/catch blocks, demonstrating the proper manner for consumers to implement error handling? I'm not sure what I should be placing try/catch blocks around. From what I'm witnessing, an exception could be thrown virtually anywhere, making things a bit tedious. Is there a document that describes this? What is proper cleanup procedure if a certain type of exception is thrown?
Unstable connection / connectivity issues
Is there a way to prevent dai::Device
from trying to connect to a device on construction? This is a very strange implementation. Typically with an API such as this involving networking, there should be a Connect() method on the class that governs this type of behavior. How do I define properties like wait time limit? How long does it look for a device before it gives up? How long does it wait for a response in the middle of a stream before it decides the connection has been lost? How do I recycle the object and tell it to ReConnect() if a connection is lost for some reason?
I'm reading through the code.
https://github.com/luxonis/depthai-core/blob/main/src/device/Device.cpp
https://github.com/luxonis/depthai-core/blob/main/src/device/DeviceBase.cpp
https://github.com/luxonis/depthai-core/blob/main/include/depthai/device/Device.hpp
Adding to the discussion, what I'm seeing is that both dai::Device
and dai::DeviceBase
constructors always call startPipeline()
, which is an expensive blocking operation. I don't mean to be rude, but this is a crime against object orientation.
- Edited
Here are some screenshots. The code executing is as follows.
std::vector<std::uint8_t> PSCore::Test1()
{
using namespace std;
dai::Device \*dptr = nullptr; try { // Create pipeline dai::Pipeline pipeline; // Define source and output auto camRgb = pipeline.create<dai::node::ColorCamera>(); auto xoutRgb = pipeline.create<dai::node::XLinkOut>(); xoutRgb->setStreamName("rgb"); xoutRgb->input.setBlocking(false); xoutRgb->input.setQueueSize(1); // Properties camRgb->setBoardSocket(dai::CameraBoardSocket::RGB); camRgb->setResolution(dai::ColorCameraProperties::SensorResolution::THE_1080_P); camRgb->setInterleaved(false); camRgb->setColorOrder(dai::ColorCameraProperties::ColorOrder::BGR); //camRgb->setPreviewSize(300, 300); //camRgb->setVideoSize(4056, 3040); camRgb->setVideoSize(1920, 1080); // Linking //camRgb->preview.link(xoutRgb->input); camRgb->video.link(xoutRgb->input); // Connect to device and start pipeline auto deviceInfo = dai::DeviceInfo("192.168.8.116"); auto device = dai::Device(pipeline, deviceInfo); dptr = &device; cout << "Connected cameras: " << device.getConnectedCameraFeatures() << endl; // Print USB speed // device already closed or disconnected exception //cout << "Usb speed: " << device.getUsbSpeed() << endl; // Bootloader version if(device.getBootloaderVersion()) { cout << "Bootloader version: " << device.getBootloaderVersion()->toString() << endl; } // Device name cout << "Device name: " << device.getDeviceName() << endl; // Output queue will be used to get the rgb frames from the output defined above //auto qRgb = device.getOutputQueue("rgb", 4, false); auto qRgb = device.getOutputQueue("rgb"); while(true) { auto inRgb = qRgb->get<dai::ImgFrame>(); auto type = inRgb->getType(); auto data = inRgb->getData(); device.close(); return data; } } catch(const std::exception &ex) { cout << ex.what(); int stophere = 7; } catch(...) { int stophere = 7; } //cleanup if(dptr != nullptr) { dptr->close(); //delete dptr; } return {};
}
These screenshots are successive runs.
run #1, exception thrown
run #2, successful
run #3, run#4, run#5 - all same as run #1
run #6, successful
run #7
It now appears that the device itself has crashed. I've run dozens of times and always same as run#7 results. How can the device be crashing???? Touching the device it is cold to the touch, which so far is the best method I've found to check if the device is online or not.
Is this normal behavior, for the firmware on the device to crash? What is the best way to tell if the device is running or not? Is there a status light or something I could turn on?
After power cycling the PoE/device, I started getting successful runs again. Then this. So if you look back at the code, I got through the line auto device = dai::Device(pipeline, deviceInfo);
, but then an exception was thrown in midst of device.getConnectedCameraFeatures()
. LOL. When I say random errors this is what I mean. This is extremely simple code, it's quite literally your sample code. Am I having a normal experience here? Is there something physically wrong with this camera?
Hi jt512 ,
Please also try the latest develop
version of depthai library - relevant github issue here.
Thanks, Erik
The branches main
, v2.21.2
, and develop
are all at the same commit…
- Edited
I see, it was just released 2 hours ago. The main changes are in the firmware, see commit here.
I am also experiencing deadlocks on dai::Device::close()
quite frequently. Referring to the code above, after getting a single frame, I call device.close(), break out of the loop and return the single frame. Deadlock on device.close();
I'm gonna send an email.
FYI, I can confirm the 2.21.2 update does nothing. Same exact sporadic connectivity issues.