首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GPUImage未能对iOS进行CVPixelBufferGetPlaneCount检查

GPUImage未能对iOS进行CVPixelBufferGetPlaneCount检查
EN

Stack Overflow用户
提问于 2014-02-24 12:27:28
回答 1查看 578关注 0票数 0

我目前正在将一个遗留项目从iOS 5/6升级到iOS 6/7。

这个项目的一部分涉及到使用GPUImage库拍摄一张照片,用一个作物过滤器处理它,然后添加一些饱和和模糊效果。我目前正在使用0.1.2版通过可可豆安装。

我遇到的问题是,当我试图从相机捕捉图像时,我在GPUImageStillCamera.m line 254中点击了下面的断言

代码语言:javascript
复制
if (CVPixelBufferGetPlaneCount(cameraFrame) > 0)
{
  NSAssert(NO, @"Error: no downsampling for YUV input in the framework yet");
}

其中cameraFrameCVImageBufferRef

我已经复制了调用它的代码,并将它移动到另一个项目,在那里它完美地工作。

一旦我将这个复制的类移回主项目中,我每次都会按断言。

我已经排除了用我自己的调试

  • 64位(两者都在发生)
  • 不同库版本
  • 初始对象设置/代码/用法

这让我相信,也许这可能是我仔细研究过的一个项目设置。任何帮助,甚至指向正确方向的指针都是非常受欢迎的。我已经花了1-2天在这件事上,我仍然完全迷失了方向!

我已经包括了下面的剥离类,它显示了一般用途。

代码语言:javascript
复制
#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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-24 15:00:17

真正的罪魁祸首是我的同事马立克发现的一种粗野的方法。隐藏在旧代码库的深处。以上代码运行良好。

教训:如果你的真的是,一定要给未来的开发人员留下适当的文档。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21987767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档