那来自传感器

时间:2016-11-29 13:01:51

标签: ios xcode camera sensor

我需要在摄像机运行时在控制台中访问传感器信息,例如:

  NSLog(@"value senson camera");

1 个答案:

答案 0 :(得分:0)

这个问题已经得到解答 调用方法AVCaptureSession访问摄像机然后使用此方法访问传感器

创建NSSrting传感器

@property (strong,nonatomic) NSString *Sensor;



#pragma mark - Styling methods

- (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];

//HERE IS YOU SENSOR INFO
_Sensor = [[NSNumber numberWithFloat:brightnessValue] stringValue];
 NSLog(@"VALUE SENSOR %@",_Sensor);

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){


        if ([_Sensor isEqualToString:@"YOU VALUE"]) {

           //YOU CODE HERE 

        }   

});


}

享受