<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++ 熱插拔示例代碼-Hot Plugin

          # 熱拔插示例-HotPlugin

           

          功能描述:本示例主要演示設(shè)備拔插回調(diào)的設(shè)置,以及拔插之后處理獲取到的流,并通過ESC_KEY鍵退出程序

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

           

          首先需要?jiǎng)?chuàng)建一個(gè)Context,用于獲取設(shè)備信息列表和創(chuàng)建設(shè)備

          ob::Context ctx;

           

          注冊(cè)設(shè)備回調(diào),分別在設(shè)備拔插的時(shí)候執(zhí)行相關(guān)函數(shù)

          ctx.setDeviceChangedCallback( []( std::shared_ptr< ob::DeviceList > removedList, std::shared_ptr< ob::DeviceList > addedList ) {
                  DeviceDisconnectCallback( removedList );
                  DeviceConnectCallback( addedList );
              } )

           

          開流

          void startStream(std::shared_ptr<PipelineHolder> holder) {
          std::shared_ptr<FramePrintInfo> printInfo(new FramePrintInfo{});
          std::string                     deviceSN = std::string(holder->deviceInfo->serialNumber());
          ob::FrameSetCallback            callback = [deviceSN, printInfo](std::shared_ptr<ob::FrameSet> frameSet) {
              // Get the depth data frame
              auto depthFrame = frameSet->depthFrame();
              if(depthFrame) {
                  printInfo->depthCount++;
                  if(printInfo->depthCount == 15) {
                      std::cout << "=====Depth Frame Info====== SN: " << std::string(deviceSN) << ", " << depthFrame << std::endl;
                      printInfo->depthCount = 0;
                  }
              }

              // Get the ir data frame
              auto irFrame = frameSet->irFrame();
              if(irFrame) {
                  printInfo->irCount++;
                  if(printInfo->irCount == 15) {
                      std::cout << "=====IR Frame Info====== SN: " << std::string(deviceSN) << ", " << std::dynamic_pointer_cast<ob::VideoFrame>(irFrame)
                                  << std::endl;
                      printInfo->irCount = 0;
                  }
              }

              // Get the ir left data frame
              auto irLeftFrame = frameSet->getFrame(OB_FRAME_IR_LEFT);
              if(irLeftFrame) {
                  printInfo->irLeftCount++;
                  if(printInfo->irLeftCount == 15) {
                      std::cout << "=====IR Left Frame Info====== SN: " << std::string(deviceSN) << ", " << std::dynamic_pointer_cast<ob::VideoFrame>(irLeftFrame)
                                  << std::endl;
                      printInfo->irLeftCount = 0;
                  }
              }

              // Get the ir right data frame
              auto irRightFrame = frameSet->getFrame(OB_FRAME_IR_RIGHT);
              if(irRightFrame) {
                  printInfo->irRightCount++;
                  if(printInfo->irRightCount == 15) {
                      std::cout << "=====IR Right Frame Info====== SN: " << std::string(deviceSN) << ", " << std::dynamic_pointer_cast<ob::VideoFrame>(irRightFrame)
                                  << std::endl;
                      printInfo->irRightCount = 0;
                  }
              }

              // Get the color data frame
              auto colorFrame = frameSet->colorFrame();
              if(colorFrame) {
                  printInfo->colorCount++;
                  if(printInfo->colorCount == 15) {
                      std::cout << "=====Color Frame Info====== SN: " << std::string(deviceSN) << ", " << std::dynamic_pointer_cast<ob::VideoFrame>(colorFrame)
                                  << std::endl;
                      printInfo->colorCount = 0;
                  }
              }
          };

          // Start video stream according to the stream profile of the configuration file.If there is no configuration file, the first stream profile will be used.
          try {
              std::cout << "startStream " << holder->deviceInfo << std::endl;
              holder->pipeline->start(nullptr, callback);
              holder->isStarted = true;
          }
          catch(...) {
              std::cout << "Pipeline start failed!" << std::endl;
              holder->isStarted = false;
          }
          }

           

           

           

           

          停流

          void stopStream(std::shared_ptr<PipelineHolder> holder) {
              if(!holder->isStarted) {
                  return;
              }

              try {
                  std::cout << "stopStream " << holder->deviceInfo << std::endl;
                  holder->isStarted = false;
                  holder->pipeline->stop();
              }
              catch(ob::Error &e) {
                  std::cerr << "stopStream failed., function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage()
                            << "\ntype:" << e.getExceptionType() << std::endl;
              }
          }

           

          程序正常退出之后資源將會(huì)自動(dòng)釋放


          <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>

                日剧大尺度床戏做爰 | japan国产精选videos | 免费在线观看黄色 | 色妞色视频一区二区三区四区 | 小雪的粉嫩粉嫩一开一合视频 | 黄色视频网站免费观看 | 挺进太深了h御宅屋 | 爱干逼 | 波多野结衣久久电影 | 五月天亚洲综合 |