Example #1
0
        private void bNextImage_Click(object sender, RoutedEventArgs e)
        {
            currentImageIndex = (currentImageIndex + 1) % capturedImages.Count;

            Console.WriteLine("Processing File: {0}", files[currentImageIndex]);
            engine.ProcessImage(capturedImages[currentImageIndex]);
            SetThresholdImage();

            AnyImageProcessed = true;
        }
Example #2
0
        void target_FrameReceived(object sender, FrameReceivedEventArgs e)
        {
            imageAvailable = false;
            int paddingLeft, paddingRight;

            if (null == normalizedImage)
            {
                imageAvailable = e.TryGetRawImage(ImageType.Normalized,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Left,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Top,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Width,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Height,
                                                  out normalizedImage, out imageMetrics, out paddingLeft, out paddingRight);
            }
            else
            {
                imageAvailable = e.UpdateRawImage(ImageType.Normalized, normalizedImage,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Left,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Top,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Width,
                                                  Microsoft.Surface.Core.InteractiveSurface.DefaultInteractiveSurface.Height);
            }

            if (!imageAvailable)
            {
                return;
            }

            DisableRawImage();

            //System.IO.MemoryStream stream = new System.IO.MemoryStream(normalizedImage);
            //BmpBitmapDecoder decoder = new BmpBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
            //ImageSource source = decoder.Frames[0];
            //source.Freeze();
            //iCapturedFrame.Source = source;

            GCHandle h      = GCHandle.Alloc(normalizedImage, GCHandleType.Pinned);
            IntPtr   ptr    = h.AddrOfPinnedObject();
            Bitmap   bitmap = new Bitmap(imageMetrics.Width,
                                         imageMetrics.Height,
                                         imageMetrics.Stride,
                                         System.Drawing.Imaging.PixelFormat.Format8bppIndexed,
                                         ptr);

            Convert8bppBMPToGrayscale(bitmap);
            engine.ProcessImage(bitmap);

            imageAvailable = false;
            EnableRawImage();
        }