图片iOS开发-易错、需注意、罕见api

iOS开发 读取环境光亮度

2017-04-17  本文已影响639人  Evans_Xiao

用于获取iPhone设备摄像头所感知的环境光强度:

#import <ImageIO/ImageIO.h>
-  (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];

   NSLog(@"%f",brightnessValue);
}
上一篇下一篇

猜你喜欢

热点阅读