Ejemplo n.º 1
0
        private async void OnPostProcessCompleteAsync(
            byte[] pixelArray, int imageWidth, int imageHeight,
            ObjectDetails fromObjectDetails, ObjectDetails toObjectDetails)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                WriteableBitmap bitmap = await ImageProcessingUtils.PixelArrayToWriteableBitmapAsync(pixelArray, imageWidth, imageHeight);

                if (bitmap != null)
                {
                }
            });
        }
Ejemplo n.º 2
0
        private async void OnFrameCapturedAsync(byte[] pixelArray, int frameWidth, int frameHeight, int frameId)
        {
            _videoEngine.Messenger.FrameCaptured -= OnFrameCapturedAsync;
            System.Diagnostics.Debug.WriteLine("OnFrameCapturedAsync");

            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                Wbitmap = await ImageProcessingUtils.PixelArrayToWriteableBitmapAsync(pixelArray, frameWidth, frameHeight);

                if (Wbitmap != null)
                {
                    CapturePhoto(Wbitmap);
                }

                _videoEngine.Messenger.FrameCaptured += OnFrameCapturedAsync;
            });
        }
Ejemplo n.º 3
0
        private async void OnFrameCapturedAsync(byte[] pixelArray, int frameWidth, int frameHeight, int frameId)
        {
            _videoEngine.Messenger.FrameCaptured -= OnFrameCapturedAsync;
            System.Diagnostics.Debug.WriteLine("OnFrameCapturedAsync");

            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                WriteableBitmap bitmap = await ImageProcessingUtils.PixelArrayToWriteableBitmapAsync(pixelArray, frameWidth, frameHeight);

                if (bitmap != null)
                {
                    capturedPhotoImage.Source = bitmap;
                    bitmap.Invalidate();
                    capturedPhotoImage.Visibility = Visibility.Visible;

                    if (frameId == ColorPickFrameRequestId)
                    {
                        int scaledWidth = (int)(_videoEngine.ResolutionWidth *viewfinderCanvas.ActualHeight / _videoEngine.ResolutionHeight);
                        int pointX      = (int)(((_viewFinderCanvasTappedPoint.X - (viewfinderCanvas.ActualWidth - scaledWidth) / 2) / scaledWidth) * frameWidth);
                        int pointY      = (int)((_viewFinderCanvasTappedPoint.Y / viewfinderCanvas.ActualHeight) * frameHeight);

                        SetColor(ImageProcessingUtils.GetColorAtPoint(
                                     bitmap, (uint)frameWidth, (uint)frameHeight, new Point()
                        {
                            X = pointX, Y = pointY
                        }));
                    }

                    if (_hideCapturePhotoImageTimer != null)
                    {
                        _hideCapturePhotoImageTimer.Dispose();
                        _hideCapturePhotoImageTimer = null;
                    }

                    _hideCapturePhotoImageTimer = new Timer(HideCapturedPhotoImageAsync, null, 8000, Timeout.Infinite);
                }

                _videoEngine.Messenger.FrameCaptured += OnFrameCapturedAsync;
            });
        }
Ejemplo n.º 4
0
        private async void OnPostProcessCompleteAsync(
            byte[] pixelArray, int imageWidth, int imageHeight,
            ObjectDetails fromObjectDetails, ObjectDetails toObjectDetails)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                WriteableBitmap bitmap = await ImageProcessingUtils.PixelArrayToWriteableBitmapAsync(pixelArray, imageWidth, imageHeight);

                if (bitmap != null)
                {
                    processingResultImage.Source = bitmap;
                    bitmap.Invalidate();

                    if (fromObjectDetails.centerX > toObjectDetails.centerX) // TODO This is wrong, but the problem is in BufferTransform
                    {
                        imageLeftSideLabel.Text  = "1";
                        imageRightSideLabel.Text = "2";
                    }
                    else
                    {
                        imageLeftSideLabel.Text  = "2";
                        imageRightSideLabel.Text = "1";
                    }

                    if (imageWidth > 0)
                    {
                        SetRectangleSizeAndPositionBasedOnObjectDetails(
                            ref firstRectangle, ref firstRectangleTranslateTransform,
                            processingResultImage, fromObjectDetails);

                        SetRectangleSizeAndPositionBasedOnObjectDetails(
                            ref secondRectangle, ref secondRectangleTranslateTransform,
                            processingResultImage, toObjectDetails);
                    }

                    processingResultGrid.Visibility = Visibility.Visible;
                }
            });
        }