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

          如何處理運行錯誤

          概述

          Orbbec SDK C++ API 使用 異常機制 實現(xiàn)接口調(diào)用狀態(tài)反饋,當(dāng)用戶應(yīng)用代碼調(diào)用 API 執(zhí)行過程中出現(xiàn)問題,會向外拋出 ob::Error 類型異常。

          使用說明

          ob::Error 是 Orbbec SDK 自定義的一個異常類,其提供了 4 個接口可以幫助用戶在發(fā)生異常時判斷異常的原因:

          // libobsnesor/hpp/Error.hpp

          /**
          * @brief Get the detailed error logs of SDK internal exceptions.
          * @return A C-style string containing the error message.
          */
          const char *getMessage() const noexcept;

          /**
          * @brief Get the exception type of the error, which can be used to determine which module is abnormal.
          * @return The OBExceptionType enum value.
          */
          OBExceptionType getExceptionType() const noexcept;

          /**
          * @brief Get the name of the error function.
          * @return A C-style string containing the name of the error function.
          */
          const char *getName() const noexcept;

          /**
          * @brief Get the parameter passed to the error interface.
          * @return A C-style string containing the error interface parameter.
          */
          const char *getArgs() const noexcept;

          使用方法如下:

          1. 推薦用戶應(yīng)用代碼在調(diào)用 Orbbec SDK C++ API 時,通過 try-catch 機制捕獲并處理異常:

          try{
            pipe.start(config);
          }catch(ob::Error &e) {
            std::cerr << "Failed to start the pipeline!" << " Exception type:" << e.getExceptionType() << ", name:" << e.getName() << ", message:" << e.getMessage() << std::endl;
          }

          2. 如果函數(shù)內(nèi)包含多個 Orbbec SDK C++ API 調(diào)用,可以在函數(shù)體外部直接捕獲所有異常:

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

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

          異常類型 

          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>

                少妇高潮大叫 | 欧美黑人╳╳ⅹ╳高潮猛交看 | 91久久综合亚洲鲁鲁五月天 | 国产欧美精品va在线观看 | 91黄片视频 | 99自拍视频导航在线播放 | 伊人久久大香线蕉一区二区三区 | 中文字幕在线观看五区 | A日本免费 | 国产videosfree性另类 |