ios - 如何使用 Swift 语法在 GPUImage2 中将两个图像混合在一起

标签 ios swift image-processing gpuimage

我熟悉以下语法,可以在 GPUImage2 中使用 Swift 语法中的类似内容进行单个图像过滤:

input --> blur --> output

但是我该如何使用需要两张图像的图像处理操作呢? GPUImage2 中的示例之一表明您可以执行此操作:

input --> self.lookup1 --> self.alphaBlend --> self.lookup2 --> output
          self.lookup1 --> self.gaussianBlur --> self.alphaBlend

其中 self.lookup1 和 self.lookup2 是 2 张不同的图像。但我不确定这种语法,在这种情况下,第二张图像是否应该在 alphaBlend 滤镜之后?

最佳答案

通过分析链并使用操作中所需的输入数量,发现我发布的上述示例有效。所以 alphaBlend 将等待应用另一个输入,这是一个工作示例:

      let alphaBlend = AlphaBlend()

      let input1 = PictureInput(image: image1)
      let input2 = PictureInput(image: image2)
      alphaBlend.mix = 0.5;

      let output = PictureOutput();
      output.encodedImageFormat = .JPEG

      output.imageAvailableCallback = {image in
        // Do something with the image
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
      }

      input1 -->  alphaBlend
      input2 --> alphaBlend --> output

      input1.processImage(synchronously: true)
      input2.processImage(synchronously: true)

关于ios - 如何使用 Swift 语法在 GPUImage2 中将两个图像混合在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39157335/

相关文章:

python - 有没有人有任何使用 OpenCV 和 python 进行描述符提取的例子?

ios - 将动态创建的文件复制到内置的应用程序包中

iphone - 在处理核心数据时如何停止内存的积累?

ios - scrollViewDidScroll 方法不引用 TableView 中的所有 ScrollView

ios - 尝试关闭 View Controller 时发出警告(模态中的模态)

ios - 在 iOS 上的 Swift 中使用 Realm DB 对应用程序大小有什么影响

iphone - 以编程方式修剪(自动裁剪透明边界)objective-c/cocoa 中的图像

c - 使用opencv进行人脸检测

ios - 什么是默认线程

ios - 代码有问题,需要帮助