中国 · 南京 · 栖霞区紫东路2号紫东国际创意园B3-2幢5F
+86-18994094214 (仅工作日:8:30~17:30)
contact@oakchina.cn

【69】我现在想在一个函数里创建OAK PoE设备,一个函数里关闭OAK PoE设备?有没有什么解决方案?

View Categories

【69】我现在想在一个函数里创建OAK PoE设备,一个函数里关闭OAK PoE设备?有没有什么解决方案?

< 1 min read

#include "depthai/depthai.hpp"
 
std::shared_ptr<dai::Device> device;
 
void start(const dai::Pipeline& pipeline) {
  device = std::make_shared<dai::Device>(pipeline);
}
 
void stop() { device->close(); }
 
dai::Pipeline getPipeline() {
  // 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");
 
  // Properties
  camRgb->setPreviewSize(300, 300);
  camRgb->setBoardSocket(dai::CameraBoardSocket::RGB);
  camRgb->setResolution(
      dai::ColorCameraProperties::SensorResolution::THE_1080_P);
  camRgb->setInterleaved(false);
  camRgb->setColorOrder(dai::ColorCameraProperties::ColorOrder::RGB);
 
  // Linking
  camRgb->preview.link(xoutRgb->input);
  return pipeline;
}
 
int main() {
 
  start(getPipeline());
 
  std::cout << "Connected cameras: ";
  for(const auto& cam : device->getConnectedCameras()) {
    std::cout << cam << " ";
  }
  std::cout << std::endl;
 
  // Print USB speed
  std::cout << "Usb speed: " << device->getUsbSpeed() << std::endl;
 
  // Bootloader version
  if(device->getBootloaderVersion()) {
    std::cout << "Bootloader version: " << device->getBootloaderVersion()->toString() << std::endl;
  }
 
  /*
   *
   * */
 
  stop();
}