Example #1
0
            public static Windows.Graphics.Imaging.SoftwareBitmap FromSoftwareBitmap(Windows.Graphics.Imaging.SoftwareBitmap bitmap)
            {
                var copy = new Windows.Graphics.Imaging.SoftwareBitmap(bitmap.BitmapPixelFormat, bitmap.PixelWidth, bitmap.PixelHeight);

                bitmap.CopyTo(copy);
                return(copy);
            }
Example #2
0
        public void ProcessFrame(ProcessVideoFrameContext context)
        {
            if (context.InputFrame.SoftwareBitmap == null)
                return;

            var softwarebitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, context.InputFrame.SoftwareBitmap.PixelWidth, context.InputFrame.SoftwareBitmap.PixelHeight, context.OutputFrame.SoftwareBitmap.BitmapAlphaMode);
            context.InputFrame.SoftwareBitmap.CopyTo(softwarebitmap);

            recognizer.Treshold = (double)_configuration["tolerance"];
            recognizer.Hue = (int)_configuration["hue"];

            var result = recognizer.Recognize(softwarebitmap);
            var s = string.Empty;
            if (result != null)
            {
                for (int i = 0; i < result.GetLength(0); i++)
                {
                    for (int j = 0; j < result.GetLength(1); j++)
                    {
                        var t = result[i, j];
                        s += t == 0 ? " 0" : t.ToString();
                        s += ' ';
                    }
                    s += Environment.NewLine;
                }
            }

            if (result != null)
            {
                prevCount = 0;
                var matrix = new int[10, 10]
            {
                {   0,  0, -1,  0,  0,  0,  0, -1,  0,  0 },
                {   0,  0, -1,  0,  0,  0,  0, -1,  0,  0 },
                {  -1, -1, -1,  0,  0, -1,  0, -1,  0,  0 },
                {   0,  0, -1,  0, -1, -1, -1, -1, -1, -1 },
                {   0,  0, -1,  0,  0, -1,  0, -1,  0,  0 },
                {   0,  0, -1,  0,  0, -1,  0, -1,  0,  0 },
                {   0,  0, -1,  0,  0, -1,  0,  0,  0,  0 },
                {  -1, -1, -1, -1, -1, -1,  0, -1,  0,  0 },
                {   0,  0, -1,  0,  0,  0,  0,  0,  0,  0 },
                {   0,  0, -1,  0,  0,  0,  0,  0,  0,  0 },
            };

                var test = solver.Test(matrix, 10, 10);
                char[,] solvedCrossword = null;
                if (test)
                {
                    solvedCrossword = solver.FirstTest(10, 10);

                    //var s = string.Empty;
                    //for (int i = 0; i < solvedCrossword.GetLength(0); i++)
                    //{
                    //	for (int j = 0; j < solvedCrossword.GetLength(1); j++)
                    //	{
                    //		var t = solvedCrossword[i, j];
                    //		s += (t == '\0') ? '*' : t;
                    //	}
                    //	s += Environment.NewLine;
                    //}
                }
            }

            if (prevValue == recognizer.DetectedCenters.Count)
                prevCount++;
            _configuration["result"] = recognizer.DetectedCenters.Count;
            _configuration["centers"] = recognizer.DetectedCenters;
            prevValue = recognizer.DetectedCenters.Count;

            softwarebitmap.CopyTo(context.OutputFrame.SoftwareBitmap);
        }