佚名通过本文主要向大家介绍了实时人脸检测,人脸实时报警服务器,实时人脸识别,实时人脸识别系统,人脸实时报警系统等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 实时人脸检测,相机关闭
描述:
当我调用人脸检测的方法时,当这个方法执行13次后,相机就关闭了,请问为啥
描述:
ios相机人脸检测
当我调用人脸检测的方法时,当这个方法执行13次后,相机就关闭了,请问为啥
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
......
//人脸检测
if(sampleBuffer)
{
[self detectFaceWithBuffer:sampleBuffer andUimage:_image];
_num++;
NSLog(@"%d",self.num);
}
......
}
- (void)detectFaceWithBuffer:(CMSampleBufferRef)sampleBuffer andUimage:(UIImage *)uiimage
{
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
CIImage *convertedImage = [[CIImage alloc] initWithCVPixelBuffer:imageBuffer options:(__bridge NSDictionary *)attachments];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.features = [self.faceDetector featuresInImage:convertedImage options:nil];
for(CIFaceFeature *feature in self.features){
if(feature.hasLeftEyePosition){
CGPoint leftEyePos = feature.leftEyePosition;
NSLog(@"leftX = %f leftY = %f",leftEyePos.x,leftEyePos.y);
}
}
});
}