Esempio n. 1
0
        private void Video_NewFrame(object source, NewCameraFrameEventArgs e)
        {
            try
            {
                if (IsLoadingCameraStream)
                {
                    this.IsLoadingCameraStream = false;
                }

                BitmapImage bi;

                using (var bitmap = e.GetBitmap())
                {
                    bi = BitmapHelper.Bitmap2BitmapImage(bitmap);
                }

                bi.Freeze(); // avoid cross thread operations and prevents leaks

                this.DisplayStream = bi;
            }
            catch (VideoException exc)
            {
                this.videoManager.StopCamera();
                this.DisplayStream = null;
            }
        }
Esempio n. 2
0
        private void Video_NewFrame(object source, NewCameraFrameEventArgs e)
        {
            try
            {
                if (IsLoadingCameraStream)
                {
                    this.IsLoadingCameraStream = false;
                }

                BitmapImage bi;

                using (var bitmap = e.GetBitmap())
                {
                    Bitmap trackBitmap = this.faceDetectionManager.FaceTracking(bitmap);

                    List <Point> first = new List <Point>();
                    List <Point> last  = new List <Point>();

                    Rectangle rect = this.faceDetectionManager.FaceTracked;
                    first.Add(new Point(rect.X, rect.Y));
                    last.Add(new Point(rect.X + rect.Width, rect.Y + rect.Height));


                    Bitmap encryptedImage = CryptingLib.Algorithm.EncryptingAlgorithm.EncryptImage(trackBitmap, first, last);

                    bi = BitmapHelper.Bitmap2BitmapImage(encryptedImage);
                    //bi = BitmapHelper.Bitmap2BitmapImage(this.faceDetectionManager.FaceTracking(bitmap));
                }

                bi.Freeze(); // avoid cross thread operations and prevents leaks

                this.DisplayStream = bi;
            }
            catch (AForge.Video.VideoException exc)
            {
                this.videoManager.StopCamera();
                this.DisplayStream = null;
            }
        }