<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++ 多路流同時(shí)開流示例代碼-Multi Stream

          # 多路流同時(shí)開流示例-MultiStream

          功能描述:本示例主要演示用device同時(shí)打開多個(gè)sensor流的操作,顯示多路流圖像,并通過ESC_KEY鍵退出程序

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

           

          首先需要?jiǎng)?chuàng)建一個(gè)pipeline

          ob::Pipeline pipe

           

           

          枚舉設(shè)備,并進(jìn)行流配置

          // enumerate and config all sensors
          auto device     = pipe.getDevice();
          auto sensorList = device->getSensorList();
          for(int i = 0; i < sensorList->count(); i++) {
              auto sensorType = sensorList->type(i);
              if(sensorType == OB_SENSOR_GYRO || sensorType == OB_SENSOR_ACCEL) {
                  continue;
              }
              auto profiles = pipe.getStreamProfileList(sensorType);
              auto profile  = profiles->getProfile(OB_PROFILE_DEFAULT);
              config->enableStream(profile);
          }

           

          通過配置開啟pipeline

          // Start the pipeline with config
          std::mutex                                        frameMutex;
          std::map<OBFrameType, std::shared_ptr<ob::Frame>> frameMap;
          pipe.start(config, [&](std::shared_ptr<ob::FrameSet> frameset) {
              auto count = frameset->frameCount();
              for(int i = 0; i < count; i++) {
                  auto                         frame = frameset->getFrame(i);
                  std::unique_lock<std::mutex> lk(frameMutex);
                  frameMap[frame->type()] = frame;
              }
          });

           

          The IMU frame rate is much faster than the video, so it is advisable to use a separate pipeline to obtain IMU data.

          auto                                              dev         = pipe.getDevice();
          auto                                              imuPipeline = std::make_shared<ob::Pipeline>(dev);
          std::mutex                                        imuFrameMutex;
          std::map<OBFrameType, std::shared_ptr<ob::Frame>> imuFrameMap;
          try {
              auto                        accelProfiles = imuPipeline->getStreamProfileList(OB_SENSOR_ACCEL);
              auto                        gyroProfiles  = imuPipeline->getStreamProfileList(OB_SENSOR_GYRO);
              auto                        accelProfile  = accelProfiles->getProfile(OB_PROFILE_DEFAULT);
              auto                        gyroProfile   = gyroProfiles->getProfile(OB_PROFILE_DEFAULT);
              std::shared_ptr<ob::Config> imuConfig     = std::make_shared<ob::Config>();
              imuConfig->enableStream(accelProfile);
              imuConfig->enableStream(gyroProfile);
              imuPipeline->start(imuConfig, [&](std::shared_ptr<ob::FrameSet> frameset) {
                  auto count = frameset->frameCount();
                  for(int i = 0; i < count; i++) {
                      auto                         frame = frameset->getFrame(i);
                      std::unique_lock<std::mutex> lk(imuFrameMutex);
                      imuFrameMap[frame->type()] = frame;
                  }
              });
          }
          catch(...) {
              std::cout << "IMU sensor not found!" << std::endl;
              imuPipeline.reset();
          }

           

          關(guān)閉pipeline

          pipe.stop()

           

          關(guān)閉IMU pipeline

          imuPipeline->stop();

          預(yù)期輸出:

          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>

                操逼在线观看 | 黑丝美女被男人操 | 黄色亚洲视频 | 成人免费视频入口在线播放 | 午夜激情久久 | 白嫩在线77777777 | av中文字幕在线播放 | 免费国产三级片 | 性爱综合网| 免费看黄色一级操逼视屏 |