LoginSignup
4
4

More than 5 years have passed since last update.

UnityでZEDから深度画像を取得する

Last updated at Posted at 2017-04-22

はじめに

ZEDのUnityサンプルには、トラッキングと、クロマキーと、MRのサンプルしか無かったので、Unity上でDepth値をどうやって使うのか調べてみました。

震度画像を取得

ZEDで画像を取得している箇所は、TextureOverlay.csのStart()関数内です。

//Create two textures and fill them with the ZED computed images
camZed = zedCamera.CreateTextureImageType(videoType);
depthXYZZed = zedCamera.CreateTextureMeasureType(sl.MEASURE.XYZ);

おそらく実体はこれですが、depthXYZZedでDepthを取得しているように見えます。
しかしここで取得している値はrgbの3次元であり、ShaderでQuadに出力してみても、Depthっぽいですが少し違うような値しか取得できませんでした。
これはsl.MEASURE.XYZで取得しているのが原因でした。

CreateTextureMeasureType(){
    ...
    if (mode == MEASURE.XYZ || mode == MEASURE.XYZABGR || mode == MEASURE.XYZARGB || mode == MEASURE.XYZBGRA || mode == MEASURE.XYZRGBA)
    {
        m_Texture = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RGBAFloat, false, true);
    }
    else if (mode == MEASURE.DEPTH || mode == MEASURE.CONFIDENCE)
    {
        m_Texture = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RFloat, false, true);
    }
}

ここでXYZとDEPTHの判別を行っており、引数をsl.MEASURE.DEPTHとすることで、Texture2D型のデプスマップを取得することが出来ました。
XYZが何を取得しているかは今のところ不明です。MeasureTypeとなっているので距離を取得はしているんでしょうが、値を見てもよく分かりませんでした。

2017-04-22_102345.png

画像は取得した値をShader内で1/10にして出力しています。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4