fix: wait for camera exposure to settle
This commit is contained in:
@@ -78,6 +78,7 @@
|
|||||||
- macOS codesign: include camera entitlement so permission prompts work in the menu bar app.
|
- macOS codesign: include camera entitlement so permission prompts work in the menu bar app.
|
||||||
- Agent tools: map `camera.snap` JPEG payloads to `image/jpeg` to avoid MIME mismatch errors.
|
- Agent tools: map `camera.snap` JPEG payloads to `image/jpeg` to avoid MIME mismatch errors.
|
||||||
- Tests: cover `camera.snap` MIME mapping to prevent image/png vs image/jpeg mismatches.
|
- Tests: cover `camera.snap` MIME mapping to prevent image/png vs image/jpeg mismatches.
|
||||||
|
- macOS camera: wait for exposure/white balance to settle before capturing a snap to avoid dark images.
|
||||||
- macOS packaging: move rpath config into swift build for reliability (#69) — thanks @petter-b
|
- macOS packaging: move rpath config into swift build for reliability (#69) — thanks @petter-b
|
||||||
- macOS: prioritize main bundle for device resources to prevent crash (#73) — thanks @petter-b
|
- macOS: prioritize main bundle for device resources to prevent crash (#73) — thanks @petter-b
|
||||||
- macOS remote: route settings through gateway config and avoid local config reads in remote mode.
|
- macOS remote: route settings through gateway config and avoid local config reads in remote mode.
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ actor CameraCaptureService {
|
|||||||
session.startRunning()
|
session.startRunning()
|
||||||
defer { session.stopRunning() }
|
defer { session.stopRunning() }
|
||||||
await Self.warmUpCaptureSession()
|
await Self.warmUpCaptureSession()
|
||||||
|
await self.waitForExposureAndWhiteBalance(device: device)
|
||||||
|
|
||||||
let settings: AVCapturePhotoSettings = {
|
let settings: AVCapturePhotoSettings = {
|
||||||
if output.availablePhotoCodecTypes.contains(.jpeg) {
|
if output.availablePhotoCodecTypes.contains(.jpeg) {
|
||||||
@@ -257,6 +258,17 @@ actor CameraCaptureService {
|
|||||||
// A short delay after `startRunning()` significantly reduces "blank first frame" captures on some devices.
|
// A short delay after `startRunning()` significantly reduces "blank first frame" captures on some devices.
|
||||||
try? await Task.sleep(nanoseconds: 150_000_000) // 150ms
|
try? await Task.sleep(nanoseconds: 150_000_000) // 150ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func waitForExposureAndWhiteBalance(device: AVCaptureDevice) async {
|
||||||
|
let stepNs: UInt64 = 50_000_000
|
||||||
|
let maxSteps = 30 // ~1.5s
|
||||||
|
for _ in 0..<maxSteps {
|
||||||
|
if !(device.isAdjustingExposure || device.isAdjustingWhiteBalance) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try? await Task.sleep(nanoseconds: stepNs)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegate {
|
private final class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegate {
|
||||||
|
|||||||
Reference in New Issue
Block a user