title: How to get light value from AVFoundation?
body: <p>I work with Swift 3 and I use camera AVFoundation</p>
  
  <p>Who know is there any way to know capacity of light? </p>
  
  <p>I know that one of the approach is use ambient light sensor, but it is don't encourage and eventually apps doesn't allows in market</p>
  
  <p>I found question very close to that I need</p>
  
  <p><a href="https://stackoverflow.com/questions/22753165/detecting-if-iphone-is-in-a-dark-room">detecting if iPhone is in a dark room</a></p>
  
  <p>And that guy explains that I can use <code>ImageIO framework, read the metadata that's coming in with each frame of the video feed</code></p>
  
  <pre><code>- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
    CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
    NSDictionary *metadata = [[NSMutableDictionary alloc] initWithDictionary:(__bridge NSDictionary*)metadataDict];
    CFRelease(metadataDict);
    NSDictionary *exifMetadata = [[metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary] mutableCopy];
    float brightnessValue = [[exifMetadata objectForKey:(NSString *)kCGImagePropertyExifBrightnessValue]  floatValue];
  }
  </code></pre>
  
  <p>But I am a rookie in iOS and don't know how to convert this code in Swift</p>
  
  <p>Thanks in advance!</p>