Unity3D打开摄像头并且调节分辨率
来源:互联网 发布:软件自动升级原理 编辑:程序博客网 时间:2024/06/05 00:43
using UnityEngine;
using System.Collections;
public class WebCamManager : MonoBehaviour
{
private string deviceName;
private WebCamTexture tex;
// Use this for initialization
void Start()
{
StartCoroutine(InitCamera());
}
// Update is called once per frame
void Update()
{
}
protected IEnumerator InitCamera()
{
//获取授权
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
Debug.Log("devices.Length " + devices.Length);
if (devices.Length > 0)
{
deviceName = devices[0].name;
Debug.Log("deviceName " + deviceName);
tex = new WebCamTexture(deviceName, (int)resSize.x, (int)resSize.y, 30);
Renderer renderer = GetComponent<Renderer>();
}
}
}
using System.Collections;
public class WebCamManager : MonoBehaviour
{
private string deviceName;
private WebCamTexture tex;
private Vector2 resSize = new Vector2(1920, 1080);
// 这里是设置手机的分辨率,可以使摄像更清楚(背景)
// Use this for initialization
void Start()
{
StartCoroutine(InitCamera());
}
// Update is called once per frame
void Update()
{
}
protected IEnumerator InitCamera()
{
//获取授权
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
Debug.Log("devices.Length " + devices.Length);
if (devices.Length > 0)
{
deviceName = devices[0].name;
Debug.Log("deviceName " + deviceName);
tex = new WebCamTexture(deviceName, (int)resSize.x, (int)resSize.y, 30);
Renderer renderer = GetComponent<Renderer>();
renderer.material.mainTexture = tex;
//将材质贴到plane上面
tex.Play();}
}
}
}
将此脚本挂在一个plane上面就可以在上面显示手机摄像头拍摄的东西。
0 0
- Unity3D打开摄像头并且调节分辨率
- Unity3D调用摄像头时的最高分辨率
- 分辨率调节
- Unity3D 设置摄像头的分辨率,比如罗技
- Android开发Camera类照相机,前后摄像头切换,分辨率读取和调节
- VS2013下使用OpenCV2.4.9打开摄像头并且显示
- 调节分辨率的函数
- Ubuntu10.04调节分辨率
- 远程桌面分辨率调节
- ubnutn 分辨率调节
- Ubuntu分辨率调节
- 使用unity3D开发同时打开手机前后摄像头实例程序
- 调节Unity3D GuiTexture 透明度
- Unity3d的lodgroup调节
- 打开摄像头
- 打开摄像头
- VirtualBox调节Linux系统分辨率
- opencv 设置摄像头分辨率
- python求各种距离公式
- 多线程 pthread学习之一
- logback简单配置详解
- Android Studio自动补全代码问题总结,,,,,,,,,后续更新
- Android 6.0及更高版本Android Runtime Permission(一)
- Unity3D打开摄像头并且调节分辨率
- HDU-5868-Different Circle Permutation-Burnside定理和polay计数
- 简单的Python脚本实践
- JavaScript中实现继承的几种方式
- Linux性能优化和监控系列(一)top工具
- 兼容iOS 10 资料整理笔记
- 【HDU 5880】Family View(AC自动机)
- ThraedLocal
- 一条命令解决500 Error: Cannot find module 'XXX'