Zoltan Varadi
Zoltan Varadi

Reputation: 2478

iOS Custom Camera - Take Photo Instantly

In my app I created a custom camera view for image capturing. When I trigger capturing, I use the following code:

private func takePhoto() {
   let settings = AVCapturePhotoSettings()
   self.stillImageOutput.capturePhoto(with: settings, delegate: self)
}

This then triggers photoOutput didFinishProcessingPhoto

There I extract the UIImage from the AVCapturePhoto and carry on.

My problem is in between I call self.stillImageOutput.capturePhoto and the image arrives in didFinishProcessingPhoto an average 0.5 second passes and I would need the capture image (almost) exactly at the time capturePhoto was called.

Is there a way to speed this process up or is there another way how I can achieve the same result?

Upvotes: 0

Views: 659

Answers (1)

AtulParmar
AtulParmar

Reputation: 4570

let settings = AVCapturePhotoSettings() write outside of takePhoto function, when you call takePhoto function at that time create a new memory and allocate to settings variable, So If you define globally in this controller then memory will allocate when this controller load and it would speed up process to take photo.

Upvotes: 1

Related Questions