GPUImageStillCamera capture are not in high resolution
I've run the sample application SimplePhotoFilter and checked the captured image resolution by downloading my phone's data directory with xcode organizer. The output image has a resolution of 640x852 pixels which according to this thread is my iPhone video resolution for the photo preset not the video preset (http://stackoverflow.com/questions/4893664/applying-effect-to-iphone-camera-preview-video-using-opengl)
I'm using an iPhone 4 device running iOS 5.1which from my understanding wouldn't be able to process the high res image returned from AVCaptureStillImageOutput since one of there dimension is bigger than 2048px. To adress this I was planning to resize the image on an iPhone4 to 2048x1529px (3.1MP) from the original resolution of 2592x1936. (5MP)
EDIT: Looking at this again, I may have been mistaken about GPUStillImageCamera not doing anything with the sample buffer (sorry if my original message added any confusion).
It appears this line of code feeds the sample buffer (with the full res image data) back into the processing pipeline:
[self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
... which is a cleaner solution than the way I was doing things. (but again, I'm experiencing the same issue where the saved image is not the full resolution one).
This happens on an iPhone 4S as well. I believe the issue is with the way GPUImageStillCamera is implemented. It calls "captureStillImageAsynchronouslyFromConnection" but then never does anything with the sample buffer (which actually contains the full res image data).
This modification below shows how to get the full res data, though I'm unsure of the best way to then filter that image. In my own implementation prior to the addition of GPUImageStillCamera, I had a delegate method that returned the unfiltered UIImage back to my main View Controller... which I then filtered as a separate still image.
- (void)capturePhotoProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(UIImage *processedImage, NSError *error))block;
{
[photoOutput setOutputSettings:[NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey]];
[photoOutput captureStillImageAsynchronouslyFromConnection:[[photoOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
[self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
// Will need an alternate pathway for the iOS 4.0 support here
UIImage *filteredPhoto = [finalFilterInChain imageFromCurrentlyProcessedOutput];
// get a UIImage of the still image data
NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *unfilteredFullResImage = [UIImage imageWithData:jpegData];
NSLog(@"filteredPhoto - w: %f, h: %f", filteredPhoto.size.width, filteredPhoto.size.height);
NSLog(@"unfilteredFullResImage - w: %f, h: %f", unfilteredFullResImage.size.width, unfilteredFullResImage.size.height);
block(filteredPhoto, error);
}];
return;
}
This has now been fixed. It was due to an oversight on my part when checking the sources of video buffers in GPUImageVideoCamera's -captureOutput:didOutputSampleBuffer:fromConnection: .
Hi Brad, I was using GPUImage framework, and I want to say this is best available in market. But, there is little problem I am facing, as you have mentioned in documentation that It had problem with full resolution (5 MP) on iPhone 4 since opengl buffer size limit. But, you also have mentioned some replication of texture to solve this problem. As I am beginner to AV Foundation and OpenGL, Can you explain the process in detail or if you had time can you implement it in framework