如何服用 &使用 Unity ARCore SDK 保存图片/屏幕截图? [英] How to take & save picture / screenshot using Unity ARCore SDK?

查看:26
本文介绍了如何服用 &使用 Unity ARCore SDK 保存图片/屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里找到了如何以本机方式执行此操作的答案,但我正在运行 Unity.

I found the answer to how to do it natively here but Im running Unity.

如何使用 ARCore 使用相机拍照

我不确定如何访问 Unity 表面渲染器线程以便能够放入这些函数.

I'm not sure how to access the Unity surface renderer thread to be able to drop in those functions.

这看起来是一个好的开始.想法?

This looks like a good start. Ideas?

使用 Texture2d ReadPixels 或 ScreenCapture.CaptureScrenshot 不可行,因为它们会阻塞渲染线程.下面的代码足以阻塞线程.

Using Texture2d ReadPixels or ScreenCapture.CaptureScrenshot are not viable as they are blocking the render thread. The code below is enough to block the thread.

StartCoroutine(TakeScreenshot());

private IEnumerator TakeScreenshot()
    {
        yield return new WaitForEndOfFrame();

        Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        ss.Apply();

编辑 2:我正在考虑使用这种技术.成功会反馈.

Edit 2: Am considering using this technique. Will report back if successful.

推荐答案

ARCore 提供了自己的 TextureReader 类,该类速度极快,并且不会重现上述副作用.TextureReader_acquireFrame

ARCore provides its own TextureReader class that is extremely fast and doesn't reproduce the side effects noted. TextureReader_acquireFrame

https://github.com/google-ar/arcore-unity-sdk/blob/master/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs

这篇关于如何服用 &使用 Unity ARCore SDK 保存图片/屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆