वहाँ पूर्वावलोकन के फ्रेम हड़पने के लिए 2 तरीके हैं .. AVCaptureVideoDataOutput & AVCaptureStillImageOutput :)
अपने कब्जा सत्र है वीडियो फ्रेम हड़पने के लिए है, तो एक चुने हुए फ्रेम से cgimage के साथ अपने परत बनाने सेटअप है।यदि यह स्थिरता के लिए सेटअप है, तो अपनी स्थिर छवि प्राप्त करने तक प्रतीक्षा करें और अपनी परत को उस सीजीमेज के स्केल किए गए संस्करण से बनाएं। अगर आपके पास अभी तक आपके सत्र में कोई आउटपुट नहीं है, तो आपको एक ऐसा लगता है जो मुझे लगता है। तब
AVCaptureVideoDataOutput *videoOutput = [[AVCaptureVideoDataOutput alloc] init];
videoOutput.videoSettings = @{ (NSString *)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA) };
[session addOutput:videoOutput];
dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL);
[videoOutput setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
, नीचे दिए गए प्रतिनिधि विधि को लागू अपनी छवि स्नैपशॉट प्राप्त करने के लिए:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
// Add your code here that uses the image.
dispatch_async(dispatch_get_main_queue(), ^{
_imageView.image = image;
});
}
यह स्मृति की खपत और कम हो जाएगा
स्रोत
2010-08-25 02:39:48
जो उपरोक्त तीन में बेहतर @ ओडेड बेन डोव है। सबसे अच्छा सुझाव दें \ –