HoloLens2的彩色和深度数据流通过主机获取

关于HoloLens 2设备提供了研究者模式,便于开发者访问传感器的原始数据,进行科研开发,本博客根据github项目在线获得图像数据,但是目前达不到实时传输的效果,延迟很高,期望以后的深入学习可以解决。

一、实验准备

1、实验条件

  • Windows 10 SDK 10.0.18362.0
  • HoloLens 2 设备
  • Unity 2020.3.31f1c1配置好MRTK混合现实开发包
  • Visual Studio 2019
  • Python3.9(opencv-python)

2、下载Github工程

HoloLens2-Unity-ResearchModeStreamer

3、打开HoloLens 2研究者模式

二、配置过程

1、配置VS环境

设置项目属性为release 和ARM64

Release+ARM64

在这里插入图片描述

2、注释工程项目中Eigen库

在这里插入图片描述

2、生成解决方案

在这里插入图片描述
在这里插入图片描述

3、更换Lib库

lib库里放了Opencv4.X的库,根据需要把附加依赖项直接换成opencv_world341.lib,这个文件包括项目所需所有lib
在这里插入图片描述

三、配置Unity项目

1、新建Unity的3D项目

在这里插入图片描述

2、将项目切换到Universal windows patform平台

在这里插入图片描述

3、新建路径

在这里插入图片描述

4、将前面编译好的文件拷贝到新建的Plugins文件夹下

E → HoloLens2-Unity-ResearchModeStreamer-master → HL2RmStreamUnityPlugin → ARM64 → Release → HL2RmStreamUnityPlugin

5、新建一个StreamerHL2.cs

复制下面代码到脚本里面
在这里插入图片描述

在这里插入代码片

6、将脚本随便挂在在一个对象上,我挂载的是主相机

在这里插入图片描述

7、设置Unity 项目的兼容性

勾选
InternetClient, InternetClientServer, PrivateNetworkClientServer, WebCam, SpatialPerception 5个位置
在这里插入图片描述

8、编译unity工程

在这里插入图片描述

9、配置package文件中的兼容性

在这里插入图片描述

10、将如下字段添加到 Package 中

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

在这里插入图片描述

11、在Package这一行中,找到"IgnorableNamespaces"的属性,添加“rescap”字段

在这里插入图片描述

12、在 Capabilityes添加如下字段

<rescap:Capability Name="perceptionSensorsExperimental" />

在这里插入图片描述
Package.appxmanifest文件全揽,RMSTest可更换文件名

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" xmlns:mobile="http://schemas.microsoft.com/appx/manifest/mobile/windows10" IgnorableNamespaces="uap uap2 uap3 uap4 mp mobile iot rescap" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10">
  <Identity Name="Template3D" Publisher="CN=DefaultCompany" Version="1.0.0.0" />
  <mp:PhoneIdentity PhoneProductId="edd907fa-2c4f-49b2-89a0-9fa371043c33" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>RMSTest</DisplayName>
    <PublisherDisplayName>DefaultCompany</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.19041.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Template3D.App">
      <uap:VisualElements DisplayName="RMSTest" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Template_3D" BackgroundColor="transparent">
        <uap:DefaultTile ShortName="RMSTest" Wide310x150Logo="Assets\Wide310x150Logo.png" />
        <uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#FFFFFF" />
        <uap:InitialRotationPreference>
          <uap:Rotation Preference="landscape" />
          <uap:Rotation Preference="landscapeFlipped" />
          <uap:Rotation Preference="portrait" />
          <uap:Rotation Preference="portraitFlipped" />
        </uap:InitialRotationPreference>
      </uap:VisualElements>
    </Application>
  </Applications>
  <Capabilities>
	<rescap:Capability Name="perceptionSensorsExperimental" />
    <Capability Name="internetClient" />
    <Capability Name="internetClientServer" />
    <Capability Name="privateNetworkClientServer" />
    <uap2:Capability Name="spatialPerception" />
    <DeviceCapability Name="webcam" />
  </Capabilities>
</Package>

四、VS编译与部署

1、打开下载好的github工程中的hololens2_simpleclient.py文件

E: → HoloLens2-Unity-ResearchModeStreamer-master → py

2、修改局域网IP

在这里插入图片描述

五、连接运行

1、将PC与HoloLens 2连接至同一局域网

2、vs部署HoloLens 2项目

D→MixedRealityLearning→RMSTest→build

3、选择项目配置

在项目属性页Release和ARM64下,选择调试,计算机名为HoloLens的IP
在这里插入图片描述

4、部署到HoloLens 2上

打开APP

5、运行hololens2_simpleclient.py文件

在这里插入图片描述

6、查看结果

(1)HoloLens 2彩色数据流
在这里插入图片描述
(2)HoloLens 2深度数据流
在这里插入图片描述

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

极客范儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值