Ejemplo n.º 1
0
        public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            DecoderResult decoderResult;

            ResultPoint[] points;
            if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
            {
                BitMatrix bits = extractPureBits(image.BlackMatrix);
                if (bits.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(bits);
                points        = NO_POINTS;
            }
            else
            {
                var            detector       = new Detector(image.BlackMatrix);
                DetectorResult detectorResult = detector.detect(hints);
                if (detectorResult.IsBlank())
                {
                    return(null);
                }

                decoderResult = decoder.decode(detectorResult.Bits);
                if (decoderResult == null)
                {
                    return(null);
                }

                points = detectorResult.Points;
            }

            Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);

            if (decoderResult.ByteSegments != null)
            {
                result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments);
            }
            if (decoderResult.ECLevel != null)
            {
                result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString());
            }
            return(result);
        }
Ejemplo n.º 2
0
        public DetectorResult[] detectMulti(Dictionary <object, object> hints)
        {
            BitMatrix image = Image;
            MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);

            FinderPatternInfo[] info = finder.findMulti(hints);

            if (info == null || info.Length == 0)
            {
                throw ReaderException.Instance;
            }

            List <object> result = new List <object>();

            for (int i = 0; i < info.Length; i++)
            {
                try
                {
                    result.Add(processFinderPatternInfo(info[i]));
                }
                catch (ReaderException)
                {
                    // ignore
                }
            }
            if ((result.Count == 0))
            {
                return(EMPTY_DETECTOR_RESULTS);
            }
            else
            {
                DetectorResult[] resultArray = new DetectorResult[result.Count];
                for (int i = 0; i < result.Count; i++)
                {
                    resultArray[i] = (DetectorResult)result[i];
                }
                return(resultArray);
            }
        }
Ejemplo n.º 3
0
        // public DetectorResult[] detectMulti(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public DetectorResult[] detectMulti(System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            BitMatrix image = Image;
            MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);

            FinderPatternInfo[] info = finder.findMulti(hints);

            if (info == null || info.Length == 0)
            {
                throw ReaderException.Instance;
            }

            // System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
            System.Collections.Generic.List <Object> result = new System.Collections.Generic.List <Object>(10); // added by .net follower (http://dotnetfollower.com)
            for (int i = 0; i < info.Length; i++)
            {
                try
                {
                    result.Add(processFinderPatternInfo(info[i]));
                }
                catch (ReaderException e)
                {
                    // ignore
                }
            }
            if ((result.Count == 0))
            {
                return(EMPTY_DETECTOR_RESULTS);
            }
            else
            {
                DetectorResult[] resultArray = new DetectorResult[result.Count];
                for (int i = 0; i < result.Count; i++)
                {
                    resultArray[i] = (DetectorResult)result[i];
                }
                return(resultArray);
            }
        }
Ejemplo n.º 4
0
        public DetectorResult[] detectMulti(System.Collections.Hashtable hints)
        {
            BitMatrix image = Image;
            MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);

            FinderPatternInfo[] info = finder.findMulti(hints);

            if (info == null || info.Length == 0)
            {
                throw ReaderException.Instance;
            }

            System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            for (int i = 0; i < info.Length; i++)
            {
                try
                {
                    result.Add(processFinderPatternInfo(info[i]));
                }
                catch (ReaderException e)
                {
                    // ignore
                }
            }
            if ((result.Count == 0))
            {
                return(EMPTY_DETECTOR_RESULTS);
            }
            else
            {
                DetectorResult[] resultArray = new DetectorResult[result.Count];
                for (int i = 0; i < result.Count; i++)
                {
                    resultArray[i] = (DetectorResult)result[i];
                }
                return(resultArray);
            }
        }
Ejemplo n.º 5
0
		public DetectorResult[] detectMulti(System.Collections.Hashtable hints)
		{
			BitMatrix image = Image;
			MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);
			FinderPatternInfo[] info = finder.findMulti(hints);
			
			if (info == null || info.Length == 0)
			{
				throw ReaderException.Instance;
			}
			
			System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			for (int i = 0; i < info.Length; i++)
			{
				try
				{
					result.Add(processFinderPatternInfo(info[i]));
				}
				catch (ReaderException e)
				{
					// ignore
				}
			}
			if ((result.Count == 0))
			{
				return EMPTY_DETECTOR_RESULTS;
			}
			else
			{
				DetectorResult[] resultArray = new DetectorResult[result.Count];
				for (int i = 0; i < result.Count; i++)
				{
					resultArray[i] = (DetectorResult) result[i];
				}
				return resultArray;
			}
		}
Ejemplo n.º 6
0
        // added by .net follower (http://dotnetfollower.com)
        // public DetectorResult[] detectMulti(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public DetectorResult[] detectMulti(System.Collections.Generic.Dictionary<Object, Object> hints)
        {
            BitMatrix image = Image;
            MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);
            FinderPatternInfo[] info = finder.findMulti(hints);

            if (info == null || info.Length == 0)
            {
                throw ReaderException.Instance;
            }

            // System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
            System.Collections.Generic.List<Object> result = new System.Collections.Generic.List<Object>(10); // added by .net follower (http://dotnetfollower.com)
            for (int i = 0; i < info.Length; i++)
            {
                try
                {
                    result.Add(processFinderPatternInfo(info[i]));
                }
                catch (ReaderException e)
                {
                    // ignore
                }
            }
            if ((result.Count == 0))
            {
                return EMPTY_DETECTOR_RESULTS;
            }
            else
            {
                DetectorResult[] resultArray = new DetectorResult[result.Count];
                for (int i = 0; i < result.Count; i++)
                {
                    resultArray[i] = (DetectorResult) result[i];
                }
                return resultArray;
            }
        }
Ejemplo n.º 7
0
        public DetectorResult[] detectMulti(Dictionary<object, object> hints)
        {
            BitMatrix image = Image;
            MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image);
            FinderPatternInfo[] info = finder.findMulti(hints);

            if (info == null || info.Length == 0)
            {
                throw new Exception("ReaderException");
            }

            ArrayList result = new ArrayList();
            for (int i = 0; i < info.Length; i++)
            {
                try
                {
                    result.Add(processFinderPatternInfo(info[i]));
                }
                catch (Exception e)
                {
                    if (e.Message.IndexOf("ReaderException") < 0)
                        throw e;
                    // ignore
                }
            }
            if ((result.Count == 0))
            {
                return EMPTY_DETECTOR_RESULTS;
            }
            else
            {
                DetectorResult[] resultArray = new DetectorResult[result.Count];
                for (int i = 0; i < result.Count; i++)
                {
                    resultArray[i] = (DetectorResult) result[i];
                }
                return resultArray;
            }
        }