0

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!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
rem
  • 161
  • 1
  • 12
  • I don't see where you are converting your `UIImage` into a `cv::Mat`, as that is likely where the issue is. You can look at this to get the OpenCV functions for performing these conversions in case that fixes your problem: https://stackoverflow.com/questions/54485811/opencv-ios-type/54486263#54486263 – CodeBender Feb 06 '19 at 14:55
  • the probleme is directly in the UIImageWriteToSavedPhotosAlbum who store my picture with bad resolution – rem Feb 06 '19 at 14:59

0 Answers0