Help us understand the problem. What is going on with this article?

【THETA V】ライブストリーミングの映像をUnityで表示

More than 1 year has passed since last update.

準備

RICOH THETA Vで4Kライブストリーミングをしよう

Skybox版

  • MainCameraにSkyboxを追加。
  • [Custom Skybox]にStereoarts HomepageThetaRealtimeSkyboxを設定。
  • MainCameraに以下のWebCamDrawer.csをアタッチ。

Sphere版

映像を描画するスクリプト

THETA SからOculus RiftへUSBライブストリーミング with Unity (Skybox編)よりWebCamDrawer.csを拝借、少し手を加えたスクリプト。

WebCamDrawer.cs
using UnityEngine;
using System.Collections;

public class WebCamDrawer : MonoBehaviour {
    public string deviceNameKeyword = "THETA";

    void Start() {
        StartStreaming();
    }

    void StartStreaming() {
        WebCamDevice device = new WebCamDevice();
        // 参照渡しでdeviceを書き換え
        if (!FindDevice (ref device)) {
            Debug.LogError("<"+deviceNameKeyword+">を含むWebカメラが検出できませんでした。");
            return;
        }
        WebCamTexture webcamTexture = new WebCamTexture(device.name);
        Material mat = GetTargetMaterial ();
        if (mat == null) {
            return;
        }
        mat.mainTexture = webcamTexture;
        webcamTexture.Play();
    }

    bool FindDevice(ref WebCamDevice target) {
        bool deviceExists = false;
        WebCamDevice[] devices = WebCamTexture.devices;
        foreach (WebCamDevice device in devices) {
            Debug.Log("device.name => " + device.name);
            if (device.name.Contains(deviceNameKeyword)) {
                target = device;
                deviceExists = true;
            }
        }
        return deviceExists;
    }

    Material GetTargetMaterial() {
        Skybox skybox = GetComponent<Skybox> ();
        if (skybox != null) {
            return skybox.material;
        }
        Renderer renderer = GetComponent<Renderer> ();
        if (renderer != null) {
            return renderer.material;
        }
        Debug.LogError ("Renderer/Skyboxコンポーネントがありません。");
        return null;
    }
}

参考
WebCamTexture

windowsのエラー

Could not connect pins - RenderStream()
UnityEngine.WebCamTexture:Play()

こんなエラーが出てくるので、以下のURLを参考に進める。
Solved: Unity Can’t Display THETA V Live Stream on Windows 10

レジストリエディターからDevicePathを追加する。
2018-02-03.png

WebCamDrawer.csのデバイスの名前を、Macの場合はTHETA、Windowsの場合はTHETA V FullHDと使い分ける。
2018-02-03 (1).png

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away