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

查看:331
本文介绍了如何服用使用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();

我正在考虑使用这种技术.如果成功,将返回报告.

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天全站免登陆