Post

Replies

Boosts

Views

Activity

builtInTrueDepthCamera cannot set exposure duration
Hello, I am making an app that requires the use of builtInTrueDepthCamera. I am trying to set a custom exposure mode but the completion for: open func setExposureModeCustom(duration: CMTime, iso ISO: Float) async -> CMTime never gets called. It works perfectly fine for builtInLiDARDepthCamera. In my function I am confirming that a custom exposure mode is supported and it is within the range of acceptable durations. Is it known that this just does not work? Here is my AVCaptureDevice extension function: extension AVCaptureDevice { func setExposureTime(to milliseconds: Double) async { print("setting exposure time 1") await withCheckedContinuation { continuation in // Check if custom exposure mode is supported guard self.isExposureModeSupported(.custom) else { print("Custom exposure mode is not supported on this device.") continuation.resume() // Resume immediately if not supported return } // Convert milliseconds to CMTime let exposureTime = CMTimeMake(value: Int64(milliseconds * 1_000), timescale: 1_000_000) print("Exposure time var : \(exposureTime.seconds * 1000)") print("Exposure time min : \(self.activeFormat.minExposureDuration.seconds * 1000)") print("Exposure time max : \(self.activeFormat.maxExposureDuration.seconds * 1000)") // Ensure the exposure time is within the supported range guard exposureTime >= self.activeFormat.minExposureDuration, exposureTime <= self.activeFormat.maxExposureDuration else { print("Exposure time is out of the supported range.") continuation.resume() // Resume immediately if out of range return } print("setting exposure time 2") // Attempt to set the exposure time do { try self.lockForConfiguration() print("setting exposure time 3") self.setExposureModeCustom(duration: exposureTime, iso: AVCaptureDevice.currentISO) { time in print("Exposure time set to: \(time.seconds * 1000) ms") continuation.resume() // Resume after the completion handler is executed } self.unlockForConfiguration() } catch { print("Failed to configure exposure: \(error)") continuation.resume() // Resume on failure } } } }
0
0
99
1w