Показать сообщение отдельно
Старый 04.05.2013, 23:03   #4
pie
ПроЭктировщик
 
Аватар для pie
 
Регистрация: 04.11.2011
Сообщений: 176
Написано 19 полезных сообщений
(для 64 пользователей)
Ответ: Чтение QR кода

Для чтения с веб камеры.
using UnityEngine;
using System.Collections;
using System.Threading;
using com.google.zxing.qrcode;

public class 
SecurityTest MonoBehaviour {    
    
WebCamTexture camTexture;
    
Thread qrThread;

    
Color32[] c;
    
sbyte[] d;
    
int whwxh;
    
int xyz;
    
bool isQuit;
    
    public 
void Start () {
        
camTexture = new WebCamTexture ();
        
OnEnable ();
        
        
qrThread = new Thread (DecodeQR);
        
qrThread.Start ();
    }
    
    public 
void OnEnable () {
        if (
camTexture != null) {
            
camTexture.Play ();
            
camTexture.width;
            
camTexture.height;
            
wxh h;
        }
    }
    
    public 
void OnDisable () {
        if (
camTexture != null) {
            
camTexture.Pause ();
        }
    }
    
    public 
void OnDestroy () {
        
qrThread.Abort ();
        
camTexture.Stop ();
    }
    
    public 
void OnApplicationQuit () {
        
isQuit true;
    }
    
    public 
void Update () {
        
camTexture.GetPixels32 ();
    }
    
    public 
void DecodeQR () {
        while(
true) {
            if(
isQuit) break;
            try {                
                
= new sbyte[wxh];
                
0;
                for(
1>= 0y--) {
                    for(
0wx++) {
                        
d[z++] = (sbyte)(((int)c[x].r) << 16 | ((int)c[x].g) << | ((int)c[x].b));
                    }
                }
               
Debug.Log (new QRCodeReader().decode(dwh).Text);
            }
            catch {
                continue;
            }
        }
    }
    
    public 
void OnGUI () {
        
GUI.DrawTexture(new Rect (00Screen.widthScreen.height), camTextureScaleMode.ScaleToFit);
    }

(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
Andvrok (06.05.2013)