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

          查找并打開設備

          本文內(nèi)容

          ● 發(fā)現(xiàn)已連接設備數(shù)

          ● 打開設備

          ● 識別特定設備

          ● 打開默認設備

          ● 后續(xù)步驟


          本文介紹如何查找然后打開 Femto Mega。 本文將解釋如何處理有多個設備連接到計算機的情況。

          你還可以參考 SDK 枚舉示例,其中演示了如何使用本文所述的函數(shù)。


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

          ● k4a_device_get_installed_count()

          ● k4a_device_open()

          ● k4a_device_get_serialnum()

          ● k4a_device_close()



          發(fā)現(xiàn)已連接的設備數(shù)

          首先使用 k4a_device_get_installed_count() 獲取當前已連接的 Femto Mega 設備數(shù)。

           


          打開設備

          若要獲取設備的相關信息或從中讀取數(shù)據(jù),首先需要使用 k4a_device_open() 打開該設備的句柄。

          k4a_device_t device = NULL;
          for (uint8_t deviceIndex = 0; deviceIndex < device_count; deviceIndex++)
          {
             if (K4A_RESULT_SUCCEEDED != k4a_device_open(deviceIndex, &device))
             {
                 printf("%d: Failed to open device\n", deviceIndex);
                 continue;
             }
             ...
             k4a_device_close(device);
          }


          k4a_device_open() 的 index 參數(shù)指示當連接了多個設備時要打開哪個設備。 如果你預期只會連接一個設備,可以傳遞 K4A_DEVICE_DEFAULT 的參數(shù)或 0 來指示第一臺設備。


          用完句柄后,每當打開設備時,都需要調(diào)用 k4a_device_close()。 在關閉句柄之前,無法打開同一設備的其他句柄。



          識別特定的設備

          在附加或分離設備之前,設備按索引枚舉的順序不會更改。 若要識別物理設備,應使用設備的序列號。

          若要讀取設備中的序列號,請在打開句柄后使用 k4a_device_get_serialnum() 函數(shù)。此示例演示如何分配適量內(nèi)存來存儲序列號。

          char *serial_number = NULL;
          size_t serial_number_length = 0;
          if (K4A_BUFFER_RESULT_TOO_SMALL != k4a_device_get_serialnum(device, NULL, &serial_number_length))
          {
             printf("%d: Failed to get serial number length\n", deviceIndex);
             k4a_device_close(device);
             device = NULL;
             continue;
          }
          serial_number = malloc(serial_number_length);
          if (serial_number == NULL)
          {
             printf("%d: Failed to allocate memory for serial number (%zu bytes)\n", deviceIndex, serial_number_length);
             k4a_device_close(device);
             device = NULL;
             continue;
          }
          if (K4A_BUFFER_RESULT_SUCCEEDED != k4a_device_get_serialnum(device, serial_number, &serial_number_length))
          {
             printf("%d: Failed to get serial number\n", deviceIndex);
             free(serial_number);
             serial_number = NULL;
             k4a_device_close(device);
             device = NULL;
             continue;
          }
          printf("%d: Device \"%s\"\n", deviceIndex, serial_number);



          打開默認設備

          在大多數(shù)應用程序中,只會將單個Femto Mega 附加到同一臺計算機。 如果預期只需連接單個設備,可以結合 K4A_DEVICE_DEFAULT 的 index 調(diào)用 k4a_device_open() 打開第一臺設備。

          k4a_device_t device = NULL;
          uint32_t device_count = k4a_device_get_installed_count();
          if (device_count != 1)
          {
             printf("Unexpected number of devices found (%d)\n", device_count);
             goto Exit;
          }
          if (K4A_RESULT_SUCCEEDED != k4a_device_open(K4A_DEVICE_DEFAULT, &device))
          {
             printf("Failed to open device\n");
             goto Exit;
          }



          后續(xù)步驟

          獲取圖像數(shù)據(jù)

          <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们嫩草伦理 | 吃奶呻吟打开双腿做 | 日本一级片在线观看 | 一级特黄6O分钟免费 | 女同性恋黄色小说 | 一级片视频免费观看 |