/// <summary> /// Event handler when the user clicks the Take a Photo button /// </summary> /// <param name='sender'> /// Sender /// </param> partial void takePhotoBtnClicked(MonoTouch.Foundation.NSObject sender) { Console.WriteLine("takePhotoBtnClicked"); picker = new MediaPicker(); // Check if a camera is available and photos are supported on this device if (!picker.IsCameraAvailable || !picker.PhotosSupported) { ShowUnsupported(); return; } // Call TakePhotoAsync, which gives us a Task<MediaFile> picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }) .ContinueWith(t => // Continue when the user has taken a photo { if (t.IsCanceled) // The user canceled { return; } // Show the photo the user took InvokeOnMainThread(delegate { UIImage image = UIImage.FromFile(t.Result.Path); this.imageView.Image = image; }); }); }
async void OpenImagePicker() { //It works? Don't use gallery var robotImagePicker = new MediaPicker(Forms.Context); await robotImagePicker.TakePhotoAsync(new StoreCameraMediaOptions { Name = data["teamNumber"].ToString() + ".jpg", Directory = "Robot Images" }).ContinueWith(t => { robotImageFile = t.Result; Console.WriteLine("Robot Image Path: " + robotImageFile.Path); }, TaskScheduler.FromCurrentSynchronizationContext()); robotImage.Source = robotImageFile.Path; try{ ParseFile image = new ParseFile(data["teamNumber"].ToString() + ".jpg", ImageToBinary(robotImageFile.Path)); data["robotImage"] = image; await data.SaveAsync(); popUpReturn(); } catch { Console.WriteLine("Image Save Error"); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var picker = new MediaPicker(); this.bntCamera.TouchUpInside += (sender, e) => { if (!picker.IsCameraAvailable) { lblSuccess.Text = "No camera!"; } else { picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }).ContinueWith(t => { if (t.IsCanceled) { lblSuccess.Text = "User cancelled"; return; } lblSuccess.Text = "Photo succeeded"; Console.WriteLine(t.Result.Path); }, TaskScheduler.FromCurrentSynchronizationContext()); } }; }
public void TakeAndStorePhoto(Action <string> onPhotoTaken) { var picker = new MediaPicker(); if (!picker.IsCameraAvailable || !picker.PhotosSupported) { MvxTrace.Trace(MvxTraceLevel.Diagnostic, "Photo taking not available"); return; } var photoName = string.Format("Sphero{0:yyyyMMddHHmmss}.jpg", DateTime.Now); picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = photoName, Directory = PictureFolder }) .ContinueWith(t => { if (t.IsCanceled) { return; } #warning Code to do... //var file = this.GetService<IMvxSimpleFileStoreService>(); //file.WriteFile(t.Result.Path, stream => t.Result.GetStream().CopyTo(stream)); //file.WriteFile("Test.txt", "Some text"); onPhotoTaken(t.Result.Path); }); }
async partial void OnTakePhoto() { var picker = new MediaPicker(); if (!picker.IsCameraAvailable) { await DisplayAlert("Error", "No Camera Available!", "OK"); } else { try { MediaFile file = await picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "photos", DefaultCamera = CameraDevice.Rear, }); Image image = new Image { Source = ImageSource.FromStream(file.GetStream) }; this.Content = image; } catch (OperationCanceledException ex) { Console.WriteLine("Operation canceled."); } } }
public async void TakePictureFromCamera() { var picker = new MediaPicker(); if (!picker.IsCameraAvailable) { System.Diagnostics.Debug.WriteLine("No camera!"); } else { try { MediaFile file = await picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "imported.jpg", Directory = "tmp" }); MessagingCenter.Send <IPictureTaker, string>(this, "pictureTaken", file.Path); System.Diagnostics.Debug.WriteLine(file.Path); } catch (OperationCanceledException) { System.Diagnostics.Debug.WriteLine("Canceled"); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.myButton); TextView label = FindViewById <TextView> (Resource.Id.lblSuccess); button.Click += delegate { var picker = new MediaPicker(this); if (!picker.IsCameraAvailable) { label.Text = "No camera!"; } else { picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }).ContinueWith(t => { if (t.IsCanceled) { label.Text = "User canceled"; return; } label.Text = "Photo succeeded"; Console.WriteLine(t.Result.Path); }, TaskScheduler.FromCurrentSynchronizationContext()); } }; }
void OnAlertDismissed(object sender, UIButtonEventArgs e) { switch (e.ButtonIndex) { case 0: picker.PickPhotoAsync() .ContinueWith(t => { if (t.IsCanceled) { return(null); } SetImage(t.Result.GetStream()); return(t.Result); }); break; case 1: picker.TakePhotoAsync(new StoreCameraMediaOptions()) .ContinueWith(t => { if (t.IsCanceled) { return(t.Result); } SetImage(t.Result.GetStream()); return(t.Result); }); break; default: break; } }
public void TakeAndStorePhoto(Action <string> onPhotoTaken) { var currentActivityService = this.GetService <IMvxAndroidCurrentTopActivity>(); var currentActivity = currentActivityService.Activity; var picker = new MediaPicker(currentActivity); if (!picker.IsCameraAvailable || !picker.PhotosSupported) { MvxTrace.Trace(MvxTraceLevel.Diagnostic, "Photo taking not available"); return; } var photoName = string.Format("Sphero{0:yyyyMMddHHmmss}.jpg", DateTime.Now); picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = photoName, Directory = PictureFolder }) .ContinueWith(t => { if (t.IsCanceled) { return; } onPhotoTaken(t.Result.Path); }); }
public async void TakePicture() { var context = MainApplication.CurrentContext as Activity; var picker = new MediaPicker(context); if (!picker.IsCameraAvailable) { Debug.WriteLine("No camera!"); } else { try { MediaFile file = await picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }); Debug.WriteLine(file.Path); MessagingCenter.Send <ICamera, string>(this, "camera", file.Path); } catch (OperationCanceledException) { Debug.WriteLine("Canceled"); } } }
async void PresentCamera() { var picker = new MediaPicker(Context); if (!picker.IsCameraAvailable) { System.Console.WriteLine("No camera!"); } else { try { // TakePhotoAsync is deprecated? var file = await picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "CouchbaseConnect", DefaultCamera = CameraDevice.Rear }); Console.WriteLine(file.Path); ((CameraContentPage)this.Element).Captured = file.Path; } catch (Exception e) { Console.WriteLine("Take Photo Cancelled."); } ((CameraContentPage)this.Element).IsPresented = false; } }
public static async Task ImagePicker(TeamData data, int imageInt) { MediaFile robotImageFile; String filePath = null; string fileName = null; //It works? Don't use gallery var robotImagePicker = new MediaPicker(Forms.Context); /* * var intent = robotImagePicker.GetTakePhotoUI(new StoreCameraMediaOptions { * Name = data.teamNumber.ToString() + ".jpg", * Directory = "Robot Images" * }).getre.ContinueWith(t => { * robotImageFile = t.Result; * filePath = robotImageFile.Path; * Console.WriteLine("Robot Image Path: " + filePath); * }, TaskScheduler.FromCurrentSynchronizationContext()); * //*/ try { await robotImagePicker.TakePhotoAsync(new StoreCameraMediaOptions { Name = data.teamNumber + "_IMG" + imageInt + ".jpg", Directory = "Robot Images" }).ContinueWith(t => { fileName = data.teamNumber.ToString() + "_IMG" + imageInt + ".jpg"; Console.WriteLine("Filename: " + fileName); robotImageFile = t.Result; filePath = robotImageFile.Path; Console.WriteLine("Robot Image Path: " + filePath); }); fileName = data.teamNumber + "_IMG" + imageInt + ".jpg"; var stream = new MemoryStream(ImageToBinary(filePath)); var storage = new FirebaseStorage(GlobalVariables.firebaseStorageURL); var send = storage.Child(GlobalVariables.regionalPointer) .Child(data.teamNumber.ToString()) .Child(fileName) .PutAsync(stream); var downloadURL = await send; Console.WriteLine("URL: " + downloadURL); /* * var db = new FirebaseClient(GlobalVariables.firebaseURL); * * var saveURL = db * .Child(GlobalVariables.regionalPointer) * .Child("teamData") * .Child(data.teamNumber.ToString()) * .Child("imageURL") * .PutAsync(downloadURL); */ } catch (Exception ex) { Console.WriteLine("Image Upload Image: " + ex); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.buttonLocation); LabelLocation = FindViewById <TextView>(Resource.Id.locationLabel); image = FindViewById <ImageView>(Resource.Id.imagePhoto); button.Click += delegate { var locator = new Geolocator(this) { DesiredAccuracy = 50 }; locator.GetPositionAsync(timeout: 10000).ContinueWith(t => { var text = String.Format("Location : Lat: {0}, Long: {0}", t.Result.Latitude, t.Result.Longitude); this.RunOnUiThread(() => LabelLocation.Text = text); }); }; Button getimge = FindViewById <Button>(Resource.Id.buttonCamera); getimge.Click += delegate { var camera = new MediaPicker(this); if (!camera.IsCameraAvailable) { Console.WriteLine("Camera unavailable!"); return; } var opts = new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MiniHackDemo" }; camera.TakePhotoAsync(opts).ContinueWith(t => { if (t.IsCanceled) { return; } using (var bmp = Android.Graphics.BitmapFactory.DecodeFile(t.Result.Path)) { this.RunOnUiThread(() => image.SetImageBitmap(bmp)); } }); }; }
public async void Capture() { var picker = new MediaPicker(); var mediaFile = await picker.TakePhotoAsync(new StoreCameraMediaOptions { DefaultCamera = CameraDevice.Rear }); MessagingCenter.Send <IPhotoCapture, Stream>(this, "photoStreamCaptured", mediaFile.GetStream()); }
public Task <MediaFile> GetPhoto(bool takeNew) { #if MONOANDROID var activity = this.GetService <Cirrious.MvvmCross.Droid.Interfaces.IMvxAndroidCurrentTopActivity>(); var picker = new MediaPicker(activity.Activity); #else var picker = new MediaPicker(); #endif return(takeNew ? picker.TakePhotoAsync(new StoreCameraMediaOptions()) : picker.PickPhotoAsync()); }
private async Task <MediaFile> UseCamera(MediaPicker picker) { var fileName = DateTime.Now.Ticks + ".png"; return(await picker.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "temp", Name = fileName //DefaultCamera = CameraDevice.Rear })); }
public async Task<string> TakePhoto() { var file = await picker.TakePhotoAsync( new StoreCameraMediaOptions { Directory = "photos", Name = "photo.jpg", DefaultCamera = CameraDevice.Rear, }); return file.Path; }
private async void AddImage(object obj) { var mediaPicker = new MediaPicker(App.UIContext); var photo = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions()); MobileServiceFile file = await this.itemManager.AddImage(this.todoItem, photo.Path); var image = new TodoItemImageViewModel(file, this.todoItem, DeleteImage); this.images.Add(image); }
public void CapturePhoto(string date, Action Ready) { var picker = new MediaPicker(); picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = String.Format("{0}.png", date), Directory = "TemporaryFiles" }).ContinueWith(t => { var Image = UIImage.FromFile(t.Result.Path); Image.SaveToPhotosAlbum((image, error) => {}); SaveFileToMedialibrary(t.Result, ".png", () => Ready()); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public async void CapturarFoto() { var capturar = new MediaPicker(); MediaFile mediaPath; if (capturar.IsCameraAvailable) { mediaPath = await capturar.TakePhotoAsync(new StoreCameraMediaOptions { DefaultCamera = CameraDevice.Rear, Name = string.Format("foto_{0}.jpg", DateTime.Now.ToString()), Directory = "Fiap" }); } }
public async Task <string> TakePhotoAsync(object context) { try { var uiContext = context as Context; if (uiContext != null) { var mediaPicker = new MediaPicker(uiContext); var photo = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions()); return(photo.Path); } } catch (TaskCanceledException) { } return(null); }
public PhotoAlertSheet() { picker = new MediaPicker(); AddButton("Photo Library"); if (picker.IsCameraAvailable) { AddButton("Camera"); } Dismissed += (sender, e) => { switch (e.ButtonIndex) { case 0: picker.PickPhotoAsync() .ContinueWith(t => { if (t.IsCanceled) { return(null); } SetImage(t.Result.GetStream()); return(t.Result); }); break; case 1: picker.TakePhotoAsync(new StoreCameraMediaOptions()) .ContinueWith(t => { if (t.IsCanceled) { return(t.Result); } SetImage(t.Result.GetStream()); return(t.Result); }); break; default: break; } }; }
private async void CameraIconPressed(object sender, EventArgs e) { //use the Xamarin.Media library to take the picture //it's cross platform and allows for quick access for taking picutres //would want to use native calls if you need customized solution var picturePicker = new MediaPicker(); if (!picturePicker.IsCameraAvailable) { //show alert that no camera is available var alert = UIAlertController.Create("Error", "Sorry I tried to access the camera on your device, but your device told me you don't have one. I can't take a picture without one.", UIAlertControllerStyle.Alert); //add in the ok button alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); //show the alert dialog on the UI PresentViewController(alert, true, null); } else { try { var media = await picturePicker.TakePhotoAsync(new StoreCameraMediaOptions { Name = string.Format("test_picture_{0}.jpg", DateTime.Now), Directory = "CameraExample" }); if (media != null) { _files.Add(media.Path); this.TableView.ReloadData(); } } catch (OperationCanceledException operationCancelledException) { //TODO log they cancelled taking the picture System.Console.WriteLine(operationCancelledException); } catch (System.Exception ex) { System.Console.WriteLine(ex.StackTrace); } } }
public static void PictureFromCamera(MediaPicker picker, Action <MediaFile> callback) { if (!picker.IsCameraAvailable || !picker.PhotosSupported) { //ToDo: How to handle unsupported return; } picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = string.Format("photo{0}.jpg", Guid.NewGuid()), Directory = "LB" }).ContinueWith(t => { if (t.IsCanceled) { return; } callback(t.Result); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); buttonLocation.TouchUpInside += (sender, e) => { var locator = new Geolocator { DesiredAccuracy = 50 }; locator.GetPositionAsync(timeout: 10000).ContinueWith(t => { var text = String.Format("Lat: {0}, Long: {0}", t.Result.Latitude, t.Result.Longitude); InvokeOnMainThread(() => LabelLocation.Text = text); }); }; buttonPicture.TouchUpInside += (sender, e) => { var camera = new MediaPicker(); if (!camera.IsCameraAvailable) { Console.WriteLine("Camera unavailable!"); return; } var opts = new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MiniHackDemo" }; camera.TakePhotoAsync(opts).ContinueWith(t => { if (t.IsCanceled) { return; } InvokeOnMainThread(() => imagePhoto.Image = UIImage.FromFile(t.Result.Path)); }); }; }
/* * private Image<Bgr, Byte> EnforceMaxSize(Image<Bgr, Byte> image, int maxWidth, int maxHeight) * { * if (image.Width > maxWidth || image.Height > maxHeight) * { * Image<Bgr, Byte> result = image.Resize(maxWidth, maxHeight, Emgu.CV.CvEnum.INTER.CV_INTER_NN, true); * image.Dispose(); * return result; * } * else * return image; * }*/ public Image <Bgr, Byte> PickImage(String defaultImageName) { if (_mediaPicker == null) { _mediaPicker = new MediaPicker(this); } String negative = _mediaPicker.IsCameraAvailable ? "Camera" : "Cancel"; int result = GetUserResponse(this, "Use Image from", "Default", "Photo Library", negative); if (result > 0) { return(new Image <Bgr, byte>(Assets, defaultImageName)); } else if (result == 0) { return(GetImageFromTask(_mediaPicker.PickPhotoAsync(), 800, 800)); } else if (_mediaPicker.IsCameraAvailable) { return(GetImageFromTask(_mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions()), 800, 800)); } return(null); }
public async Task <Stream> TakePhoto() { var picker = new MediaPicker(); if (!picker.IsCameraAvailable) { return(null); } MediaFile mf = null; try { mf = await picker.TakePhotoAsync(new StoreCameraMediaOptions()); } catch (TaskCanceledException) { Debug.WriteLine("photo picker canceled"); } if (mf == null) { return(null); } return(mf.GetStream()); }
partial void PhotoButton_TouchUpInside(UIButton sender) { var picker = new MediaPicker(); // new MediaPicker (this); on Android if (!picker.IsCameraAvailable) { Console.WriteLine("No camera!"); } else { picker.TakePhotoAsync(new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }).ContinueWith(t => { if (t.IsCanceled) { Console.WriteLine("User canceled"); return; } Console.WriteLine(t.Result.Path); }); } }
public ExpenseViewModel() { picker = new MediaPicker(); assignmentViewModel = ServiceContainer.Resolve <AssignmentViewModel>(); addExpenseCommand = new DelegateCommand(async obj => { var expense = obj as Expense; if (expense != null) { SelectedExpense = expense; CanDelete = true; AddExpenseHeader = "Expense"; await LoadPhotoAsync(expense); } else { SelectedExpense = new Expense(); CanDelete = false; AddExpenseHeader = "Add Expense"; Photo = new ExpensePhoto(); } if (addExpensePopUp != null && addExpensePopUp.IsOpen) { addExpensePopUp.IsOpen = false; } addExpensePopUp = new Popup(); addExpensePopUp.Height = Window.Current.Bounds.Height; addExpensePopUp.Width = Constants.PopUpWidth; AddExpenseFlyoutPanel flyoutpanel = new AddExpenseFlyoutPanel(); flyoutpanel.Width = addExpensePopUp.Width; flyoutpanel.Height = addExpensePopUp.Height; addExpensePopUp.Child = flyoutpanel; addExpensePopUp.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - Constants.PopUpWidth); addExpensePopUp.SetValue(Canvas.TopProperty, 0); addExpensePopUp.IsOpen = true; }); saveExpenseCommand = new DelegateCommand(async _ => { selectedExpense.Cost = ExpenseCost.ToDecimal(CultureInfo.InvariantCulture); selectedExpense.AssignmentId = assignmentViewModel.SelectedAssignment.Id; var task = SaveExpenseAsync(assignmentViewModel.SelectedAssignment, SelectedExpense); if (Photo != null && Photo.Image != null) { task = task.ContinueWith(obj => { Photo.ExpenseId = SelectedExpense.Id; }); await SavePhotoAsync(); } await LoadExpensesAsync(assignmentViewModel.SelectedAssignment); addExpensePopUp.IsOpen = false; }); deleteExpenseCommand = new DelegateCommand(async _ => { await DeleteExpenseAsync(assignmentViewModel.SelectedAssignment, selectedExpense); await LoadExpensesAsync(assignmentViewModel.SelectedAssignment); addExpensePopUp.IsOpen = false; }); cancelExpenseCommand = new DelegateCommand(_ => { addExpensePopUp.IsOpen = false; }); addImageCommand = new DelegateCommand(async _ => { bool cameraCommand = false, imageCommand = false; var dialog = new MessageDialog("Take picture with your built in camera or select one from your photo library.", "Add Image"); if (picker.IsCameraAvailable) { dialog.Commands.Add(new UICommand("Camera", new UICommandInvokedHandler(q => cameraCommand = true))); } dialog.Commands.Add(new UICommand("Library", new UICommandInvokedHandler(q => imageCommand = true))); await dialog.ShowAsync(); if (cameraCommand) { try { var mediaFile = await picker.TakePhotoAsync(new StoreCameraMediaOptions()); var photo = await mediaFile.GetStream().LoadBytes(); if (Photo == null) { Photo = new ExpensePhoto { ExpenseId = SelectedExpense.Id } } ; Photo.Image = photo; OnPropertyChanged("Photo"); } catch (Exception exc) { Debug.WriteLine(exc.Message); //this could happen if they cancel, etc. } } else if (imageCommand) { try { var mediaFile = await picker.PickPhotoAsync(); var photo = await mediaFile.GetStream().LoadBytes(); if (Photo == null) { Photo = new ExpensePhoto { ExpenseId = SelectedExpense.Id } } ; Photo.Image = photo; OnPropertyChanged("Photo"); } catch (Exception exc) { Debug.WriteLine(exc.Message); //this could happen if they cancel, etc. } } }); }
void MediaChooser (object sender, UIButtonEventArgs e) { if (e.ButtonIndex == 1) { System.Console.WriteLine ("Camera"); var picker = new MediaPicker (); // new MediaPicker (this); on Android if (!picker.IsCameraAvailable) { Console.WriteLine("No camera!"); } else { picker.TakePhotoAsync ( new StoreCameraMediaOptions { Name = "test.jpg" , Directory = "MediaPickerSample" } ).ContinueWith ( t => { if (t.IsCanceled) { Console.WriteLine ("User canceled"); return; } Console.WriteLine (t.Result.Path); imageView.Image = new UIImage(t.Result.Path); } , TaskScheduler.FromCurrentSynchronizationContext() ); } image_bytes = UIImageViewToByteArray(imageView.Image); image.Dispose (); } else if (e.ButtonIndex == 2) { System.Console.WriteLine ("Library"); var picker = new MediaPicker (); // new MediaPicker (this); on Android picker.PickPhotoAsync() .ContinueWith (t => { if (t.IsCanceled) { Console.WriteLine ("User canceled"); return; } Console.WriteLine (t.Result.Path); imageView.Image = new UIImage(t.Result.Path); }, TaskScheduler.FromCurrentSynchronizationContext()); } //MOKEEEEEEEEE UIImage To ByteArray image = imageView.Image; image_bytes = UIImageViewToByteArray(image); image.Dispose (); }
public async void LoadImage(String imageName) { #if NETFX_CORE Mat m = CvInvoke.Imread(imageName, LoadImageType.AnyColor); InvokeOnImageLoaded(m); #else if (_mediaPicker == null) { #if __ANDROID__ _mediaPicker = new MediaPicker(Forms.Context); #else _mediaPicker = new MediaPicker(); #endif } var action = await(_mediaPicker.IsCameraAvailable? DisplayActionSheet("Use Image from", "Cancel", null, "Default", "Photo Library", "Camera") : DisplayActionSheet("Use Image from", "Cancel", null, "Default", "Photo Library")); if (action.Equals("Default")) { #if __ANDROID__ InvokeOnImageLoaded(new Mat(Forms.Context.Assets, imageName)); #else Mat m = CvInvoke.Imread(imageName, LoadImageType.AnyColor); InvokeOnImageLoaded(m); #endif } else if (action.Equals("Photo Library")) { #if __ANDROID__ Android.Content.Intent intent = _mediaPicker.GetPickPhotoUI(); Android.App.Activity activity = Forms.Context as Android.App.Activity; activity.StartActivityForResult(intent, PickImageRequestCode); //once the image was picked, the MainActivity.OnActivityResult function will handle the remaining work flow #else var file = await _mediaPicker.PickPhotoAsync(); using (Stream s = file.GetStream()) using (MemoryStream ms = new MemoryStream()) { s.CopyTo(ms); byte[] data = ms.ToArray(); Mat m = new Mat(); CvInvoke.Imdecode(data, LoadImageType.Color, m); InvokeOnImageLoaded(m); } #endif } else if (action.Equals("Camera")) { #if __ANDROID__ Android.Content.Intent intent = _mediaPicker.GetTakePhotoUI(new StoreCameraMediaOptions()); Android.App.Activity activity = Forms.Context as Android.App.Activity; activity.StartActivityForResult(intent, PickImageRequestCode); //once the image was picked, the MainActivity.OnActivityResult function will handle the remaining work flow #else var file = await _mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions()); using (Stream s = file.GetStream()) using (MemoryStream ms = new MemoryStream()) { s.CopyTo(ms); byte[] data = ms.ToArray(); Mat m = new Mat(); CvInvoke.Imdecode(data, LoadImageType.Color, m); InvokeOnImageLoaded(m); } #endif } #endif }