gpt4 book ai didi

ios - 在基本项目中使用 GPUImage 实时视频过滤器会导致纯白屏幕

转载 作者:行者123 更新时间:2023-11-29 02:58:39 26 4
gpt4 key购买 nike

我刚刚将 GPUImage 集成到一个全新的项目中,并按照 Github 中的说明添加了所需的库。页。我已经为GPUImageVideoCamera创建了一个strong属性,并在viewDidLoad中,我将其实例化如下:

self.videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];

编辑:项目中的完整代码:

@interface ViewController () <GPUImageVideoCameraDelegate>
{
GPUImageVideoCamera *videoCamera;
}

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

GPUImagePixellatePositionFilter *customFilter = [[GPUImagePixellatePositionFilter alloc] init];
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];

[videoCamera addTarget:customFilter];
[customFilter addTarget:filteredVideoView];

[videoCamera startCameraCapture];
}

@end

但是,我得到的只是一个白屏,没有任何错误或警告,并且想知道我做错了什么......谢谢!

最佳答案

我知道这是一个老问题,但我遇到了同样的问题并找到了解决方法。这看起来真的很愚蠢,但对我来说,我只是将 videoCamera 设为一个属性,它就开始工作了,即:

@interface ViewController ()

@property (nonatomic, strong) GPUImageVideoCamera *camera;

@end

-(void)viewDidLoad {
[super viewDidLoad];
self.camera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];

//etc.
}

关于ios - 在基本项目中使用 GPUImage 实时视频过滤器会导致纯白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23555785/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com