【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录

未完成,已搁置....

==20190718

首先贴出官方解决方案

https://docs.microsoft.com/zh-cn/windows/mixed-reality/spectator-view#spectatorview-preview

国内网友的中文版

https://blog.csdn.net/yuanlaijike/article/details/84288068#Preview_25

 

其中相关编译DLL部分的步骤

https://github.com/Microsoft/MixedRealityToolkit/blob/master/SpectatorViewPlugin/README.md

下面是关于这个编译DLL步骤的中文版

 

Overview

  • The SpectatorViewPlugin solution generates a dll needed for the SpectatorView experience in the MixedRealityToolkit-Unity repo: https://github.com/Microsoft/MixedRealityToolkit-Unity/tree/htk_development/Assets/HoloToolkit-Preview/SpectatorView.

SpectatorViewPlugin这个解决方案,可以生成MixedRealityToolkit-Unity的第三视角中,所需的DLL。解决方案地址如下

  • SpectatorViewPlugin.dll utilizes OpenCV libraries for detecting ArUco markers.

SpectatorViewPlugin.dll利用OpenCV的库检测ArUco标记(AR标记)

  • An example for how to call into this dll exists in the following unity script:https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/htk_development/Assets/HoloToolkit-Preview/SpectatorView/Scripts/SpatialSync/MarkerDetector.cs

在下方的Unity脚本中展示了如何调用这个DLL

  • Logic within SpectatorViewPlugin.dll will only be executed on the HoloLens. It is not used on the mobile device, so you will only need to build x86 Release binaries. This can all be done on a PC in visual studio.

SpectatorViewPlugin.dll的内部逻辑只会在hololens上执行,无法在移动设备上使用,因此你只需要发布x86 Release的二进制文件,这些步骤可在PC端的Visual Studio中完成。

  • After compiling this project, you will need to manually copy dlls from the compile output directory (${MixedRealityToolkit_RepoPath}\SpectatorViewPlugin\SpectatorViewPlugin\Release\SpectatorViewPlugin) to a Plugin folder in your unity assets ($(MixedRealityToolkit-Unity_RepoPath}\Assets\Plugins\WSA\x86).

编译完成这个项目后,你需要手动将DLL文件从output文件夹(第一个路径)拷贝到,你unityAsset目录下Plugin文件夹(Assets\Plugins\WSA\x86)下

For more information on unity plugin directories, see https://docs.unity3d.com/Manual/SpecialFolders.html

对于UnityPlugin文件夹的更多信息,可以参照如下网址

How to Build the SpectatorView Plugin for MRTK

如何为MRTK编译SpectatorView Plugin

Install Vcpkg

  • Open a Command Prompt in administrator mode
  • Navigate to a folder in which you would like to store your repositories (ex: c:\git)
  • git clone https://github.com/Microsoft/vcpkg
  • cd vcpkg
  • git checkout 05b31030cee412118a9710daf5b4652a684b7f50

安装Vcpkg

1.以管理员身份打开命令模式

2.导航到用于保存项目的目录,(例如c:\git

3.git下载https://github.com/Microsoft/vcpkg

4.cd vcpkg

5.git checkout 05b31030cee412118a9710daf5b4652a684b7f50

NOTE: The above commit was the last tested commit by a contributor to this repo. If the below setup steps fail with this commit, it is likely worth checking if the failure is a known issue for the vcpkg repo. It is also worth attempting checking out the master branch and reattempting the setup steps.

注释:上述的提交版本是笔者提交的最终测试版。如果使用这个版本执行下面的安装步骤失败,那就有必要检查一下是否是VCPKG已知的问题,???也可以尝试检查下master branch并且按照安装步骤重试一次。

  • .\bootstrap-vcpkg.bat
  • .\vcpkg integrate install

Install OpenCV Contrib for UWP

为UWP安装OpenCV

  • .\vcpkg install opencv[contrib]:x86-uwp --recurse

NOTE: Copy the above line exactly (the []s do not indicate an optional value).

注:确保复制上面完整的内容([]不代表是可选内容)

Building the Plugin

  • Navigate to your Git repository folder (ex: c:\git)
  • git clone https://github.com/Microsoft/MixedRealityToolkit.git
  • Open the .sln file located in MixedRealityToolkit\SpectatorViewPlugin\SpectatorViewPlugin\SpectatorViewPlugin.sln
  • Set the build options to Release and x86, then build the solution.

发布插件

1.进入你的git文件夹

2.git下载https://github.com/Microsoft/MixedRealityToolkit.git

3.打开在如下位置的解决方案

4.杂发布时,设置为Release X86,然后发布这个解决方案

 

上面的命令部分,可以在powershell中执行,

在C盘windows文件夹,system32下找到powershell.exe,右键,管理员身份运行

 

在执行命令前可以先手动下载vcpkg

官方提供的下载地址如下:

https://github.com/Microsoft/vcpkg

 

下载好后,解压,powershell 通过cd命令进入你解压好的路径(最好不要放中文路径)

 

其中这句不知道是什么意思,执行失败,我直接跳过了

接下来执行命令

可以看到如下输出,(由于输出过长,这里就不截长图了,将结果粘贴在下面以供参考)

Building vcpkg.exe ...

  pch.cpp
  archives.cpp
  checks.cpp
  chrono.cpp
  cofffilereader.cpp
  downloads.cpp
  enums.cpp
  files.cpp
  hash.cpp
  machinetype.cpp
  strings.cpp
  stringview.cpp
  system.cpp
  system.print.cpp
  binaryparagraph.cpp
  build.cpp
  commands.autocomplete.cpp
  commands.buildexternal.cpp
  commands.cache.cpp
  commands.ci.cpp
  commands.contact.cpp
  commands.cpp
  commands.create.cpp
  commands.dependinfo.cpp
  commands.edit.cpp
  commands.env.cpp
  commands.exportifw.cpp
  commands.import.cpp
  commands.integrate.cpp
  commands.list.cpp
  commands.owns.cpp
  commands.portsdiff.cpp
  commands.search.cpp
  commands.upgrade.cpp
  commands.version.cpp
  commands.xvsinstances.cpp
  dependencies.cpp
  export.cpp
  globalstate.cpp
  help.cpp
  input.cpp
  install.cpp
  metrics.cpp
  packagespec.cpp
  packagespecparseresult.cpp
  paragraphparseresult.cpp
  paragraphs.cpp
  parse.cpp
  postbuildlint.buildtype.cpp
  postbuildlint.cpp
  remove.cpp
  sourceparagraph.cpp
  statusparagraph.cpp
  statusparagraphs.cpp
  tools.cpp
  triplet.cpp
  update.cpp
  userconfig.cpp
  vcpkgcmdarguments.cpp
  vcpkglib.cpp
  vcpkgpaths.cpp
  versiont.cpp
  visualstudio.cpp
  vcpkglib.vcxproj -> E:\Folder\HololensSVPreview\vcpkg-master\toolsrc\msbuild.x86.release\vcpkglib.lib
  vcpkg.cpp
  正在生成代码
  All 17048 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
  已完成代码的生成
  vcpkg.vcxproj -> E:\Folder\HololensSVPreview\vcpkg-master\toolsrc\msbuild.x86.release\vcpkg.exe
  vcpkgmetricsuploader.cpp
  正在生成代码
  All 5511 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
  已完成代码的生成
  vcpkgmetricsuploader.vcxproj -> E:\Folder\HololensSVPreview\vcpkg-master\toolsrc\msbuild.x86.release\vcpkgmetricsuplo
  ader.exe

Building vcpkg.exe... done.

 

接下来执行

执行结果

 

接下来

此处需要为你的VS2017安装英文语言包发,否则可能会报如下错误

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第1张图片

为vs 2017安装英文语言包后,重新执行

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第2张图片

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第3张图片

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第4张图片

某些东西下载可能会很慢,几分钟,几十分钟,根据网络情况,或者最好能有梯子。请耐心等待

执行完成后,又发现有新的报错如下

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第5张图片

 

重新执行这个命令即可,程序会继续下载

PS E:\Folder\hololenssvpreview\vcpkg-master> .\vcpkg install opencv[contrib]:x86-uwp --recurse
The following packages will be built and installed:
  * libjpeg-turbo[core]:x86-uwp
  * libpng[core]:x86-uwp
    opencv[contrib,core,eigen,flann,jpeg,opengl,png,tiff]:x86-uwp
  * opengl[core]:x86-uwp
  * tiff[core]:x86-uwp
Additional packages (*) will be modified to complete this operation.
Starting package 1/5: libjpeg-turbo:x86-uwp
Building package libjpeg-turbo[core]:x86-uwp...
-- Downloading https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.2.tar.gz...
-- Extracting source E:/Folder/HololensSVPreview/vcpkg-master/downloads/libjpeg-turbo-libjpeg-turbo-2.0.2.tar.gz
-- Applying patch add-options-for-exes-docs-headers.patch
-- Applying patch workaround_cmake_system_processor.patch
-- Using source at E:/Folder/HololensSVPreview/vcpkg-master/buildtrees/libjpeg-turbo/src/2.0.2-3c759cce19
-- Downloading http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win32/nasm-2.14.02-win32.zip...
-- Configuring x86-uwp
-- Building x86-uwp-dbg
-- Building x86-uwp-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package libjpeg-turbo[core]:x86-uwp... done
Installing package libjpeg-turbo[core]:x86-uwp...
Installing package libjpeg-turbo[core]:x86-uwp... done
Elapsed time for package libjpeg-turbo:x86-uwp: 9.777 min
Starting package 2/5: tiff:x86-uwp
Building package tiff[core]:x86-uwp...
-- Downloading http://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz...
-- Extracting source E:/Folder/HololensSVPreview/vcpkg-master/downloads/tiff-4.0.10.tar.gz
-- Applying patch fix-stddef.patch
-- Applying patch cmakelists.patch
-- Using source at E:/Folder/HololensSVPreview/vcpkg-master/buildtrees/tiff/src/4.0.10-229dd2f530
-- Configuring x86-uwp
-- Building x86-uwp-dbg
-- Building x86-uwp-rel
-- Installing: E:/Folder/HololensSVPreview/vcpkg-master/packages/tiff_x86-uwp/share/tiff/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package tiff[core]:x86-uwp... done
Installing package tiff[core]:x86-uwp...
Installing package tiff[core]:x86-uwp... done
Elapsed time for package tiff:x86-uwp: 1.687 min
Starting package 3/5: opengl:x86-uwp
Building package opengl[core]:x86-uwp...
-- Performing post-build validation
-- Performing post-build validation done
Building package opengl[core]:x86-uwp... done
Installing package opengl[core]:x86-uwp...
Installing package opengl[core]:x86-uwp... done
Elapsed time for package opengl:x86-uwp: 1.764 s
Starting package 4/5: libpng:x86-uwp
Building package libpng[core]:x86-uwp...
-- Downloading https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz...
-- Extracting source E:/Folder/HololensSVPreview/vcpkg-master/downloads/glennrp-libpng-v1.6.37.tar.gz
-- Applying patch use-abort-on-all-platforms.patch
-- Using source at E:/Folder/HololensSVPreview/vcpkg-master/buildtrees/libpng/src/v1.6.37-802966ac31
-- Configuring x86-uwp
-- Building x86-uwp-dbg
-- Building x86-uwp-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package libpng[core]:x86-uwp... done
Installing package libpng[core]:x86-uwp...
Installing package libpng[core]:x86-uwp... done
Elapsed time for package libpng:x86-uwp: 8.173 min
Starting package 5/5: opencv:x86-uwp
Building package opencv[contrib,core,eigen,flann,jpeg,opengl,png,tiff]:x86-uwp...
-- Downloading https://github.com/opencv/opencv/archive/3.4.3.tar.gz...
-- Downloading https://github.com/opencv/opencv/archive/3.4.3.tar.gz... Failed. Status: 18;"Transferred a partial file"
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:172 (message):

      Failed to download file.
      If you use a proxy, please set the HTTPS_PROXY and HTTP_PROXY environment
      variables to "https://user:password@your-proxy-ip-address:port/".
      Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues

Call Stack (most recent call first):
  scripts/cmake/vcpkg_from_github.cmake:108 (vcpkg_download_distfile)
  ports/opencv/portfile.cmake:5 (vcpkg_from_github)
  scripts/ports.cmake:73 (include)


Error: Building package opencv:x86-uwp failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: opencv:x86-uwp
  Vcpkg version: 2019.06.26-nohash

Additionally, attach any relevant sections from the log files above.

这句在结尾又有报错,重新执行这句命令,会卡在如下位置,

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第6张图片

 

==============20190725

这个下载“3.4.3 tar.gz”这,一直过不去

由于我没有梯子,这一步一直卡着,

无奈最后找别人,用梯子手动下载了这个文件,放到download目录,重新运行命令终于通过了

基本的操作步骤就是:

1.去这个网站,去掉最后的三个点,会直接弹出下载,

2.去我们安装vcpkg的目录,找到dpwnload文件夹,里面有个temp文件夹,里面会显示这个待下载文件的名字。

把temp里的文件名,赋给刚刚下好的本地文件,

3.将这个文件放到download文件夹即可

4.再次运行命令             .\vcpkg install opencv[contrib]:x86-uwp --recurse

程序即会自动加载这个包了。

 

然后接下来,面对疾风。。。阿不,下一个错误吧。

版本低,BUILD_FAILED错误。。。

【Unity】Hololens第三视角(Spectator View)preview 版(ipad或者iphone版) 实现及踩坑记录_第7张图片

 

================20190808

理论上配置完环境,打开官方源码,编译那几个必要的dll

然后手动复制到Unity目录,

接着分别发布HoloLens和IOS版

部署到真机测试即可

 

目前我这没有可用的梯子,环境配置通不过

而且没有Mac和IOS测试设备,项目暂时搁置。。。

如果之后有机会继续做,我会来继续写这篇博客

你可能感兴趣的:(Unity,Hololens,第三人称视角,踩坑)