LoginSignup
4
2

More than 3 years have passed since last update.

【HoloLens1】HoloLens RS5 で Research mode を使う

Last updated at Posted at 2018-12-22

HoloLens Advent Calendar 2018 22日目の記事です。
今回は春に行われたHoloLensのバージョンアップ、RS4で実装されたResearch modeをRS5でも使ってみます。

HoloLens Research modeとは

Windows 10 April 2018 Update(RS4)で実装されたHoloLensの機能。
RS4以降のHoloLensで使用することができ、HoloLens上で使われる各種センサの値を可視化する事ができます。
可視化できるデータには以下のものがあります。

・地図作成と頭部トラッキングに使われる4台の環境認識カメラ
・2種類の深度カメラ (近距離センシング用と遠距離センシング用)
・2種類の赤外線反射データ (IRエミッタから照射される赤外線を使う)

計8種類のセンサデータにアクセスでき、アプリ内に埋め込む事も可能。

※Research modeは研究者などを対象にしたモードであり、Research modeの機能を埋め込んだHoloLensアプリをストアに公開する事は厳しいと思われます。

環境

実行環境
HoloLens RS5 日本語対応版
OS Build : 10.0.17763.1

開発環境
Visual Studio 2017

導入

以下のURLに沿って進めていきます。
https://docs.microsoft.com/en-us/windows/mixed-reality/research-mode

<HoloLens側の準備>
[設定] > [更新ととセキュリティ] > [開発者向け]
・「開発者向け機能を使う」と「デバイスポータルを有効にする」をオンにします。

<PC側の準備>
・PC上でデバイスポータルにアクセスします。(https://[IPv4 アドレス])
・デバイスポータルのメニューからResearch modeを選択し、Allow access to sensor streams にチェックを入れ、HoloLensを再起動します。これで、Research modeが利用可能になります。
・以下リポジトリのマスターブランチをCloneします。
 https://github.com/Microsoft/HoloLensForCV
・zipファイルを解凍し、中にあるHoloLensForCV.slnをVisual Studioで開きます。
・HoloLens実機とPCを繋ぎ、Release、x86、SensorStreamViewerをDevice実行でビルドします。

キャプチャ.PNG

・各種センサーが可視化されたデータが表示されます。上部が深度カメラと赤外線反射データ、下部が環境認識カメラを可視化したものになります。
20181222_203547_HoloLens.jpg

上部4つの画像は8bitのBGRAフォーマットで出力されています。
VisualStudio内のFrameRenderer.cpp内の値を変更する事でグレースケールやナイトビジョン風の表示に変える事も可能です。

FrameRenderer.cpp
    // Set color based on a ratio of how closely it matches the surrounding colors.
    UINT32 alpha = static_cast<UINT32>((scaled - integer) * 255);
    UINT32 beta = 255 - alpha;
    return {
        static_cast<byte>((prev.A * beta + next.A * alpha) / 255), // Alpha
        static_cast<byte>((prev.R * beta + next.R * alpha) / 255), // Red
        static_cast<byte>((prev.G * beta + next.G * alpha) / 255), // Green
        static_cast<byte>((prev.B * beta + next.B * alpha) / 255)  // Blue
    };

深度カメラの範囲を指定など。深度は16bitで取得。

FrameRenderer.cpp
                // Use a special pseudo color to render 16 bits depth frame.
                // Since we must scale the output appropriately we use std::bind to
                // create a function that takes the depth scale as input but also matches
                // the required signature.
                const float depthScale = 1.0f / 1000.0f;
                float minReliableDepth, maxReliableDepth;

                if (m_sensorName == L"Long Throw ToF Depth")
                {
                    minReliableDepth = 0.5f;
                    maxReliableDepth = 4.0f;
                }
                else
                {
                    minReliableDepth = 0.2f;
                    maxReliableDepth = 1.0f;
                }

まとめ

HoloLens Research modeを利用する事で各種センサデータを可視化する事ができました。
Unityに埋め込む事ができれば、利用の幅も広がるので、そちらの方もやっていきたいと思います。

実行時の動画を以下に載せました↓
HoloLens RS5 Research mode test

参考

Microsoft Docs / HoloLens Research mode

4
2
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
2