【问题标题】:WebCamTexture doesn't show on Daydream (Pixel's device camera)?WebCamTexture 不显示在 Daydream(Pixel 的设备摄像头)上?
【发布时间】:2017-06-11 00:54:02
【问题描述】:

我正在尝试在 Unity 构建的 Daydream 应用中使用设备摄像头(Pixel 手机)实时视频显示。在 Unity 中我尝试了 WebCamTexture,当在 PC 上的 Unity 中测试运行时,WebCamTexture 会捕获网络摄像头源,但是当我将应用程序构建到 Daydream /Cardboard 时,没有摄像头源。但是,如果检测到任何相机,我确实放了一个画布/文本来打印出来,如果是的话,相机的名称。在 Daydream 应用程序运行时,检测到 2 个摄像头(摄像头 0、摄像头 1),但未显示图像。有没有人有想法/建议如何解决这个问题?以下是我用 C# 编写的代码,并将其附加到 Unity Plane/ Quad,并引用了 Canvas Text。

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class tWebCam : MonoBehaviour
{
    public Text textPanel;
    WebCamTexture mCamera = null;

    public GameObject camPlane;
    // Use this for initialization
    void Start ()
    {
        WebCamDevice[] devices = WebCamTexture.devices;

        //camPlane = GameObject.FindWithTag("Player");

        if (devices.Length > 0)
        {
            mCamera = new WebCamTexture(devices[devices.Length-1].name, 1920, 1920, 30);
            camPlane.GetComponent<Renderer>().material.mainTexture = mCamera;

            mCamera.deviceName = devices[devices.Length - 1].name;
            Debug.Log(devices.Length);
            Debug.Log(mCamera.deviceName);
            mCamera.Play();
            textPanel.text = "# of devices: " + devices.Length.ToString() + "; Device 1: " + mCamera.deviceName;
        }
        else
        {
            textPanel.text = "No device detected...";
        }


    }

    // Update is called once per frame
    void Update () {

    }
}

【问题讨论】:

    标签: unity3d google-vr daydream


    【解决方案1】:

    如果我理解您的问题,相机将无法工作,因为手机位于 Cardboard 或 Daydream 耳机内,因此受到物理阻碍。

    【讨论】:

    • 感谢贾斯汀的回答。纸板或 Daydream 耳机的物理遮挡可以修改,所以这不是我主要关心的问题。我想弄清楚的是是否可以访问设备摄像头。在旁注中,我注意到对于探戈项目,有一个结合探戈和纸板的实验示例。因此可以作为内向外跟踪; neverthrless,它只适用于支持 Tango 的设备。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    相关资源
    最近更新 更多