zoukankan      html  css  js  c++  java
  • Unity3D调用摄像头显示当前拍摄画面

    1. using UnityEngine;  
    2. using System.Collections;  
    3.   
    4. public class CameraTest : MonoBehaviour  
    5. {  
    6.     public WebCamTexture cameraTexture;  
    7.     public string cameraName="";  
    8.     private bool isPlay = false;  
    9.     // Use this for initialization  
    10.     void Start()  
    11.     {  
    12.         StartCoroutine(Test());  
    13.     }  
    14.   
    15.     // Update is called once per frame  
    16.     void Update()  
    17.     {  
    18.   
    19.     }  
    20.   
    21.     IEnumerator Test()  
    22.     {  
    23.         yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);  
    24.         if (Application.HasUserAuthorization(UserAuthorization.WebCam))  
    25.         {  
    26.             WebCamDevice[] devices = WebCamTexture.devices;  
    27.             cameraName = devices[0].name;  
    28.             cameraTexture = new WebCamTexture(cameraName, 400, 300, 15);  
    29.             cameraTexture.Play();  
    30.             isPlay = true;  
    31.         }  
    32.     }  
    33.   
    34.     void OnGUI()  
    35.     {  
    36.         if (isPlay)  
    37.         {  
    38.             GUI.DrawTexture(new Rect(0, 0, 400, 300), cameraTexture, ScaleMode.ScaleToFit);  
    39.         }  
    40.     }  

  • 相关阅读:
    爬虫解析库:XPath
    手写一个小型打包构建工具
    Python网络爬虫神器PyQuery的使用方法
    人脸识别JavaScript也可以轻松搞定
    颜值即正义!这几个库颠覆你对数据交互的想象
    微信朋友圈自动点赞
    android studio的安装信息
    Docker使用笔记
    C语言联合
    Mac之Sublime Text使用Go
  • 原文地址:https://www.cnblogs.com/yfceshi/p/6856723.html
Copyright © 2011-2022 走看看