I use the following function to make picture photoOutput?.capturePhoto(with: AVCapturePhotoSettings(), delegate: self)
.
When I save the picture his weight is only about 200Ko however the size with the AVCaptureSession.presset is .hight
so it's make 1920x1080.
there is m'y prepare function to change view where all "image" var are UIImage :
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showPhoto_Segue"{
let previewVC = segue.destination as! PreviewViewController
previewVC.image = self.image
}
}
in my photoOutput function I have :
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
if let imageData = photo.fileDataRepresentation(){
image = UIImage(data: imageData)
Arrayimages.append(image!)
Arraytimes.append(Float64(CMTimeGetSeconds(currentCamera!.exposureDuration)))
}
if pictureNumber < 11 {
pictureNumber += 1
DispatchQueue.main.asyncAfter(deadline: .now() + newDurationSeconds + 0.3, execute: {
self.photoOutput?.capturePhoto(with: AVCapturePhotoSettings(), delegate: self)
})
}
else{
image = OpenCVWrapper.hdrImaging(Arrayimages, Arraytimes)
performSegue(withIdentifier: "showPhoto_Segue", sender: nil)
}
}
In my OpenCVWrapper.mm I have :
+(UIImage *) hdrImaging:(NSArray *)images :(NSArray *)times{
std::vector<cv::Mat> imagesVector;
std::vector<float> timesVector;
for (int i = 0; i < images.count; i++) {
UIImage * imageToUse = images[i];
UIImageWriteToSavedPhotosAlbum(imageToUse, nil, nil, nil);
}
//some traitment
return response;
}
when I use UIImageWriteToSavedPhotosAlbum function my pictures are already compressed but I don't know why and the weight of the file is to small to get good quality !
what can I do to get full resolution of my piture in 1920x1080 ?
maybe with AVCapturePhotoSettings ??
thanks!