Ejemplo n.º 1
0
        private void BrowseForUnitVideo()
        {
            string filePath = FileBrowser.BroseForVideoFiles();

            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }

            using (IVideo video = ModelResolver.Resolve <IVideo>())
            {
                video.SetVideo(filePath);

                using (Image <Bgr, Byte> image = video.GetFrameImage())
                {
                    Image = image.ToBitmap();

                    PickUnitsPointsViewModel viewModel = new PickUnitsPointsViewModel(Image);
                    PickUnitsPointsView      view      = new PickUnitsPointsView()
                    {
                        DataContext = viewModel,
                    };

                    view.ShowDialog();

                    if (viewModel.OkPressed)
                    {
                        PixelDistance = viewModel.GetDistance();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SelectUnits()
        {
            string location = FileBrowser.BrowseForFile("Video|*.avi;*.mpg;*.mpeg;*.mp4;*.mov|Image|*.jpg;*.jpeg*.bmp;*.png");

            if (string.IsNullOrWhiteSpace(location))
            {
                return;
            }

            string ext = Path.GetExtension(location);
            Bitmap bitmap;

            if (ext.Contains("avi") || ext.Contains("mpg") || ext.Contains("mpeg") || ext.Contains("mov"))
            {
                //Is video file
                using (IVideo video = ModelResolver.Resolve <IVideo>())
                {
                    video.SetVideo(location);
                    using (Image <Bgr, Byte> image = video.GetFrameImage())
                    {
                        bitmap = new Bitmap(image.Bitmap);
                    }
                }
            }
            else
            {
                //Is image file
                bitmap = new Bitmap(location);
            }

            PickUnitsPointsView      view      = new PickUnitsPointsView();
            PickUnitsPointsViewModel viewModel = new PickUnitsPointsViewModel(bitmap);

            view.DataContext = viewModel;
            view.ShowDialog();

            if (viewModel.ExitResult != WindowExitResult.Ok)
            {
                return;
            }

            UnitsToMm = viewModel.UnitsToMm;
        }