- 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