<blockquote id="76sxc"></blockquote>
<cite id="76sxc"><track id="76sxc"></track></cite>
<legend id="76sxc"></legend>

  • <blockquote id="76sxc"><p id="76sxc"></p></blockquote>
    <sub id="76sxc"><p id="76sxc"></p></sub>

          C++ 多設備示例代碼-Multi Device

          # 多設備示例-MultiDevice

           

          功能描述:本示例主要演示了對多設備進行操作。

          > 本示例基于C++ High Level API進行演示

           

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

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

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

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

           

          打開多個設備的深度和彩色流

          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++;
              }
          }

           

          停止所有設備已打開的流

          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++;
              }
          }

           

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

          預期輸出:

          image.png 


          <blockquote id="76sxc"></blockquote>
          <cite id="76sxc"><track id="76sxc"></track></cite>
          <legend id="76sxc"></legend>

        1. <blockquote id="76sxc"><p id="76sxc"></p></blockquote>
          <sub id="76sxc"><p id="76sxc"></p></sub>

                美日韩操逼视频 | 少妇的诱惑k8 | 最新中文字幕在线 | 日韩人妻中文无码一区二区中文无码 | 日本无码免费视频 | 40岁女人毛片 | 4人痴女超短裙ol波多野结衣 | 日本熟妇丰满毛茸茸无码 | 亚洲成人免费网站 | 亚洲天堂AV在线观看 |