• <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
      <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
    • <dfn id="2awkm"></dfn>
      <menu id="2awkm"><acronym id="2awkm"></acronym></menu>
      
      
      <rt id="2awkm"></rt><dfn id="2awkm"><code id="2awkm"></code></dfn>
    • <dd id="2awkm"><s id="2awkm"></s></dd>
      <tbody id="2awkm"></tbody>
    • <dfn id="2awkm"></dfn>
      <menu id="2awkm"><noscript id="2awkm"></noscript></menu>

      C++ 多設(shè)備示例代碼-Multi Device

      # 多設(shè)備示例-MultiDevice

       

      功能描述:本示例主要演示了對多設(shè)備進(jìn)行操作。

      > 本示例基于C++ High Level API進(jìn)行演示

       

      首先需要創(chuàng)建一個Context,獲取設(shè)備信息列表用于創(chuàng)建設(shè)備及Pipeline

      ob::Context ctx;
      //查詢已經(jīng)接入設(shè)備的列表
      auto devList = ctx.queryDeviceList();
      //獲取接入設(shè)備的數(shù)量
      int devCount = devList->deviceCount();

      創(chuàng)建設(shè)備,并通過設(shè)備創(chuàng)建Pipeline

      //遍歷設(shè)備列表并創(chuàng)建設(shè)備
      std::vector<std::shared_ptr<ob::Device>> devices;
      for (int i = 0; i < devCount; i++)
      {
          //獲取設(shè)備并創(chuàng)建pipeline
          auto dev  = devList->getDevice( i );
          auto pipe = std::make_shared< ob::Pipeline >( dev );
          pipes.push_back( pipe );

       

      打開多個設(shè)備的深度和彩色流

      void StartStream(std::vector<std::shared_ptr<ob::Pipeline>> pipes) {
          int i = 0;
          for(auto &&pipe: pipes) {
              std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
              // Get the depth camera configuration list
              auto                                    depthProfileList = pipe->getStreamProfileList(OB_SENSOR_DEPTH);
              std::shared_ptr<ob::VideoStreamProfile> depthProfile     = nullptr;
              if(depthProfileList) {
                  // Open the default profile of Depth Sensor, which can be configured through the configuration file
                  depthProfile = std::const_pointer_cast<ob::StreamProfile>(depthProfileList->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
              }
              config->enableStream(depthProfile);

              // Get the color camera configuration list
              try {
                  auto                                    colorProfileList = pipe->getStreamProfileList(OB_SENSOR_COLOR);
                  std::shared_ptr<ob::VideoStreamProfile> colorProfile     = nullptr;
                  if(colorProfileList) {
                      // Open the default profile of Color Sensor, which can be configured through the configuration file
                      colorProfile = std::const_pointer_cast<ob::StreamProfile>(colorProfileList->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
                  }
                  config->enableStream(colorProfile);
              }
              catch(ob::Error &e) {
                  std::cerr << "Current device is not support color sensor!" << std::endl;
              }

              // Start the pipeline and pass in the configuration
              pipe->start(config, [i](std::shared_ptr<ob::FrameSet> frameSet) {
                  std::lock_guard<std::mutex> lock(frameMutex);
                  if(frameSet->colorFrame()) {
                      colorFrames[i] = frameSet->colorFrame();
                  }
                  if(frameSet->depthFrame()) {
                      depthFrames[i] = frameSet->depthFrame();
                  }
              });
              i++;
          }
      }

       

      停止所有設(shè)備已打開的流

      void StopStream( std::vector< std::shared_ptr< ob::Pipeline > > pipes) {
          int i = 0;
          for ( auto&& pipe : pipes ) {
              if(colorFrames[i])
                  colorFrames->reset();
              if(depthFrames[i])
                  depthFrames->reset();
              if(irFrames[i])
                  irFrames->reset();
              //停止pipeline
              pipe->stop();
              i++;
          }
      }

       

      程序正常退出之后資源將會自動釋放

      預(yù)期輸出:

      image.png 


      • <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
        <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
      • <dfn id="2awkm"></dfn>
        <menu id="2awkm"><acronym id="2awkm"></acronym></menu>
        
        
        <rt id="2awkm"></rt><dfn id="2awkm"><code id="2awkm"></code></dfn>
      • <dd id="2awkm"><s id="2awkm"></s></dd>
        <tbody id="2awkm"></tbody>
      • <dfn id="2awkm"></dfn>
        <menu id="2awkm"><noscript id="2awkm"></noscript></menu>
        亚洲一二三视频 | A级成人毛片 | 殴美黄色录像 | 欧美视频网站在线观看 | 亚洲日韩精品国产一区二区三区 |