2016-11-29 35 views
-2

我需要在控制台访问传感器信息时,相机运行例如:这来自传感器

NSLog(@"value senson camera"); 
+0

请阅读[帮助中心](http://stackoverflow.com/help)并编辑问题 – Lexi

+0

[选中此项](http://stackoverflow.com/help/how-to-ask)。 –

回答

0

这个问题已经回答 Invoke方法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 

     } 

}); 


} 

享受

+0

好的我有工作感谢 – user3365028

+1

如果这个问题已经得到解答,您应该将该问题标记为重复,并将链接重复问题。 – Lexi