Table of Contents

Easyar unity 頭顯擴展包

本文檔介紹了 Easyar unity 頭顯擴展包的概念、能力邊界以及創建頭顯擴展包所需的背景知識。

開始之前

EasyAR Unity 頭顯擴充套件是什麼

EasyAR Unity 頭顯擴充套件是一個 Unity package,包含一系列程式碼和範例,幫助您在您的頭顯裝置上使用 EasyAR Sense 的功能。透過這個擴充套件,您可以將 EasyAR Sense 的大部分功能(如影像追蹤、稠密空間地圖等)整合到您的裝置上,從而利用 EasyAR 提供的強大 AR 功能。

使用 EasyAR Unity 頭顯擴充套件是 EasyAR 頭顯支援的其中一種方式。下圖展示了 EasyAR 在 Unity 中的整體架構,以及頭顯擴充套件在其中的位置。

block
  columns 4
  block:groupApp:4
    block:groupAppWrapper
      space
      App1["EasyAR + Device A<br>App"]
      space
      App2["EasyAR<br>App"]
      space
      App3["EasyAR + Device B<br>App"]
    end
  end
  
  block:groupSensePluginExtension
    columns 1
    SensePluginExtension["EasyAR Sense Unity Plugin<br>Extension for Device A"]
    space
  end
  block:groupSensePlugin
    columns 1
    SensePlugin["EasyAR Sense Unity Plugin"]
    space
  end
  block:groupXRI
    columns 1
    XRI["XR Interaction Toolkit"]
    space
  end
  block:groupARF
    columns 1
    ARF["AR Foundation"]
    space
  end
  
  block:groupDeviceAUnity
    columns 1
    DeviceAUnity["Device A<br>Unity SDK"]
    space
  end
  block:groupSense
    columns 1
    Sense["EasyAR Sense"]
    block:groupSenseWrapper
      MDeviceB["Device B<br>CameraDevice"]
      Others["..."]
    end
  end
  block:groupXRSubsystem:2
    columns 1
    XRSubsystem["XR Subsystems"]
    XRSDK["Unity XR SDK"]
  end

  block:groupSystem:4
    columns 1
    System["Native Library"]
    block:groupSystemWrapper
      space
      DeviceA["Device A<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Library&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
      space
      space
      DeviceB["Device B<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Library&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]
      space
    end
  end
  
  SensePluginExtension --> App1
  SensePlugin --> App1
  SensePlugin --> App2
  SensePlugin --> App3
  ARF --> App3
  XRI --> App1
  XRI --> App3
  groupSense --> SensePlugin
  groupDeviceAUnity --> SensePluginExtension
  SensePlugin --> SensePluginExtension
  DeviceA --> groupDeviceAUnity
  DeviceA --> XRSDK
  XRSubsystem --> ARF
  XRSubsystem --> XRI
  DeviceB --> MDeviceB
  DeviceB --> XRSDK
  
  style groupApp fill:none,stroke:none,stroke-width:0px
  style groupAppWrapper fill:none,stroke:none,stroke-width:0px
  style groupSensePlugin fill:none,stroke:none,stroke-width:0px
  style groupARF fill:none,stroke:none,stroke-width:0px
  style groupXRI fill:none,stroke:none,stroke-width:0px
  style DeviceAUnity fill:none,stroke:none,stroke-width:0px
  style Sense fill:none,stroke:none,stroke-width:0px,color
  style groupSenseWrapper fill:none,stroke:none,stroke-width:0px
  style XRSubsystem fill:none,stroke:none,stroke-width:0px
  style System fill:none,stroke:none,stroke-width:0px
  style groupSystemWrapper fill:none,stroke:none,stroke-width:0px
  style groupSensePluginExtension fill:none,stroke:none,stroke-width:0px  

  classDef EasyAR fill:#6e6ce6,stroke:#333,color:#fff
  class SensePluginExtension EasyAR

圖中列出了兩種典型的頭顯支援方式:透過 Unity 頭顯擴充套件對接裝置 SDK(Device A),以及在 EasyAR Sense 函式庫中直接對接裝置 SDK(Device B)。本文件主要介紹前者。

我可以建立自己的頭顯擴充套件包嗎?

目前,AR/VR/MR/XR 產業內尚未形成非常統一的介面方案。雖然 OpenXR 是個很好的候選標準,但規範演化和產業實作還需要時間。因此通常來說,市售裝置直接執行 EasyAR 並不容易,極可能出現資料介面缺失的情況。隨著產業的發展,一些新興裝置也可能具備良好的介面支援。例如在 2024 年,蘋果公司開放了 Vision Pro 的相關介面,這些介面已足夠用來支撐 EasyAR 執行,不過使用起來仍需具備一些專業知識。

如果您無法做出判斷,建議聯絡硬體製造商或 EasyAR 商務部門以取得相應的裝置支援。

如果您是硬體製造商,並希望在自己的裝置上支援 EasyAR 的功能,您可以參考接下來的文件內容來建立一個頭顯擴充套件包,從而使 EasyAR 的大部分功能能在您的裝置上執行。本文檔在提供資料和介面規範的同時,並不限定所有實作細節,任何實作方式或介面定義都可以討論,歡迎透過商務管道聯絡溝通。

本文檔涵蓋的硬體自身需要具備運動追蹤或 SLAM 能力。EasyAR 的功能需運行在良好的裝置追蹤能力之上,通常不建議依賴 EasyAR 的功能來最佳化裝置的追蹤,這會產生循環依賴,進而在理論上放大誤差並導致整體系統趨於不穩定。如果裝置本身不具備運動追蹤能力,則支援方案不在本文檔涵蓋範圍之內,如有需要可透過商務管道進行溝通。

頭顯擴展包的能力邊界

頭顯擴展包的目標是讓 EasyAR Sense 的大部分功能可以在您的設備上運行。為了實現這個目標,您需要了解頭顯擴展包的能力邊界。

頭顯擴展包所包含的內容

您將實現的擴展是:

  • 使用 自定義相機功能,從您的設備 API 抓取數據並發送進 EasyAR Sense 的一系列代碼。
  • 在 Unity 中,頭顯擴展會使用 外部幀數據源EasyAR Sense Unity Plugin 定義的一套 EasyAR Sense 數據流來簡化自定義相機開發。
  • 在 Unity 中,頭顯擴展是一個 Unity package,包含運行時腳本,編輯器腳本和擴展的 sample,您或 EasyAR 可以將它分發給下游用戶。
提示

如果您不希望將對接細節暴露在外部系統中,可以聯繫 EasyAR 進行溝通。在 EasyAR Sense 內部使用 C 接口直接對接是可行且有先例的。

您在實現擴展的時候,可能會:

  • 修改您 SDK 的接口設計和內部實現
  • 與您的團隊一起討論確認數據獲取和使用方案。
  • 花**[大量]**時間進行數據正確性驗證而不是寫代碼。

完成擴展後,您將會看到:

  • 大多數 EasyAR Sense 功能在您的設備上可以使用,這些功能會利用您設備的運動跟蹤能力。
  • EasyAR Sense 內支援的 EasyAR 雲服務在您的設備上可以使用。
  • 只能使用 EasyAR XR license。個人版、專業版以及經典版的 license 無法在您的設備上使用。
  • 使用自定義相機時的所有 EasyAR license 的限制以相同方式適用於您的設備。

What the headset extension package does not include

This extension cannot be used without EasyAR Sense:

  • This headset extension will not run standalone. As a dependency, EasyAR Sense is required. In Unity, the EasyAR Sense Unity Plugin must be used.
  • It does not directly call EasyAR cloud service APIs (such as the EasyAR Mega localization service); these calls are completed within EasyAR Sense.
  • In Unity, it does not directly call API methods for AR functionalities (such as Image Tracking); these are handled within the EasyAR Sense Unity Plugin.
  • In Unity, it does not modify the transform of scene GameObjects or tracked targets; these modifications are done within the EasyAR Sense Unity Plugin.

This extension cannot be used without your device SDK:

  • In Unity, the headset extension or the EasyAR Sense Unity Plugin will not modify the transform of the scene camera; this must be done within your device SDK or its dependency chain.

Certain EasyAR functionalities remain unavailable through the headset extension:

  • Surface Tracking functionality will be unusable.
  • EasyAR's own Motion Tracking will be unusable.
  • Plane Detection (part of EasyAR Motion Tracking) will be unusable.

如何在我的裝置上使用 Mega?

在裝置上運行 Mega 是很多使用者關心的問題。在 Unity 中,Mega 服務是運行在 EasyAR Sense 諸多基礎功能之上的一個功能模組,所以只要您的裝置完整支援 EasyAR Sense,那麼 Mega 也會被支援。

一般來說,不建議在一開始就直接在裝置上運行 Mega 範例來驗證裝置對 Mega 的支援情況,因為 Mega 會綜合利用所有輸入數據,並且其對這些數據的誤差容忍度較大。直接運行 Mega 範例很可能會因為數據介面不匹配或數據品質不佳而導致無法獲得合理的運行效果,並且無法判斷問題出在哪裡,這會為日後的調試帶來很大困難。

重要事項

Mega 服務對裝置的動態追蹤能力有一定要求。如果裝置的動態追蹤能力不佳,那麼 Mega 的表現也會受到影響。在大範圍 AR 場景中,還需要特別關注室內外的表現差異。

重要事項

Mega 一般服務於大空間場景,因此需要格外關注遠距離物體以及轉動頭部或移動時物體的 顯示 效果。如果裝置的顯示系統誤差較大,那麼即使 Mega 本身運行正常,使用者也會感覺虛擬物體無法正確貼合現實物體。

需要的背景知識和團隊配置

建立頭戴式顯示器擴充套件包不是一個簡單的任務,需要您和您的團隊在多個領域進行深入的工作。通常來說,要完成頭戴式顯示器擴充,需要 Unity 開發參與的同時投入 Unity 開發之外的團隊人員。由於缺少標準,只在 3D 引擎上面修改通常無法完成頭戴式顯示器擴充,建議從第一天起就讓系統工程師和 SDK 工程師等底層開發工程師參與進來。

打造 AR/VR 設備需要一些領域知識,相似地,在設備上運行和驗證 EasyAR Sense 將需要您或您的團隊是如下領域的專家:

  • 您設備的物理結構和渲染系統
  • 相機系統幾何
  • SDK 開發
  • 常規 Android debug 技能,比如 adb(中國大陸國際

如果您工作在 Unity 上,您還需要知道這些:

另外,有一點在這些領域的知識將幫助您更好地理解系統,尤其是如何發送正確的數據到 EasyAR:

  • Android 開發(中國大陸國際
  • 幾何視覺,尤其是影像匹配和 3D 重建

後續步驟

在接下來的文章中,您將了解建立頭顯擴充套件的完整流程:

相關主題