public void WillBeginCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
     if (resolvedSettings.LivePhotoMovieDimensions.Width > 0 && resolvedSettings.LivePhotoMovieDimensions.Height > 0)
     {
         capturingLivePhoto(true);
     }
 }
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                             CMSampleBuffer photoSampleBuffer,
                                             CMSampleBuffer previewPhotoSampleBuffer,
                                             AVCaptureResolvedPhotoSettings resolvedSettings,
                                             AVCaptureBracketedStillImageSettings bracketSettings,
                                             NSError error)
        {
            if (photoSampleBuffer == null || error != null)
            {
                Console.WriteLine("Error taking photo: " + error);
                return;
            }

            NSData imageData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);

            SetPaths(".jpg");

            UIImage formattedImg = AppUtils.ScaleAndRotateImage(UIImage.LoadFromData(imageData));

            imageData = formattedImg.AsJPEG(0.8f);

            if (imageData.Save(filePath, false, out NSError saveErr))
            {
                Console.WriteLine("Saved photo to: " + filePath);
                ReturnWithData(innerPath);
            }
            else
            {
                Console.WriteLine("ERROR saving to " + fileName + " because " + saveErr.LocalizedDescription);
            }
        }
		public void DidFinishProcessingPhoto (AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
		{
			if (photoSampleBuffer != null)
				photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation (photoSampleBuffer, previewPhotoSampleBuffer);
			else
				Console.WriteLine ($"Error capturing photo: {error.LocalizedDescription}");
		}
Example #4
0
 public virtual void WillBeginCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
     if ((resolvedSettings.LivePhotoMovieDimensions.Width > 0) && (resolvedSettings.LivePhotoMovieDimensions.Height > 0))
     {
         LivePhotoCaptureHandler(true);
     }
 }
Example #5
0
 // ReSharper disable once UnusedMember.Local
 private void PhotoJustGotCaptured(AVCapturePhotoOutput photoOutput, AVCaptureResolvedPhotoSettings settings)
 {
     if (_cameraModule.BluetoothOperator.IsPrimary ||
         _cameraModule.BluetoothOperator.PairStatus != PairStatus.Connected)
     {
         _cameraModule.CaptureSuccess = !_cameraModule.CaptureSuccess;
     }
 }
		public void DidFinishProcessingLivePhotoMovie (AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, CMTime duration, CMTime photoDisplayTime, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
		{
			if (error != null) {
				Console.WriteLine ($"Error processing live photo companion movie: {error.LocalizedDescription})");
				return;
			}

			livePhotoCompanionMovieUrl = outputFileUrl;
		}
Example #7
0
 public override void DidFinishCapture(AVCapturePhotoOutput captureOutput,
                                       AVCaptureResolvedPhotoSettings resolvedSettings,
                                       NSError error)
 {
     if (ShouldSaveCaptureResult(error))
     {
         PHAssetManager.PerformChangesWithAuthorization(TryToAddPhotoToLibrary, null, DidFinish);
     }
 }
        public override void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error.LocalizedDescription})");
                DidFinish();
                return;
            }

            if (photoData == null)
            {
                Console.WriteLine("No photo data resource");
                DidFinish();
                return;
            }

            PHPhotoLibrary.RequestAuthorization(status =>
            {
                if (status == PHAuthorizationStatus.Authorized)
                {
                    PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() =>
                    {
                        var options = new PHAssetResourceCreationOptions
                        {
                            UniformTypeIdentifier = RequestedPhotoSettings.ProcessedFileType,
                        };

                        var creationRequest = PHAssetCreationRequest.CreationRequestForAsset();
                        creationRequest.AddResource(PHAssetResourceType.Photo, photoData, options);

                        var url = livePhotoCompanionMovieUrl;
                        if (url != null)
                        {
                            var livePhotoCompanionMovieFileResourceOptions = new PHAssetResourceCreationOptions
                            {
                                ShouldMoveFile = true
                            };
                            creationRequest.AddResource(PHAssetResourceType.PairedVideo, url, livePhotoCompanionMovieFileResourceOptions);
                        }
                    }, (success, err) =>
                    {
                        if (err != null)
                        {
                            Console.WriteLine($"Error occurered while saving photo to photo library: {error.LocalizedDescription}");
                        }
                        DidFinish();
                    });
                }
                else
                {
                    DidFinish();
                }
            });
        }
        // キャプチャー後処理
        public override void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error.LocalizedDescription})");
                return;
            }

            if (photoData == null)
            {
                Console.WriteLine("No photo data resource");
                return;
            }

            // 撮影したラベル画像をフォトアルバムに保存するか
            // フォトアルバムに保存する必要が出てきた真偽値をTrueにする
            bool IsSaveToPhotoAlbum = false;

            // 画像を保存するかどうかの判定
            if (IsSaveToPhotoAlbum)
            {
                // 撮影した画像を保存する処理
                PHPhotoLibrary.RequestAuthorization(status =>
                {
                    if (status == PHAuthorizationStatus.Authorized)
                    {
                        PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() =>
                        {
                            var creationRequest = PHAssetCreationRequest.CreationRequestForAsset();
                            creationRequest.AddResource(PHAssetResourceType.Photo, photoData, null);

                            var url = livePhotoCompanionMovieUrl;
                            if (url != null)
                            {
                                var livePhotoCompanionMovieFileResourceOptions = new PHAssetResourceCreationOptions
                                {
                                    ShouldMoveFile = true
                                };
                                creationRequest.AddResource(PHAssetResourceType.PairedVideo, url, livePhotoCompanionMovieFileResourceOptions);
                            }
                        }, (success, err) =>
                        {
                            if (err != null)
                            {
                                Console.WriteLine($"Error occurered while saving photo to photo library: {error.LocalizedDescription}");
                            }
                        });
                    }
                });
            }
        }
        public virtual void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error}", error);
            }

            if (PhotoData == null)
            {
                Console.WriteLine("No photo data resource");
            }

            CompletionHandler(imageBytes);
        }
Example #11
0
        public virtual void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error}", error);
                DidFinish();
                return;
            }

            if (PhotoData == null)
            {
                Console.WriteLine("No photo data resource");
                DidFinish();
                return;
            }

            DidFinish();
        }
Example #12
0
        public override void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                                      CMSampleBuffer photoSampleBuffer,
                                                      CMSampleBuffer previewPhotoSampleBuffer,
                                                      AVCaptureResolvedPhotoSettings resolvedSettings,
                                                      AVCaptureBracketedStillImageSettings bracketSettings,
                                                      NSError error)
        {
            if (photoSampleBuffer != null)
            {
                _photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Error capturing photo: {0}", error.LocalizedDescription));
            }

            PictureTaken?.Invoke(this, _photoData);
        }
        public void DidFinishProcessingPhoto(
            AVCapturePhotoOutput output,
            CMSampleBuffer buffer1,
            CMSampleBuffer buffer2,
            AVCaptureResolvedPhotoSettings resolvedPhotoSettings,
            AVCaptureBracketedStillImageSettings bracketedStillImageSettings,
            NSError error
            )
        {
            if (_photoCapturePath == null)
            {
                throw new ArgumentNullException(_photoCapturePath);
            }

            var data  = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(buffer1, buffer2);
            var bytes = data.ToArray();

            File.WriteAllBytes(_photoCapturePath, bytes);
            _photoCapturePath = null;
        }
		public void DidFinishCapture (AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
		{
			if (error != null) {
				Console.WriteLine ($"Error capturing photo: {error.LocalizedDescription})");
				DidFinish ();
				return;
			}

			if (photoData == null) {
				Console.WriteLine ("No photo data resource");
				DidFinish ();
				return;
			}

			PHPhotoLibrary.RequestAuthorization (status => {
				if (status == PHAuthorizationStatus.Authorized) {
					PHPhotoLibrary.SharedPhotoLibrary.PerformChanges (() => {
						var creationRequest = PHAssetCreationRequest.CreationRequestForAsset ();
						creationRequest.AddResource (PHAssetResourceType.Photo, photoData, null);

						var url = livePhotoCompanionMovieUrl;
						if (url != null) {
							var livePhotoCompanionMovieFileResourceOptions = new PHAssetResourceCreationOptions {
								ShouldMoveFile = true
							};
							creationRequest.AddResource (PHAssetResourceType.PairedVideo, url, livePhotoCompanionMovieFileResourceOptions);
						}
					}, (success, err) => {
						if (err != null)
							Console.WriteLine ($"Error occurered while saving photo to photo library: {error.LocalizedDescription}");
						DidFinish ();
					});
				} else {
					DidFinish ();
				}
			});
		}
Example #15
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, CMSampleBuffer finishedPhotoBuffer, CMSampleBuffer previewPhotoBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (finishedPhotoBuffer != null)
                {
                    LockPictureSpecificSettingsIfNothingCaptured();

                    using (var image = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(finishedPhotoBuffer, previewPhotoBuffer))
                        using (var imgDataProvider = new CGDataProvider(image))
                            using (var cgImage = CGImage.FromJPEG(imgDataProvider, null, false, CGColorRenderingIntent.Default))
                                using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                                {
                                    _cameraModule.CapturedImage = uiImage.AsJPEG().ToArray();
                                }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
                var photo    = UIImage.LoadFromData(jpegData);

                var inSampleSize = ImageHelper.CalculateInSampleSize(photo.Size, Core.Constants.PhotoMaxSize, Core.Constants.PhotoMaxSize);
                var deviceRatio  = Math.Round(UIScreen.MainScreen.Bounds.Width / UIScreen.MainScreen.Bounds.Height, 2);

                var x = ((float)inSampleSize.Width - Core.Constants.PhotoMaxSize * (float)deviceRatio) / 2f;
                photo = ImageHelper.CropImage(photo, x, 0, Core.Constants.PhotoMaxSize * (float)deviceRatio, Core.Constants.PhotoMaxSize, inSampleSize);
                GoToDescription(photo, orientationOnPhoto);
            }
            catch (Exception ex)
            {
                AppSettings.Reporter.SendCrash(ex);
                ShowAlert(Core.Localization.LocalizationKeys.PhotoProcessingError);
            }
        }
Example #17
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {/*
          * try
          * {
          *     using (var pixelBuffer = photoSampleBuffer.GetImageBuffer() as CVPixelBuffer)
          *     {
          *         pixelBuffer.Lock(CVPixelBufferLock.None);
          *         var j = CIImage.FromImageBuffer(pixelBuffer);
          *         pixelBuffer.Unlock(CVPixelBufferLock.None);
          *     }
          *
          *     using(var t = photoSampleBuffer.GetImageBuffer())
          *     {
          *
          *     }
          *
          *
          *     //var i = new CGAffineTransform();
          *     //i.Rotate(90);
          *
          *     //u = lol.ImageByApplyingTransform(y);
          *
          *     //var filter = CIFilter.GetFilter("CIAffineTransform", );
          *
          *
          * }
          * catch(Exception ex)
          * {
          *
          * }*/
            var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            var h        = UIImage.LoadFromData(jpegData);

            GoToDescription(h);
        }
 public void DidFinishRecordingLivePhotoMovie(AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
     capturingLivePhoto(false);
 }
 public void WillCapturePhoto(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
     willCapturePhotoAnimation();
 }
		void WillCapturePhoto (AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
		{
			DispatchQueue.MainQueue.DispatchAsync (() => {
				PreviewView.Layer.Opacity = 0;
				UIView.Animate (0.25, () => {
					PreviewView.Layer.Opacity = 1;
				});
			});
		}
Example #21
0
 public virtual void DidFinishRecordingLivePhotoMovie(AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
     LivePhotoCaptureHandler(false);
 }
		public void WillCapturePhoto (AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
		{
			willCapturePhotoAnimation ();
		}
		public void WillBeginCapture (AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
		{
			if (resolvedSettings.LivePhotoMovieDimensions.Width > 0 && resolvedSettings.LivePhotoMovieDimensions.Height > 0)
				capturingLivePhoto (true);
		}
 public virtual void WillCapturePhoto(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings)
 {
 }
Example #25
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, CMSampleBuffer finishedPhotoBuffer, CMSampleBuffer previewPhotoBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (finishedPhotoBuffer != null)
                {
                    if (!(_cameraModule.BluetoothOperator.PairStatus == PairStatus.Connected &&
                          !_cameraModule.BluetoothOperator.IsPrimary))
                    {
                        LockPictureSpecificSettingsIfApplicable();
                    }

                    using (var image = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(finishedPhotoBuffer, previewPhotoBuffer))
                        using (var imgDataProvider = new CGDataProvider(image))
                            using (var cgImage = CGImage.FromJPEG(imgDataProvider, null, false, CGColorRenderingIntent.Default))
                                using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                                {
                                    var imageBytes = uiImage.AsJPEG().ToArray();
                                    if (_cameraModule.BluetoothOperator.PairStatus == PairStatus.Connected &&
                                        !_cameraModule.BluetoothOperator.IsPrimary)
                                    {
                                        _cameraModule.BluetoothOperator.SendCapture(imageBytes);
                                    }
                                    else
                                    {
                                        _cameraModule.CapturedImage = imageBytes;
                                    }
                                }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
 public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     try
     {
         var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
         var photo    = UIImage.LoadFromData(jpegData);
         GoToDescription(photo, orientationOnPhoto);
     }
     catch (Exception ex)
     {
         AppSettings.Reporter.SendCrash(ex);
         ShowAlert(Core.Localization.LocalizationKeys.PhotoProcessingError);
     }
 }
 public virtual void DidFinishProcessingLivePhotoMovie(AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, CMTime duration, CMTime photoDisplayTime, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
 {
     if (error != null)
     {
         Console.WriteLine($"Error processing live photo companion movie: {error}", error);
         return;
     }
 }
Example #28
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CoreMedia.CMSampleBuffer photoSampleBuffer, CoreMedia.CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            var imageData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);

            if (imageData != null)
            {
                var capturedImage = new UIImage(imageData);


                var storyboard      = UIStoryboard.FromName("Main", NSBundle.MainBundle);
                UIViewController vc = new UIViewController();
                if (came_from == Constants.personal)
                {
                    CropCameraViewController.currentImage = capturedImage;
                    vc = storyboard.InstantiateViewController(nameof(CropCameraViewController));
                }
                else if (came_from == Constants.company_logo)
                {
                    CropCompanyLogoViewController.currentImage = capturedImage;
                    vc = storyboard.InstantiateViewController(nameof(CropCompanyLogoViewController));
                }

                this.NavigationController.PushViewController(vc, true);
            }
        }
Example #29
0
 // ReSharper disable once UnusedMember.Local
 private void PhotoJustGotCaptured(AVCapturePhotoOutput photoOutput, AVCaptureResolvedPhotoSettings settings)
 {
     _cameraModule.CaptureSuccess = !_cameraModule.CaptureSuccess;
 }
		void DidFinishProcessingPhoto (AVCapturePhotoOutput captureOutput,
									   CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer,
									   AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings,
									   NSError error)
		{
			if (photoSampleBuffer == null) {
				Console.WriteLine ($"Error occurred while capturing photo: {error}");
				return;
			}

			NSData imageData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation (photoSampleBuffer, previewPhotoSampleBuffer);
			PHPhotoLibrary.RequestAuthorization (status => {
				if (status == PHAuthorizationStatus.Authorized) {
					PHPhotoLibrary.SharedPhotoLibrary.PerformChanges (() => {
						PHAssetCreationRequest.CreationRequestForAsset ().AddResource (PHAssetResourceType.Photo, imageData, null);
					}, (success, err) => {
						if (!success) {
							Console.WriteLine ($"Error occurred while saving photo to photo library: {err}");
						} else {
							Console.WriteLine ("Photo was saved to photo library");
						}
					});
				} else {
					Console.WriteLine ("Not authorized to save photo");
				}
			});
		}
Example #31
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            var h        = UIImage.LoadFromData(jpegData);

            GoToDescription(h);
        }
Example #32
0
        public virtual async void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error}", error);
                DidFinish();
                return;
            }

            if (PhotoData == null)
            {
                Console.WriteLine("No photo data resource");
                DidFinish();
                return;
            }

            var status = await Photos.PHPhotoLibrary.RequestAuthorizationAsync();

            if (status == Photos.PHAuthorizationStatus.Authorized)
            {
                Photos.PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() =>
                {
                    var options = new Photos.PHAssetResourceCreationOptions();
                    options.UniformTypeIdentifier = RequestedPhotoSettings.ProcessedFileType();
                    var creationRequest           = Photos.PHAssetCreationRequest.CreationRequestForAsset();
                    creationRequest.AddResource(Photos.PHAssetResourceType.Photo, PhotoData, options);

                    if (LivePhotoCompanionMovieUrl != null)
                    {
                        var livePhotoCompanionMovieResourceOptions            = new Photos.PHAssetResourceCreationOptions();
                        livePhotoCompanionMovieResourceOptions.ShouldMoveFile = true;
                        creationRequest.AddResource(Photos.PHAssetResourceType.PairedVideo, LivePhotoCompanionMovieUrl, livePhotoCompanionMovieResourceOptions);
                    }
                }, (success, completeError) =>
                {
                    if (!success)
                    {
                        Console.WriteLine($"Error occurred while saving photo to photo library: {error}");
                    }

                    DidFinish();
                });
            }
            else
            {
                Console.WriteLine(@"Not authorized to save photo");
                DidFinish();
            }
        }
		public void DidFinishRecordingLivePhotoMovie (AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, AVCaptureResolvedPhotoSettings resolvedSettings)
		{
			capturingLivePhoto (false);
		}
Example #34
0
        public override void DidFinishProcessingLivePhotoMovie(AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl,
                                                               CMTime duration,
                                                               CMTime photoDisplayTime, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"photo capture delegate: error processing live photo companion movie: {error}");
                return;
            }

            _livePhotoCompanionMovieUrl = outputFileUrl;
        }
		void DidFinishProcessingRawPhoto (AVCapturePhotoOutput captureOutput,
										  CMSampleBuffer rawSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer,
										  AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings,
										  NSError error)
		{
			if (rawSampleBuffer == null) {
				Console.WriteLine ($"Error occurred while capturing photo: {error}");
				return;
			}

			var filePath = Path.Combine (Path.GetTempPath (), $"{resolvedSettings.UniqueID}.dng");
			NSData imageData = AVCapturePhotoOutput.GetDngPhotoDataRepresentation (rawSampleBuffer, previewPhotoSampleBuffer);
			imageData.Save (filePath, true);

			PHPhotoLibrary.RequestAuthorization (status => {
				if (status == PHAuthorizationStatus.Authorized) {
					PHPhotoLibrary.SharedPhotoLibrary.PerformChanges (() => {
						// In iOS 9 and later, it's possible to move the file into the photo library without duplicating the file data.
						// This avoids using double the disk space during save, which can make a difference on devices with limited free disk space.
						var options = new PHAssetResourceCreationOptions ();
						options.ShouldMoveFile = true;
						PHAssetCreationRequest.CreationRequestForAsset ().AddResource (PHAssetResourceType.Photo, filePath, options); // Add move (not copy) option
					}, (success, err) => {
						if (!success)
							Console.WriteLine ($"Error occurred while saving raw photo to photo library: {err}");
						else
							Console.WriteLine ("Raw photo was saved to photo library");

						NSError rErr;
						if (NSFileManager.DefaultManager.FileExists (filePath))
							NSFileManager.DefaultManager.Remove (filePath, out rErr);
					});
				} else {
					Console.WriteLine ("Not authorized to save photo");
				}
			});
		}
 public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     if (photoSampleBuffer != null)
     {
         photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
     }
     else
     {
         Console.WriteLine($"Error capturing photo: {error.LocalizedDescription}");
     }
 }
Example #37
0
 public void DidFinishCapture(AVCapturePhotoOutput captureOutput, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
 => OnFinishCapture(photoData, error);
        public void DidFinishProcessingLivePhotoMovie(AVCapturePhotoOutput captureOutput, NSUrl outputFileUrl, CMTime duration, CMTime photoDisplayTime, AVCaptureResolvedPhotoSettings resolvedSettings, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error processing live photo companion movie: {error.LocalizedDescription})");
                return;
            }

            livePhotoCompanionMovieUrl = outputFileUrl;
        }
 public override void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     if (photoSampleBuffer == null)
     {
         Console.WriteLine($"Error capturing photo: {error.LocalizedDescription}");
     }
 }