获取Tango的相机流数据 [英] Getting Tango's camera stream data

查看:73
本文介绍了获取Tango的相机流数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取Tango的相机流,以将自制的AR套件与Tango结合在一起.

I'm trying to get the Tango's camera stream in order to combine an homemade AR Kit to Tango.

我被困在一切都可以按Tango编辑器仿真的预期工作的状态,但不适用于推送到平板电脑的应用程序.

I'm stuck at a point where everything works as intended in Tango's editor emulation, but not in the app pushed to the tablet.

我正在使用的代码如下:

The code I'm using is the following:

YUVTexture yuvTexture = m_tangoApplication.GetVideoOverlayTextureYUV();
Texture2D yTexture = yuvTexture.m_videoOverlayTextureY;
// m_videoOverlayTextureCr is not used by Tango yet for some reason
Texture2D uvTexture = yuvTexture.m_videoOverlayTextureCb;

// convert from YV12 to RGB
for (int i = 0; i < yTexture.height; ++i)
{
    for (int j = 0; j < yTexture.width; ++j)
    {
        Color yPixel = yTexture.GetPixel(j, i);
        Color uvPixel = uvTexture.GetPixel(j, i);

        m_texture.SetPixel(4 * j + 0, yTexture.height - i - 1, YUV2Color(yPixel.r, uvPixel.r, uvPixel.g));
        m_texture.SetPixel(4 * j + 1, yTexture.height - i - 1, YUV2Color(yPixel.g, uvPixel.r, uvPixel.g));
        m_texture.SetPixel(4 * j + 2, yTexture.height - i - 1, YUV2Color(yPixel.b, uvPixel.b, uvPixel.a));
        m_texture.SetPixel(4 * j + 3, yTexture.height - i - 1, YUV2Color(yPixel.a, uvPixel.b, uvPixel.a));
    }
}

YUV2Color(从Tango的YUV2RGB着色器中提取):

YUV2Color (extracted from Tango's YUV2RGB Shader):

public static Color YUV2Color(float y_value, float u_value, float v_value)
{
    float r = y_value + 1.370705f * (v_value - 0.5f);
    float g = y_value - 0.698001f * (v_value - 0.5f) - (0.337633f * (u_value - 0.5f));
    float b = y_value + 1.732446f * (u_value - 0.5f);

    return new Color(r, g, b, 1f);
}

有人已经解决了这个问题吗?当大多数使用 ITangoVideoOverlay 时,我已经看到了很多与之相关的帖子,但是对于当前的 IExperimentalTangoVideoOverlay

Did someone already solved this problem? I've seen a lot of post related to it when the ITangoVideoOverlay was mostly used, but nothing with the current IExperimentalTangoVideoOverlay

我已经做了很多尝试,到目前为止,这是我最接近的预期……任何帮助将不胜感激.

I've experimented a lot of things, so far it has been the closest I got to what I expected ... Any help would be highly appreciated.

推荐答案

您正在使用纹理ID"方法来获取YUV纹理颜色,这并不是很常见.一个更简单的方法是使用Raw Byte缓冲方法来获取彩色摄像机图像,以实现此目的:

You are using the Texture ID method to get the YUV texture color, this is not very common to do. A easier path would be using the Raw Byte buffer method to get color camera image, to do that:

  1. TangoManager预制上,启用视频覆盖,然后从下拉框中选择Raw Byte方法.
  2. 注册到 ITangoVideoOverlay 界面.
  3. 将图像缓冲区数据从YUV转换为RGB,这部分与YUV2Color函数完全一样,但是使用来自
  1. On TangoManager prefab, enable video overlay, and select Raw Byte method from the drop down box.
  2. Register to ITangoVideoOverlay interface.
  3. Convert the image buffer data from YUV to RGB, this part is exactly like the YUV2Color function, but use data from TangoImageData.data

这篇关于获取Tango的相机流数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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