【问题标题】:How to improve the performance of HoloLens when live streaming video from PC to HoloLens?将视频从 PC 直播到 HoloLens 时如何提高 HoloLens 的性能?
【发布时间】:2019-12-08 07:55:50
【问题描述】:

我正在处理一个 HoloLens 项目,并希望添加一个功能,将屏幕截图从我的 PC 实时流式传输到 HoloLens。幸运的是,我找到了一个存储库https://gist.github.com/jryebread/2bdf148313f40781f1f36d38ada85d47,非常有帮助。我在客户端修改了一点 Python 代码,以便在我的 PC 上获取屏幕截图,并将每一帧连续发送到 HoloLens。然而,HoloLens 在图像接收器运行时表现不佳,即使是可手动拖动的立方体也无法平滑移动,整个帧率下降。

我曾尝试在 Unity 中使用 Holographic Remoting Player,例如 https://docs.microsoft.com/en-us/windows/mixed-reality/holographic-remoting-player。这样,我只需要在本地读取我的 PC 的屏幕截图,并将整个渲染帧发送到 HoloLens。但是,当我播放 Unity 场景时,包含屏幕截图的原始图像会显示在 Unity 中,但不会显示在 HoloLens 上。

我使用 IEnumerator load_image() 和 StartCoroutine("load_image");从我的电脑加载图像。我用来加载图像并在 UI-RawImage 上显示的代码是

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;

public class LiveScreen : MonoBehaviour {

    public RawImage rawImage;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        StartCoroutine("load_image");
    }

    IEnumerator load_image()
    {
        string[] filePaths = Directory.GetFiles(@"G:\Files\Pyfiles\", "*.jpg");                  // get every file in chosen directory with the extension.png
        WWW www = new WWW("file://" + filePaths[0]);                                    // "download" the first file from disk
        yield return www;                                                               // Wait unill its loaded
        Texture2D new_texture = new Texture2D(320, 180);                                // create a new Texture2D (you could use a gloabaly defined array of Texture2D )
        www.LoadImageIntoTexture(new_texture);                                          
        rawImage.texture = new_texture;
        new_texture.Apply();
    }
}

谁能给我一些建议,告诉我如何在 HoloLens 上提高 APP 的性能,或者我是否可以在这个项目中使用 HoloLens 的远程渲染?

提前致谢。

【问题讨论】:

  • 欢迎来到 StackOverflow!不幸的是,这个社区不是外部资产的搜索引擎。要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是无关紧要的,因为它们往往会吸引固执己见的答案和垃圾邮件。相反,请描述问题以及迄今为止为解决该问题所做的工作。但是,有一个资源可以帮助您入门:unitylist.com/p/fdt/u-Texture-Send-Receive 它使用 UDP 在两个 Unity 实例之间同步纹理。在 MagicLeap 上完美运行
  • 您应该在您的 PC 上本地录制屏幕并将其作为流式传输(如 ffmpeg)发送到 Hololens。如果您使用 unity 开发 Hololens App,derHugo 提供的链接显示了如何在 Unity 中播放流媒体。
  • 感谢您的帮助。抱歉,这是我第一次提出问题,所以当我试图描述它时可能会出错。这个资产很酷。但是,对于这个项目,我必须使用 HoloLens,并且我已经测试过该资产不适用于 HoloLens,因为 HoloLens 的某些功能使用 UWP。我会尝试 ffmpeg 并非常感谢您的帮助。

标签: c# uwp hololens


【解决方案1】:

您在 load_image() 中的过程理论上应该可以工作。

但是在每个 update() 帧循环中启动一个协程是一个非常糟糕的做法。 最好启动一个协程并使用带有 WaitForSecond() 中断的永无止境的循环。通过这种方式,您可以尝试全息透镜可以处理的最大重复率是多少。

void Start () {
     StartCoroutine(StartImageLoading());
 }

 IEnumerator StartImageLoading () {
     while(true){ // This creates a never-ending loop
         yield return new WaitForSeconds(1);
         LoadImage();
         // If you want to stop the loop, use: break;
     }
 }

您也应该在 load_images() 中优化您的代码。如果要显示一张图像,只需从磁盘加载一个文件。那要快得多!

【讨论】:

  • 谢谢,这个建议真的很有帮助。
猜你喜欢
  • 2021-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-01
  • 2017-12-17
  • 1970-01-01
  • 2011-11-22
  • 1970-01-01
相关资源
最近更新 更多