从PC到HoloLens的现场直播视频时,如何提高HoloLens的性能



我正在从事一个Hololens项目,并希望添加一个将从我的PC进行屏幕截图的功能。幸运的是,我找到了一个存储库https://gist.github.com/jryebread/2BDF148313F40781F1F1F1F1F1F1F1F36D38ADA85D47,这非常有帮助。我修改了客户端上的Python代码的一点,以在我的PC上捕获屏幕捕获,并不断将每个帧发送到HoloLens。但是,HoloLens在运行图像接收器的情况下表现不佳,即使是手动拖动的立方体也无法平稳移动,整个帧速率也下降。

我试图在Unity中使用全息远程远程播放器,例如https://learn.microsoft.com/en-us/windows/mixed-reality/holographic-remoting-player。这样,我只需要在本地读取屏幕截图,然后将整个渲染框架发送给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:FilesPyfiles", "*.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的远程渲染用于此项目?

预先感谢。

从理论上起作用的load_image((内部的过程。

,但是要启动每个更新((帧循环是一个非常糟糕的做法。最好启动一个Coroutine,并使用Waitforsecond((中断使用永无止境的循环。这样,您可以尝试HoloLens可以处理的最大重复率是什么。

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((中优化代码。如果要显示一个图像,只需从磁盘加载一个文件即可。那快得多!

最新更新