gpt4 book ai didi

ios - imageFromCurrentFramebufferWithOrientation返回nil GPUImagePicture?

转载 作者:行者123 更新时间:2023-12-01 18:14:53 26 4
gpt4 key购买 nike

我想将图像转换为黑色和白色。我尝试了以下代码,但imageFromCurrentFramebufferWithOrientation始终返回nil。

-(UIImage *)convertImageToBlackAndWhite:(UIImage *)image{
GPUImagePicture *gpuImage = [[GPUImagePicture alloc] initWithImage:image];
GPUImageSobelEdgeDetectionFilter *edgeFilter = [[GPUImageSobelEdgeDetectionFilter alloc] init];

GPUImageColorMatrixFilter *conversionFilter = [[GPUImageColorMatrixFilter alloc] init];
conversionFilter.colorMatrix = (GPUMatrix4x4){
{0.0, 0.0, 0.0, 1.0},
{0.0, 0.0, 0.0, 1.0},
{0.0, 0.0, 0.0, 1.0},
{1.0,0.0,0.0,0.0},
};

[gpuImage addTarget:edgeFilter];
[edgeFilter addTarget:conversionFilter];
[gpuImage processImage];
NSLog(@"%@",[conversionFilter imageFromCurrentFramebufferWithOrientation:0]);
return [conversionFilter imageFromCurrentFramebufferWithOrientation:0];

}

最佳答案

对于the recent changes in the way that GPUImage handles framebuffers,您需要添加以下行

[conversionFilter useNextFrameForImageCapture];

就在之前
[gpuImage processImage];

在上面的代码中。您需要让框架知道在处理完图像并从中捕获结果之前不要回收最后一个过滤器的帧缓冲区。

关于ios - imageFromCurrentFramebufferWithOrientation返回nil GPUImagePicture?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22993251/

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