gpt4 book ai didi

swift - 将 GPUImage MultipleBlend 从 OBJ-C 转换为 Swift

转载 作者:行者123 更新时间:2023-11-30 10:49:16 25 4
gpt4 key购买 nike

我正在将 GPUImage 应用程序转换为 Swift,但在转换以下内容时遇到一些问题。

GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Elevate.png" ofType:nil]]];

[lookupImageSource forceProcessingAtSize:sourceImage.size];

GPUImageMultiplyBlendFilter * blendFilter = [[GPUImageMultiplyBlendFilter alloc] init];

GPUImageOpacityFilter *opacityFilter = [[GPUImageOpacityFilter alloc] init];
opacityFilter.opacity = sliderValue;

[lookupImageSource addTarget:opacityFilter];

[stillImageSource addTarget:blendFilter];
[opacityFilter addTarget:blendFilter];

[blendFilter useNextFrameForImageCapture];

[stillImageSource processImage];
[lookupImageSource processImage];

finishedImage = [blendFilter imageFromCurrentFramebufferWithOrientation:sourceImage.imageOrientation];

目前我已转换为以下内容,但运行代码时出现错误。

let filterOpacity = OpacityAdjustment()
filterOpacity.opacity = 1

let filterImage = PictureInput.init(image: UIImage.init(named: "Elevate.png")!)
filterImage.addTarget(filterOpacity)


let filterMultiplyBlend = MultiplyBlend()
filterMultiplyBlend.addTarget(filterOpacity)


imageOutput = sourceImage!.filterWithPipeline{input, output in
input --> filterMultiplyBlend --> output
}

我收到此错误作为输出。

Warning: tried to add target beyond target's input capacity --> Pipeline.swift: addTarget(_:atTargetIndex:): 43

最佳答案

试试这个

        let filterOpacity = OpacityAdjustment()
filterOpacity.opacity = 1

let filterImage = PictureInput.init(image: UIImage.init(named: "Elevate.png")!)

let filterMultiplyBlend = MultiplyBlend()

imageOutput = sourceImage!.filterWithPipeline{input, output in
input --> filterOpacity --> filterMultiplyBlend --> output
}

关于swift - 将 GPUImage MultipleBlend 从 OBJ-C 转换为 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55009422/

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