zoukankan      html  css  js  c++  java
  • unity3d 读取usb摄像头

    using UnityEngine;
    using System.Collections;
    
    public class C : MonoBehaviour
    {
        private WebCamTexture cameraTexture;
        private string cameraName = "";
        private bool isPlay = true;
        // Use this for initialization  
        void Start()
        {
            cameraTexture = new WebCamTexture();
            StartCoroutine(Test());
        }
    
        // Update is called once per frame  
        void Update()
        {
    
        }
    
        IEnumerator Test()
        {
            yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
            if (Application.HasUserAuthorization(UserAuthorization.WebCam))
            {
                WebCamDevice[] devices = WebCamTexture.devices;
                cameraName = devices[0].name;
                cameraTexture = new WebCamTexture(cameraName, 400, 300, 15);
                cameraTexture.Play();
                isPlay = true;
            }
        }
    
        void OnGUI()
        {
            if (isPlay)
            {
                GUI.DrawTexture(new Rect(0, 0, 400, 300), cameraTexture, ScaleMode.ScaleToFit);
            }
        }
    }

  • 相关阅读:
    query compiler
    non-deterministic-turing-machine
    What-are-P-NP-NP-complete-and-NP-hard
    查询优化器的算法
    Redis 和 I/O 多路复用
    Linux aio
    MySQL 的那些网络超时错误
    MYSQL performance
    jvmti
    JVM Troubleshooting
  • 原文地址:https://www.cnblogs.com/dragon2012/p/4624782.html
Copyright © 2011-2022 走看看