首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何提高HoloLens从PC到HoloLens现场流媒体视频的性能?

如何提高HoloLens从PC到HoloLens现场流媒体视频的性能?
EN

Stack Overflow用户
提问于 2019-07-30 20:53:46
回答 1查看 581关注 0票数 1

我正在做一个HoloLens项目,并希望添加一个功能,从我的PC到HoloLens的实时流屏幕截图。幸运的是,我找到了一个存储库https://gist.github.com/jryebread/2bdf148313f40781f1f36d38ada85d47,这非常有用。我在客户端修改了一些python代码,以便在我的PC上获得屏幕截图,并不断地将每一帧发送到HoloLens。然而,在图像接收器运行的情况下,HoloLens性能很差,即使是手拖动的立方体也不能平稳地移动,整个帧速率也会下降。

我已经尝试使用全息遥控播放器在团结,如https://learn.microsoft.com/en-us/windows/mixed-reality/holographic-remoting-player。这样,我只需要读取屏幕截图从我的PC本地和发送整个渲染的帧到HoloLens。但是,当我播放“统一”场景时,原始图像包含显示在“统一”中的屏幕快照,但不显示在HoloLens上。

我使用IEnumerator load_image()和StartCoroutine("load_image");从我的计算机加载图像。用于加载映像并在UI-RawImage上显示的代码是

代码语言:javascript
复制
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上的应用程序的性能,或者我是否可以在这个项目中使用HoloLens的远程渲染?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-09 08:01:01

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

但是,启动coroutine每一个更新()框架循环是一种非常糟糕的做法。最好启动一个协同线,并使用带有WaitForSecond()中断的永无止境循环。这样,你可以尝试什么是最大重复率,全息镜头可以处理。

代码语言:javascript
复制
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()中的代码。如果您想要显示一个映像,只需从磁盘加载一个文件。那就快多了!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57279871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档