Skip to content

Instantly share code, notes, and snippets.

@Limon-O-O
Created November 9, 2016 05:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Limon-O-O/683ffdec05ef9ffd60cbc9ef58d7d9df to your computer and use it in GitHub Desktop.
Save Limon-O-O/683ffdec05ef9ffd60cbc9ef58d7d9df to your computer and use it in GitHub Desktop.
get brightness value from CMSampleBuffer
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
}
@Cyberbeni
Copy link

Use CGFloat instead of Float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment