Reputation: 12194
The iPhone 5S is capable of taking pictures while recording video and I am trying to figure out how I would do this programatically. I know I would be utilizing AVFoundation, however, I couldn't find anything in the programming guide regarding this. I have also checked the sample projects (AVFoundation-related) and it doesn't look like there is anything there that does what I am looking for. if you could help point me in the right direction that would be great.
Upvotes: 4
Views: 2806
Reputation: 2924
In iOS7 there has a new api to capture UIView, we can get image and do something.
eg:
UIView+Screenshot.h
-(UIImage *)convertViewToImage;
UIView+Screenshot.m
-(UIImage *)convertViewToImage
{
UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Apple's Document: drawViewHierarchyInRect:afterScreenUpdates:
Upvotes: 3
Reputation: 758
I agree with Rivera's answer ! You are going to need AV
And this is how I do it after the hole AV stuff
CGImageRef bigImage = image.CGImage;
CGRect rectImage = CGRectMake(self.scannArea.origin.x*widhtRatio,
self.scannArea.origin.y*heightRatio - 50,
self.scannArea.size.width*widhtRatio,
self.scannArea.size.height*heightRatio);
CGImageRef part = CGImageCreateWithImageInRect(bigImage, rectImage);
UIImageWriteToSavedPhotosAlbum([UIImage imageWithCGImage:part], nil, nil, nil);
image = [self drawImage:[UIImage imageNamed:@"overlaygraphic.png"]
inImage:image
atPoint:CGPointMake(self.scannArea.origin.x*widhtRatio,
self.scannArea.origin.y*heightRatio - 50)];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
if you want to see the hole sample np. I will upload my class
Upvotes: 1
Reputation: 2144
Through AVCaptureSession you can easily achieve iPhone 5S in the camera app functionality. In your view touch event:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection "
You can get current frame on above delegate method and save it in your gallery.
Please go through below link:
https://developer.apple.com/library/ios/samplecode/RosyWriter/Introduction/Intro.html
Upvotes: 1
Reputation: 10938
Actually you can do it with any device that can record video:
AVCaptureVideoDataOutput
.AVCaptureSession
.AVCaptureVideoDataOutputSampleBufferDelegate
.captureOutput:didOutputSampleBuffer:fromConnection:
in the delegate and get the image with imageFromSampleBuffer:
.Some similar code can be found here, where images are captured at a given interval, but you only want one image.
Upvotes: 6