最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Unity調(diào)用手機(jī)攝像機(jī)識(shí)別二維碼

 更新時(shí)間:2019年07月24日 14:49:16   作者:C-h-h  
這篇文章主要為大家詳細(xì)介紹了Unity調(diào)用手機(jī)攝像機(jī)識(shí)別二維碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)現(xiàn)Unity調(diào)用手機(jī)攝像,拍攝,然后識(shí)別二維碼,顯示二維碼的內(nèi)容。

需要導(dǎo)入一個(gè)zxing.unity.dll文件,現(xiàn)在這個(gè)腳本的識(shí)別數(shù)據(jù)是放在Updata里邊掃描的 數(shù)據(jù)量特別大會(huì)卡  要是用的話就自己做一下一秒執(zhí)行一次。我這里沒有弄

下載地址:zxing.unity.dll

代碼:

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
  {
  }
 }
 }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 剖析設(shè)計(jì)模式編程中C#對(duì)于組合模式的運(yùn)用

    剖析設(shè)計(jì)模式編程中C#對(duì)于組合模式的運(yùn)用

    這篇文章主要介紹了設(shè)計(jì)模式編程中C#對(duì)于組合模式的運(yùn)用,理論上來說組合模式包含抽象構(gòu)件、樹葉構(gòu)件和樹枝構(gòu)件三個(gè)角色,需要的朋友可以參考下
    2016-02-02
  • C# AutoMapper 使用方法總結(jié)

    C# AutoMapper 使用方法總結(jié)

    這篇文章主要介紹了C# AutoMapper 使用方法,文中講解非常細(xì)致,代碼幫助大家更好的理解學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • 淺談二叉查找樹的集合總結(jié)分析

    淺談二叉查找樹的集合總結(jié)分析

    本篇文章是談二叉查找樹進(jìn)行了詳細(xì)的總結(jié)分析,需要的朋友參考下
    2013-05-05
  • WinForm使用DecExpress控件中的ChartControl插件繪制圖表

    WinForm使用DecExpress控件中的ChartControl插件繪制圖表

    這篇文章介紹了WinForm使用DecExpress控件中的ChartControl插件繪制圖表的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05
  • C#實(shí)現(xiàn)windows form倒計(jì)時(shí)的方法

    C#實(shí)現(xiàn)windows form倒計(jì)時(shí)的方法

    這篇文章主要介紹了C#實(shí)現(xiàn)windows form倒計(jì)時(shí)的方法,涉及C#桌面程序設(shè)計(jì)中時(shí)間操作的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • C# WINFORM自定義異常處理方法

    C# WINFORM自定義異常處理方法

    這篇文章主要介紹了一個(gè)簡(jiǎn)單的統(tǒng)一異常處理方法。系統(tǒng)底層出現(xiàn)異常,寫入記錄文件,系統(tǒng)頂層捕獲底層異常,顯示提示信息。需要的可以參考一下
    2021-12-12
  • 詳解C# 托管資源和非托管資源

    詳解C# 托管資源和非托管資源

    這篇文章主要介紹了詳解C# 托管資源和非托管資源的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • C#開發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)

    C#開發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)

    本文詳細(xì)講解了C#開發(fā)WinForm清空DataGridView控件綁定數(shù)據(jù)的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-03-03
  • C#操作配置文件app.config、web.config增刪改

    C#操作配置文件app.config、web.config增刪改

    這篇文章介紹了C#操作配置文件app.config、web.config增刪改的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05
  • C#實(shí)現(xiàn)改變DataGrid某一行和單元格顏色的方法

    C#實(shí)現(xiàn)改變DataGrid某一行和單元格顏色的方法

    這篇文章主要介紹了C#實(shí)現(xiàn)改變DataGrid某一行和單元格顏色的方法,主要涉及DataGrid控件的添加與使用、數(shù)據(jù)源的綁定、單元格與行的獲取等操作。需要的朋友可以參考下
    2014-09-09

最新評(píng)論

深州市| 六盘水市| 沁阳市| 商城县| 宕昌县| 友谊县| 梓潼县| 陇川县| 拜城县| 萨嘎县| 工布江达县| 剑河县| 荔浦县| 仪陇县| 化州市| 宁阳县| 龙州县| 鄂州市| 南靖县| 衢州市| 万荣县| 曲水县| 来宾市| 广昌县| 永清县| 策勒县| 晴隆县| 德安县| 星座| 波密县| 玉林市| 阿巴嘎旗| 台中市| 南雄市| 西乌珠穆沁旗| 河曲县| 陆丰市| 丹东市| 大足县| 阿巴嘎旗| 清镇市|