我目前正在将一个遗留项目从iOS 5/6升级到iOS 6/7。
这个项目的一部分涉及到使用GPUImage库拍摄一张照片,用一个作物过滤器处理它,然后添加一些饱和和模糊效果。我目前正在使用0.1.2版通过可可豆安装。
我遇到的问题是,当我试图从相机捕捉图像时,我在GPUImageStillCamera.m line 254中点击了下面的断言
if (CVPixelBufferGetPlaneCount(cameraFrame) > 0)
{
NSAssert(NO, @"Error: no downsampling for YUV input in the framework yet");
}其中cameraFrame是CVImageBufferRef
我已经复制了调用它的代码,并将它移动到另一个项目,在那里它完美地工作。
一旦我将这个复制的类移回主项目中,我每次都会按断言。
我已经排除了用我自己的调试
这让我相信,也许这可能是我仔细研究过的一个项目设置。任何帮助,甚至指向正确方向的指针都是非常受欢迎的。我已经花了1-2天在这件事上,我仍然完全迷失了方向!
我已经包括了下面的剥离类,它显示了一般用途。
#import "ViewController.h"
#import "GPUImage.h"
#import "ImageViewController.h"
@interface ViewController ()
@property (nonatomic, strong) IBOutlet GPUImageView *gpuImageView;
@property (nonatomic, strong) GPUImageStillCamera *camera;
@property (nonatomic, strong) GPUImageCropFilter *cropFilter;
@end
@implementation ViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setupCameraCapture];
}
- (void)setupCameraCapture
{
if (self.camera) {
return;
}
self.cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0, 0, 1, 0.5625)];
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
self.camera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
}
else {
self.camera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionFront];
}
self.camera.outputImageOrientation = UIInterfaceOrientationPortrait;
NSError *error = nil;
[self.camera.inputCamera lockForConfiguration:&error];
[self.camera.inputCamera setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
[self.camera.inputCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance];
if ([self.camera.inputCamera respondsToSelector:@selector(isLowLightBoostSupported)]) {
BOOL isSupported = self.camera.inputCamera.isLowLightBoostSupported;
if (isSupported) {
[self.camera.inputCamera setAutomaticallyEnablesLowLightBoostWhenAvailable:YES];
}
}
[self.camera.inputCamera unlockForConfiguration];
[self.camera addTarget:self.cropFilter];
[self.cropFilter addTarget:self.gpuImageView];
[self.camera startCameraCapture];
}
- (IBAction)capturePressed:(id)sender
{
[self.camera capturePhotoAsImageProcessedUpToFilter:self.cropFilter withCompletionHandler:^(UIImage *image, NSError *error) {
// do something with the image here
}];
}
@end发布于 2014-02-24 15:00:17
真正的罪魁祸首是我的同事马立克发现的一种粗野的方法。隐藏在旧代码库的深处。以上代码运行良好。
教训:如果你的真的是,一定要给未来的开发人员留下适当的文档。
https://stackoverflow.com/questions/21987767
复制相似问题