unity 调用手机摄像机 识别二维码
来源:互联网 发布:51单片机毕业设计 编辑:程序博客网 时间:2024/05/22 05:14
简单的调用手机摄像 拍摄 然后识别二维码 显示二维码的内容
需要导入一个zxing.unity.dll文件,现在这个脚本的识别数据是放在Updata里边扫描的 数据量特别大会卡 要是用的话就自己做一下一秒执行一次。我这里没有弄
下载地址http://download.csdn.net/detail/chh19941125/8734149
代码:
using System.Threading;using UnityEngine;using ZXing;public class WebCameraScript : MonoBehaviour{ public string LastResult; public string Lastresult; public Color32[] data; private bool isQuit; public GUITexture myCameraTexture; private WebCamTexture webCameraTexture; private void Start() { // bool success = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO); // Checks how many and which cameras are available on the device for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; cameraIndex++) { // We want the back camera if (!WebCamTexture.devices[cameraIndex].isFrontFacing) { //webCameraTexture = new WebCamTexture(cameraIndex, Screen.width, Screen.height); webCameraTexture = new WebCamTexture(cameraIndex, 200, 200); // Here we flip the GuiTexture by applying a localScale transformation // works only in Landscape mode myCameraTexture.transform.localScale = new Vector3(1, 1, 1); } } // Here we tell that the texture of coming from the camera should be applied // to our GUITexture. As we have flipped it before the camera preview will have the // correct orientation myCameraTexture.texture = webCameraTexture; // Starts the camera webCameraTexture.Play(); //enabled=WebCamTexture.s } public void ShowCamera() { myCameraTexture.guiTexture.enabled = true; webCameraTexture.Play(); } public void HideCamera() { myCameraTexture.guiTexture.enabled = false; webCameraTexture.Stop(); } private void OnGUI() { GUI.Label(new Rect(60, 30*1, Screen.width, 20), "LastResult:" + LastResult); if (GUI.Button(new Rect(0, 0, 100, 100), "ON/OFF")) { if (webCameraTexture.isPlaying) HideCamera(); else ShowCamera(); } } private void Update() { //data = new Color32[webCameraTexture.width * webCameraTexture.height]; data = webCameraTexture.GetPixels32(); DecodeQR(webCameraTexture.width, webCameraTexture.height); } private void DecodeQR(int W, int H) { if (isQuit) return; // create a reader with a custom luminance source var barcodeReader = new BarcodeReader {AutoRotate = true, TryHarder = true}; // while (true) { try { // decode the current frame Result result = barcodeReader.Decode(data, W, H); if (result != null) { LastResult = result.Text; // shouldEncodeNow = true; print("i read out::" + result.Text); } // Sleep a little bit and set the signal to get the next frame Thread.Sleep(200); data = null; } catch { } } }}
0 0
- unity 调用手机摄像机 识别二维码
- unity Vuforia + 二维码解析 使用同一个摄像机
- 【Unity+Hololens开发】识别二维码
- Unity二维码识别和生成二维码
- 关于手机拍照识别二维码
- Unity编程笔录--Unity二维码识别和生成二维码
- unity 调用外部摄像机(c#)
- 【Unity】Unity调用手机陀螺仪
- 手机识别二维码生成到pdf中
- unity调用android语音识别
- Unity摄像机
- Unity 摄像机
- unity 摄像机
- python调用zxing项目进行二维码识别
- zxing二维码生成扫描,识别二维码图片,长按识别二维码调用方便简洁
- HTML5 调用手机摄像头扫描二维码
- 关于unity3d调用手机摄像机的一些操作
- HTML5调用手机摄像机、相册功能 <input>方法
- 为应用添加多个Activity与参数传递
- exec-maven-plugin(Maven自动执行批处理脚本的插件,可用于复制WAR包到Tomcat)
- 选择排序
- equals和==的区别
- HDOJ 1239 Calling Extraterrestrial Intelligence Again
- unity 调用手机摄像机 识别二维码
- NoSQL数据库笔谈(转)
- java mysql 基本操作
- JVM加载class文件的原理
- C++中智能指针的设计和使用
- spring 容器
- linux下2048小游戏
- linux内存管理(堆栈、数组)
- 浏览器兼容性