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

      創(chuàng)建您的第一個(gè)相機(jī)應(yīng)用

      這個(gè)快速入門將幫助你快速使用Orbbec SDK,構(gòu)建你的第一個(gè)相機(jī)應(yīng)用程序需要用到以下函數(shù):

       

       

      queryDeviceList()

      deviceCount()

      getDevice()

      getDeviceInfo()

      firmwareVersion()

      serialNumber()

      connectionType()

      getSensorList()

      getSensor()

       

      先決條件

      連接Orbbec設(shè)備。
      下載并安裝Orbbec SDK。

       

      頭文件

      包含Orbbec SDK的主要頭文件

      ```cpp
      #include <iostream>
      #include "utils.hpp"
      #include "libobsensor/ObSensor.hpp"
      #include "libobsensor/hpp/Error.hpp"
      ```

       

      查找Orbbec設(shè)備

      首先,我們需要檢查您的計(jì)算機(jī)連接了多少個(gè)Orbbec設(shè)備。使用函數(shù)來檢索連接的設(shè)備。

      // Create a Context.
      ob::Context ctx;

      // Query the list of connected devices
      auto devList = ctx.queryDeviceList();
      if (devList->deviceCount() == 0) {
          std::cerr << "Device not found!" << std::endl;
          return -1;
      }

      如果檢測到設(shè)備,您可以繼續(xù)訪問其信息和傳感器。

       

      訪問設(shè)備信息

      獲取設(shè)備列表后,打開第一個(gè)設(shè)備并檢索一些基本信息,比如設(shè)備名稱和固件版本。

      auto dev = devList->getDevice(0);
      auto devInfo = dev->getDeviceInfo();
      std::cout << "Device name: " << devInfo->name() << std::endl;
      std::cout << "Firmware version: " << devInfo->firmwareVersion() << std::endl;

      // By getting the serial number of the device
      auto sn = devInfo->serialNumber();
      std::cout << "Serial number: " << sn << std::endl;

      // By getting the connection type of the device
      auto connectType = devInfo->connectionType();
      std::cout << "ConnectionType: " << connectType << std::endl;

       

      列出傳感器

      接下來,通過獲取傳感器列表并打印每個(gè)傳感器類型。

         // Get the list of supported sensors
          std::cout << "Sensor types: " << std::endl;
          auto sensorList = dev->getSensorList();
          for(uint32_t i = 0; i < sensorList->count(); i++) {
              auto sensor = sensorList->getSensor(i);
              switch(sensor->type()) {
              case OB_SENSOR_COLOR:
                  std::cout << "\tColor sensor" << std::endl;
                  break;
              case OB_SENSOR_DEPTH:
                  std::cout << "\tDepth sensor" << std::endl;
                  break;
              case OB_SENSOR_IR:
                  std::cout << "\tIR sensor" << std::endl;
                  break;
              case OB_SENSOR_IR_LEFT:
                  std::cout << "\tIR Left sensor" << std::endl;
                  break;
              case OB_SENSOR_IR_RIGHT:
                  std::cout << "\tIR Right sensor" << std::endl;
                  break;
              case OB_SENSOR_GYRO:
                  std::cout << "\tGyro sensor" << std::endl;
                  break;
              case OB_SENSOR_ACCEL:
                  std::cout << "\tAccel sensor" << std::endl;
                  break;
              default:
                  break;
              }
          }

       

       

      錯(cuò)誤處理

      在你的應(yīng)用程序中包含錯(cuò)誤處理是很重要的。Orbbec SDK提供了詳細(xì)的異常,可以捕獲以了解在執(zhí)行過程中發(fā)生了什么錯(cuò)誤。

      ```cpp
      catch(ob::Error &e) {
          std::cerr << "Error: " << e.getMessage() << std::endl;
          return -2;
      }
      ```

       

      完整代碼

      #include <iostream>
      #include "utils.hpp"
      #include "libobsensor/ObSensor.hpp"
      #include "libobsensor/hpp/Error.hpp"

      #define ESC 27

      int main(int argc, char **argv) try {
          // Print the sdk version number, the sdk version number is divided into major version number, minor version number and revision number
          std::cout << "SDK version: " << ob::Version::getMajor() << "." << ob::Version::getMinor() << "." << ob::Version::getPatch() << std::endl;
          // Print sdk stage version
          std::cout << "SDK stage version: " << ob::Version::getStageVersion() << std::endl;

          // Create a Context.
          ob::Context ctx;

          // Query the list of connected devices
          auto devList = ctx.queryDeviceList();

          // Get the number of connected devices
          if(devList->deviceCount() == 0) {
              std::cerr << "Device not found!" << std::endl;
              return -1;
          }

          // Create a device, 0 means the index of the first device
          auto dev = devList->getDevice(0);

          // Get device information
          auto devInfo = dev->getDeviceInfo();

          // Get the name of the device
          std::cout << "Device name: " << devInfo->name() << std::endl;

          // Get the pid, vid, uid of the device
          std::cout << "Device pid: " << devInfo->pid() << " vid: " << devInfo->vid() << " uid: " << devInfo->uid() << std::endl;

          // By getting the firmware version number of the device
          auto fwVer = devInfo->firmwareVersion();
          std::cout << "Firmware version: " << fwVer << std::endl;

          // By getting the serial number of the device
          auto sn = devInfo->serialNumber();
          std::cout << "Serial number: " << sn << std::endl;

          // By getting the connection type of the device
          auto connectType = devInfo->connectionType();
          std::cout << "ConnectionType: " << connectType << std::endl;

          // Get the list of supported sensors
          std::cout << "Sensor types: " << std::endl;
          auto sensorList = dev->getSensorList();
          for(uint32_t i = 0; i < sensorList->count(); i++) {
              auto sensor = sensorList->getSensor(i);
              switch(sensor->type()) {
              case OB_SENSOR_COLOR:
                  std::cout << "\tColor sensor" << std::endl;
                  break;
              case OB_SENSOR_DEPTH:
                  std::cout << "\tDepth sensor" << std::endl;
                  break;
              case OB_SENSOR_IR:
                  std::cout << "\tIR sensor" << std::endl;
                  break;
              case OB_SENSOR_IR_LEFT:
                  std::cout << "\tIR Left sensor" << std::endl;
                  break;
              case OB_SENSOR_IR_RIGHT:
                  std::cout << "\tIR Right sensor" << std::endl;
                  break;
              case OB_SENSOR_GYRO:
                  std::cout << "\tGyro sensor" << std::endl;
                  break;
              case OB_SENSOR_ACCEL:
                  std::cout << "\tAccel sensor" << std::endl;
                  break;
              default:
                  break;
              }
          }

          std::cout << "Press ESC to exit! " << std::endl;

          while(true) {

              // Get the value of the pressed key, if it is the esc key, exit the program
              int key = getch();
              if(key == ESC)
                  break;
          }

          return 0;
      }
      catch(ob::Error &e) {
          std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
          exit(EXIT_FAILURE);
      }

       

      下一步

      -了解如何使用Orbbec SDK配置和使用單個(gè)傳感器。

      -探索Orbbec SDK文檔中提供的高級(jí)功能和設(shè)置。

      -開始將Orbbec設(shè)備功能集成到您的更大型項(xiàng)目和應(yīng)用程序中。

       

       

       

       

       

       

       

       

       

       

       

       


      • <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>
        色偷偷大香蕉 | 男人的天堂av电影 | 91无码电影 | 人人干国产 | 天美视频网爱爱 |