capturePhotoAsJPEGProcessedUpToFilter Resolution
What is the correct way of capturing a full resolution filtered image with metadata from the iPhone camera? I'm saving an image to the camera roll successfully, but its being heavily scaled down to 640 x 852. I'm using the session preset "AVCaptureSessionPresetPhoto" as the docs says that should be full resolution
My code is based off the SimplePhotoFilter project, except I had to add [stillCamera pauseCamerCapture] before saving the image or the image was saved with distortion lines down the edge
Is it possible to save it at native 3264 x 2448 resolution with normal iPhone camera metadata? I'm developing on a 4S. Thanks
The [stillCamera pauseCameraCapture] is what's preventing the full-size photos from being processed, because you're telling the application to ignore incoming frames after that's activated. Therefore, you're only processing the last preview frame of video, which is 640 x 852.
Are you sure that you were following the SimplePhotoFilter example? If you allocate a default still image camera using [[GPUImageStillCamera alloc] init], everything should be set to the correct presets for taking photos. If you change the presets in any way for the still camera, there is a known bug in iOS where the camera will send some corrupt image data for photos at the non-photo preset. Using the SimplePhotoFilter example, I see none of this artifacting when taking pictures with the way it is configured.
I think my issue my be related to the resolution as well, but I can't seem to resolve it. I copied the code from SimplePhotoFilter to take pictures, and it worked fine on my 4S, but when I ran the takePicture code in my application, I get *** -[NSConcreteMutableData length]: message sent to deallocated instance 0xe954ce0 on the processedJPEG object. Have you seen this before? I've done a bit of researching, and haven't found an answer. If I don't try to use processedJPEG in my code, then my phone will just freeze in the callback method, and after a while automatically restart...
That might have to do with the block of code here:
NSData *dataForJPEGFile = nil;
@autoreleasepool {
UIImage *filteredPhoto = [finalFilterInChain imageFromCurrentlyProcessedOutput];
// report_memory(@"After UIImage generation");
dataForJPEGFile = UIImageJPEGRepresentation(filteredPhoto, 0.8);
// report_memory(@"After JPEG generation");
}
where I generate the JPEG representation within an autorelease pool. I thought that it would survive outside of that pool under ARC, but it's possible that it is not doing so. I'll look into it.
I just got this to work today. Photos are full size and look good in both lanscape and portrait when compared with Camera+ photos. My code is based on the SimplePhotoFilter example.
- (IBAction)captureStillImage:(id)sender {
self.captureImageGesture.enabled = NO;
[self snapShutter];
[self.stillCamera capturePhotoAsJPEGProcessedUpToFilter:self.filter withCompletionHandler:^(NSData* imageData, NSError* error){
if (error) {
[self alertOnError:error];
}
else {
UIImage* capturedImage = [[UIImage alloc] initWithData:imageData];
if ([self.delegate respondsToSelector:@selector(didCaptureImage:)]) {
[self.delegate didCaptureImage:capturedImage];
}
}
runOnMainQueueWithoutDeadlocking(^{
self.captureImageGesture.enabled = YES;
});
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.stillCamera = [[GPUImageStillCamera alloc] init];
self.stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
self.filter = [[GPUImageGammaFilter alloc] init];
[self.filter prepareForImageCapture];
[self.stillCamera addTarget:filter];
GPUImageView* filterView = (GPUImageView*)self.view;
filterView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;
[self.filter addTarget:filterView];
[self.stillCamera startCameraCapture];
}
Awesome -thanks I'll try it.
On Jun 2, 2012, at 3:09 PM, Troy Stribling wrote:
I just got this to work today. Photos are full size and look good in both lanscape and portrait when compared with Camera+ photos. My code is based on the SimplePhotoFilter example.
- (IBAction)captureStillImage:(id)sender { self.captureImageGesture.enabled = NO; [self snapShutter]; [self.stillCamera capturePhotoAsJPEGProcessedUpToFilter:self.filter withCompletionHandler:^(NSData* imageData, NSError* error){ if (error) { [self alertOnError:error]; } else { UIImage* capturedImage = [[UIImage alloc] initWithData:imageData]; if ([self.delegate respondsToSelector:@selector(didCaptureImage:)]) { [self.delegate didCaptureImage:capturedImage]; } } runOnMainQueueWithoutDeadlocking(^{ self.captureImageGesture.enabled = YES; }); }]; } - (void)viewDidLoad { [super viewDidLoad]; self.stillCamera = [[GPUImageStillCamera alloc] init]; self.stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait; self.filter = [[GPUImageGammaFilter alloc] init]; [self.filter prepareForImageCapture]; [self.stillCamera addTarget:filter]; GPUImageView* filterView = (GPUImageView*)self.view; filterView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill; [self.filter addTarget:filterView]; [self.stillCamera startCameraCapture]; }
Reply to this email directly or view it on GitHub: https://github.com/BradLarson/GPUImage/issues/173#issuecomment-6079964
Ok. It turns out that since my project was not using arc, and I added a project using arc, I needed to let the compiler know that the project used arc, then all the funky memory issues were taken care of.
when I pauseCamerCapture?
I there a way to save image in resolution 1280x853?
@balabs - This isn't really related to the issue here, but if you need to do this, simply use -forceProcessingAtSize: on one of your filters in the chain the downsample to a lower resolution.
That's what I needed. Thanks for extremely fast response. Best regards