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

      K4A 訪問FemtoMega網(wǎng)絡(luò)模式

      K4A訪問FemtoMega網(wǎng)絡(luò)模式

      快速入門:網(wǎng)絡(luò)訪問設(shè)備應(yīng)用程序

      想要開始使用網(wǎng)絡(luò)訪問Femto Mega?本文將幫助你啟動(dòng)并成功運(yùn)行該設(shè)備!

       

      本文將介紹以下函數(shù):

           k4a_device_get_installed_count()

           k4a_device_open()

           k4a_device_get_serialnum()

           k4a_device_start_cameras()

           k4a_device_stop_cameras()

           k4a_device_close()

      先決條件

      1.      《設(shè)置 Femto Mega》并將FemtoMega將固件版本升級(jí)最新1.2.7以上版本;

      2.      并安裝 SDK《Orbbec SDK 和 Orbbec SDK K4A Wrapper》

      3.      確保Femto Mega和Host主機(jī)在同一個(gè)局域網(wǎng)內(nèi)(做設(shè)備發(fā)現(xiàn)用)

      頭文件

      只需要一個(gè)頭文件,即 k4a.h。 請確保所選的編譯器設(shè)置為使用 SDK 的庫并包含文件夾。 此外,需要鏈接 k4a.lib 和 k4a.dll 文件。

      #include <k4a/k4a.h>

      查找 Femto Mega 設(shè)備

      可將多個(gè) Femto Mega 設(shè)備連接到計(jì)算機(jī)。

      需要默認(rèn)打開網(wǎng)絡(luò)發(fā)現(xiàn)功能(僅局域網(wǎng)有效)

      修改OrbbecSDKConfig_v1.0.xml中將EnumerateNetDevice值由false改為true

      1.png

       

       首先,我們將使用 k4a_device_get_installed_count() 函數(shù)確定有多少個(gè)設(shè)備,或者是否連接了任何設(shè)備。 此函數(shù)應(yīng)可立即運(yùn)行,而無需經(jīng)過附加的設(shè)置。

      uint32_t count = k4a_device_get_installed_count();

      確定某個(gè)設(shè)備已連接到計(jì)算機(jī)后,可以使用 k4a_device_open() 將其打開。 可以提供想要打開的設(shè)備的索引,或者只對第一個(gè)設(shè)備使用 K4A_DEVICE_DEFAULT

      // Open the first plugged in Kinect device
      k4a_device_t device = NULL;
      k4a_device_open(K4A_DEVICE_DEFAULT, &device);

      與 Azure Kinect 庫中的大多數(shù)內(nèi)容一樣,當(dāng)你打開某種內(nèi)容時(shí),也應(yīng)該在用完時(shí)將其關(guān)閉! 關(guān)閉時(shí),請記得調(diào)用 k4a_device_close()

       

      k4a_device_close(device);

      打開設(shè)備后,可以進(jìn)行測試以確保它正常工作。 讓我們讀取設(shè)備的序列號(hào)!

       

      // Get the size of the serial number
      size_t serial_size = 0;
      k4a_device_get_serialnum(device, NULL, &serial_size);

      // Allocate memory for the serial, then acquire it
      char *serial = (char*)(malloc(serial_size));
      k4a_device_get_serialnum(device, serial, &serial_size);
      printf("Opened device: %s\n", serial);
      free(serial);

      啟動(dòng)相機(jī)

      打開設(shè)備后,需要使用 k4a_device_configuration_t 對象配置相機(jī)。 相機(jī)配置包含大量不同的選項(xiàng)。 請選擇最適合自己方案的設(shè)置。

       

      // Configure a stream of 3840x2160 BRGA color data at 15 frames per second
      k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
      config.camera_fps       = K4A_FRAMES_PER_SECOND_15;
      config.color_format     = K4A_IMAGE_FORMAT_COLOR_BGRA32;
      config.color_resolution = K4A_COLOR_RESOLUTION_2160P;

      // Start the camera with the given configuration
      k4a_device_start_cameras(device, &config);

      // ...Camera capture and application specific code would go here...

      // Shut down the camera when finished with application logic
      k4a_device_stop_cameras(device);

      錯(cuò)誤處理

      為簡潔起見,我們不會(huì)在某些例子中顯示錯(cuò)誤處理。 但是,錯(cuò)誤處理始終很重要! 許多函數(shù)返回常規(guī)的成功/失敗類型 k4a_result_t,或者包含詳細(xì)信息的更具體的變量,比如 k4a_wait_result_t。 請查看每個(gè)函數(shù)的文檔或 IntelliSense,以了解該函數(shù)預(yù)期顯示的錯(cuò)誤消息!

      可以使用 K4A_SUCCEEDED 和 K4A_FAILED 宏檢查函數(shù)的結(jié)果。 因此,除了打開 Femto Mega 設(shè)備以外,我們還可以按如下所示保護(hù)函數(shù)調(diào)用:

       

      // Open the first plugged in Kinect device
      k4a_device_t device = NULL;
      if ( K4A_FAILED( k4a_device_open(K4A_DEVICE_DEFAULT, &device) ) )
      {
          printf("Failed to open k4a device!\n");
          return;
      }

      完整源代碼

       

      #pragma comment(lib, "k4a.lib")
      #include <k4a/k4a.h>

      #include <stdio.h>
      #include <stdlib.h>

      int main()
      {
          uint32_t count = k4a_device_get_installed_count();
          if (count == 0)
          {
              printf("No k4a devices attached!\n");
              return 1;
          }

          // Open the first plugged in Kinect device
          k4a_device_t device = NULL;
          if (K4A_FAILED(k4a_device_open(K4A_DEVICE_DEFAULT, &device)))
          {
              printf("Failed to open k4a device!\n");
              return 1;
          }

          // Get the size of the serial number
          size_t serial_size = 0;
          k4a_device_get_serialnum(device, NULL, &serial_size);

          // Allocate memory for the serial, then acquire it
          char *serial = (char*)(malloc(serial_size));
          k4a_device_get_serialnum(device, serial, &serial_size);
          printf("Opened device: %s\n", serial);
          free(serial);

          // Configure a stream of 3840x2160 BRGA color data at 15 frames per second
          k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
          config.camera_fps       = K4A_FRAMES_PER_SECOND_15;
          config.color_format     = K4A_IMAGE_FORMAT_COLOR_BGRA32;
          config.color_resolution = K4A_COLOR_RESOLUTION_2160P;

          // Start the camera with the given configuration
          if (K4A_FAILED(k4a_device_start_cameras(device, &config)))
          {
              printf("Failed to start cameras!\n");
              k4a_device_close(device);
              return 1;
          }

          // Camera capture and application specific code would go here

          // Shut down the camera when finished with application logic
          k4a_device_stop_cameras(device);
          k4a_device_close(device);

          return 0;
      }


      后續(xù)步驟

      了解如何使用傳感器 SDK 查找并打開 Femto Mega 設(shè)備。

      《查找并打開設(shè)備》

       


      • <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>
        久久综合狠狠综合五十路 | 下面喷水视频 | 一级做a免费观看 | 大鸡巴操逼视频 | 色综合色狠狠天天综合色 |