コード例 #1
1
	public static Result DecodeImage(Texture2D tex)
	{
		Color32LuminanceSource colLumSource = new Color32LuminanceSource(tex.GetPixels32(), tex.width, tex.height);
		HybridBinarizer hybridBinarizer = new HybridBinarizer(colLumSource);
		BinaryBitmap bitMap = new BinaryBitmap(hybridBinarizer);
		//We reset before we decode for safety;


		CodeReader.reset();

		return CodeReader.decode(bitMap);
	}
コード例 #2
0
        /// <summary>
        /// Function for just fetching the QR-Codes in the WebCamTexture-Image.
        /// It stores the Data in a QrCodeData-Object.
        /// It uses the "pixels" field as the image-source, since we can not
        /// access the Unity-API from another thread than the main-thread.
        /// </summary>
        private void DecodeQr()
        {
            while (_runThread)
            {
                // waiting.
                if (_pixels != null)
                {
                    // Create a BitMatrix from the Color32[] of the camear image, so that XZing can detect QR-codes.
                    LuminanceSource lum = new Color32LuminanceSource(_pixels, GlobalState.Instance.CamWidth, GlobalState.Instance.CamHeight);
                    HybridBinarizer bin = new HybridBinarizer(lum);
                    BinaryBitmap binBip = new BinaryBitmap(bin);
                    BitMatrix matrix = binBip.BlackMatrix;

                    Detector detector = new Detector(matrix);
                    DetectorResult result = detector.detect();
                    _qrCodeCollection.UpdateData(result);
                }
            }
        }
コード例 #3
0
        public static Result[] DecodeMultiple(this IBarcodeReaderGeneric reader, Color32[] rawColor32, int width, int height)
        {
            var luminanceSource = new Color32LuminanceSource(rawColor32, width, height);

            return(reader.DecodeMultiple(luminanceSource));
        }