Still camera doesn't display to view
Hi Brad,
I have a pretty simple block of code to capture a still picture but it doesn't work. When I go to this view controller, no preview camera image is displayed, nothing in fact is displayed.
-
(void)viewDidLoad { [super viewDidLoad];
imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; imageView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:imageView];
camera = [[GPUImageStillCamera alloc] init]; camera.outputImageOrientation = UIInterfaceOrientationPortrait;
[camera addTarget:imageView]; [camera startCameraCapture]; }
-
(void)viewDidUnload { [super viewDidUnload]; [camera stopCameraCapture]; imageView = nil; }
I also run into a problem navigating away from the view controller.
// EXC_BAD_ACCESS
runOnMainQueueWithoutDeadlocking(^{
[weakSelf processVideoSampleBuffer:sampleBuffer];
});
Thanks for any help and thanks for sharing this framework, Scott B
I'm not sure but a filter must be used at least. I tried to test with your code which added a filter like this..
-
(void)viewDidLoad { [super viewDidLoad];
GPUImageView *imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; imageView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:imageView];
stillCamera = [[GPUImageStillCamera alloc] init];
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
filter = [[GPUImageSepiaFilter alloc] init]; [filter prepareForImageCapture]; [stillCamera addTarget:filter];
[stillCamera addTarget:imageView];
[filter addTarget:imageView]; [stillCamera startCameraCapture]; }
This code works well.. Check the SimplePhotoFilter sample..
One more, you have to add this code when controller is disappeared..
- (void)viewDidDisappear:(BOOL)animated { [stillCamera stopCameraCapture]; }
Hi Brad, i have a same issue as scottmboring. Testing on iPad3 5.1.1. When i hit the home screen button and open the app again, it works.
Adding in a filter fixed the issue for me; although it would be nice to not have to use a filter since this provides a simple way to implement a custom camera setup.
I used the sharpen filter with the sharpen value set to 0 which achieves the same outcome as not using a filter at all.