Пример #1
0
        public async Task TakePicture()
        {
            if (!CrossMedia.Current.IsCameraAvailable ||
                !CrossMedia.Current.IsTakePhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert("No Camera",
                                                                "Sorry! No camera available.", "OK");

                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new
                                                               Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory   = "TestPhotoFolder",
                SaveToAlbum = true,
                PhotoSize   = PhotoSize.Medium,
            });

            if (file == null)
            {
                IsVisible = false;
                return;
            }

            this.Source = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                return(stream);
            });
            ListImage.Add(Source);
        }
        public override LearningImage BackProject(LearningImage i)
        {
            int Scale = this.Scale;
            ListImage li = new ListImage(i.Height * Scale + Height, i.Width * Scale + Width);
            for (int h = 0; h < i.Height; h++)
            {
                for (int w = 0; w < i.Width; w++)
                {
                    LearningImage trimed = i.Trim(new Rectangle(w, h, 1, 1));
                    LearningImage pasting = base.BackProject(trimed);
                    for (int hh = 0; hh < pasting.Height; hh++)
                        for (int ww = 0; ww < pasting.Width; ww++)
                            li.Add(h * Scale + hh, w * Scale + ww, pasting.GetPlane(hh, ww));
                }
            }

            LearningImage o = new LearningImage(i.Height * Scale, i.Width * Scale, this.FrameIn.Plane);
            for (int h = 0; h < o.Height; h++)
                for (int w = 0; w < o.Width; w++)
                    o.SetPlane(h, w, li.Median(h + Height / 2, w + Width / 2));
            return o;
        }
Пример #3
0
        public async Task GetPhoto()
        {
            if (!CrossMedia.Current.IsTakePhotoSupported)
            {
                return;
            }

            var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
            {
                PhotoSize = PhotoSize.Medium,
            });

            if (file == null)
            {
                IsVisible = false;
                return;
            }
            this.Source = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                return(stream);
            });
            ListImage.Add(Source);
        }