Post

Replies

Boosts

Views

Created

Why AVCaptureDevice.setExposureModeCustom deteriorate overexposed image on iPhone 13
I would like to take 10 photos with my iPhone with different exposure times and ISO locked at 100.0. I would like to have 5 images underexposed and 5 others overexposed. I got some images deteriorated with iPhone 13. In others iPhones it works well. I show you the result of merging images (original, 5 overexposed and 5 underexposed images): I show you last image with the greatest exposure time value (image number 10): As you can see, overexposed parts of image are deteriorated. In the other iPhones I have not this issue. Here is code : var shutter_table = [0: 1/25000.0, 1: 1/20000.0, 2: 1/16000.0, 3: 1/12500.0, 4: 1/10000.0, 5: 1/8000.0, 6: 1/6400.0, 7: 1/5000.0, 8: 1/4000.0, 9: 1/3200.0, 10: 1/2500.0, 11: 1/2000.0, 12: 1/1600.0, 13: 1/1000.0, 14: 1/800.0, 15: 1/640.0, 16: 1/500.0, 17: 1/400.0, 18: 1/320.0, 19: 1/250.0, 20: 1/200.0, 21: 1/160.0, 22: 1/125.0, 23: 1/100.0, 24: 1/80.0, 25: 1/60.0, 26: 1/50.0, 27: 1/40.0, 28: 1/30.0, 29: 1/25.0, 30: 1/20.0, 31: 1/15.0, 32: 1/13.0, 33: 1/10.0, 34: 1/8.0, 35: 1/6.0, 36: 1/5.0, 37: 1/4.0, 38: 1/3.0, 39: 1/2.5, 40: 1/2.0, 41: 1/1.6, 42: 1/1.3, 43: 1.0, 44: 1.3, 45: 1.6, 46: 2.0, 47: 2.5, 48: 3.2, 49: 4.0, 50: 5.0, 51: 6.0, 52: 8.0, 53: 10.0, 54: 13.0, 55: 15.0, 56: 20.0, 57: 25.0, 58: 30.0, 59: 40.0, 60: 50.0, 61: 60.0, 62: 80.0, 63: 100.0, 64: 120.0, 65: 140.0, 66: 160.0, 67: 180.0, 68: 200.0 ] func set_closest_shutter(current_exposure : Double) { var i = 0; for index in 0...shutter_table.count - 1{ if ( shutter_table[ index ]! >= current_exposure ) { i = index break } } current_shutter = i; default_shutter = i; } func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) { if let imageData = photo.fileDataRepresentation(){ try? currentCamera?.lockForConfiguration() if pictureNumber == 0{ set_closest_shutter(current_exposure: Float64(CMTimeGetSeconds(currentCamera!.exposureDuration)) ) currentCamera?.exposureMode = .custom defaultWBMode = currentCamera?.whiteBalanceMode let gains: AVCaptureDevice.WhiteBalanceGains = currentCamera!.deviceWhiteBalanceGains currentCamera?.setWhiteBalanceModeLocked(with: gains, completionHandler:nil); if ( currentCamera?.isFocusModeSupported(.locked) ?? false ) { currentCamera?.focusMode = AVCaptureDevice.FocusMode.locked } } var newDurationSeconds : Double = Double(CMTimeGetSeconds(currentCamera!.exposureDuration)) //print( "current exposure == " + String( newDurationSeconds ) ) var newExposureTime: CMTime? if ( pictureNumber < 5 ) { current_shutter -= 4 if ( current_shutter < 0 ) { current_shutter = 0 } newDurationSeconds = shutter_table[ current_shutter ]! if ( newDurationSeconds < minDuration! ) { newDurationSeconds = minDuration! } } else { if ( pictureNumber == 5 ) { current_shutter = default_shutter; } current_shutter += 4 if ( current_shutter >= shutter_table.count ){ current_shutter = shutter_table.count - 1 } newDurationSeconds = shutter_table[ current_shutter ]! if ( newDurationSeconds > maxDuration! ) { newDurationSeconds = maxDuration! } } newExposureTime = CMTimeMakeWithSeconds(newDurationSeconds.roundTo(toPlaces: 9), preferredTimescale: Int32(CONVERT_NANO_SECOND)) //currentCamera?.activeFormat.highResolutionStillImageDimensions self.pictureNumber += 1 if self.pictureNumber <= 10 { currentCamera?.setExposureModeCustom(duration: newExposureTime!, iso: ISOValue!, completionHandler: {_ in DispatchQueue.main.async { self.photoOutput?.capturePhoto(with: AVCapturePhotoSettings(), delegate: self) } }) } else { } } I would like to fix this. Can you give me some steps to fix it or debug it?
2
0
921
Jan ’23