-
-
Save kb100824/51321aaf6520adb76580f0c7041632a2 to your computer and use it in GitHub Desktop.
get brightness value from CMSampleBuffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getBrightnessValue(from sampleBuffer: CMSampleBuffer) -> Float { | |
guard | |
let metadataDict = CMCopyDictionaryOfAttachments(nil, sampleBuffer, kCMAttachmentMode_ShouldPropagate) as? [String: Any], | |
let exifMetadata = metadataDict[String(kCGImagePropertyExifDictionary)] as? [String: Any], | |
let brightnessValue = exifMetadata[String(kCGImagePropertyExifBrightnessValue)] as? Float | |
else { return 0.0 } | |
return brightnessValue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment