I am creating a simple camera app for a photobooth. This code below is a sample of the whole project, I am using AVFoundation because I needed my own custom requirements.
When the user presses a button, it takes a photo and instantly shows the preview in the imageView. This is my first major coding project and am new to Objective-C. Is there a way to add a timer or duration to the imageView so that it then removes the image from it, or a way to cycle to a second black image after some time, ready for the next user to take their photo?
Many thanks for any help suggested!
- (IBAction)takephoto:(id)sender {
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in StillImageOutput.connections) {
for (AVCaptureInputPort *port in [connection inputPorts ]) {
if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
videoConnection = connection;
break;
}
}
}
[StillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer != NULL) {
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [UIImage imageWithData:imageData];
imageView.image = image;
}
}];
}
Aucun commentaire:
Enregistrer un commentaire