コード例 #1
0
        public RGBLuminanceSource(byte[] d, int W, int H, RGBLuminanceSource.BitmapFormat format)
            : base(W, H)
        {
            __width  = W;
            __height = H;
            int width  = W;
            int height = H;

            // In order to measure pure decoding speed, we convert the entire image to a greyscale array
            // up front, which is the same as the Y channel of the YUVLuminanceSource in the real app.
            luminances = new byte[width * height];
            for (int y = 0; y < height; y++)
            {
                int offset = y * width;
                for (int x = 0; x < width; x++)
                {
                    int b = d[offset * 4 + x * 4];
                    int g = d[offset * 4 + x * 4 + 1];
                    int r = d[offset * 4 + x * 4 + 2];
                    if (r == g && g == b)
                    {
                        // Image is already greyscale, so pick any channel.
                        luminances[offset + x] = (byte)r;
                    }
                    else
                    {
                        // Calculate luminance cheaply, favoring green.
                        luminances[offset + x] = (byte)((r + g + g + b) >> 2);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Decodes the specified barcode bitmap.
        /// </summary>
        /// <param name="rawRGB">The image as byte[] array.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="format">The format.</param>
        /// <returns>
        /// the result data or null
        /// </returns>
        public Result[] DecodeMultiple(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format)
        {
            if (rawRGB == null)
                throw new ArgumentNullException("rawRGB");

            var luminanceSource = createRGBLuminanceSource(rawRGB, width, height, format);

            return DecodeMultiple(luminanceSource);
        }
コード例 #3
0
        public VuforiaQRTokenScanner()
        {
            m_barcodeReader = new BarcodeReader();


#if UNITY_EDITOR
            m_pixelFormat  = Image.PIXEL_FORMAT.GRAYSCALE; // Need Grayscale for Editor
            m_bitmapFormat = RGBLuminanceSource.BitmapFormat.Gray8;
#else
            m_pixelFormat  = Image.PIXEL_FORMAT.RGB888; // Use RGB888 for mobile
            m_bitmapFormat = RGBLuminanceSource.BitmapFormat.RGB24;
#endif
        }