Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将GPUImage2与CIFilters一起使用_Ios_Swift_Memory_Gpuimage_Cifilter - Fatal编程技术网

Ios 将GPUImage2与CIFilters一起使用

Ios 将GPUImage2与CIFilters一起使用,ios,swift,memory,gpuimage,cifilter,Ios,Swift,Memory,Gpuimage,Cifilter,我正在使用GPUImage和CIFilter处理图像。然而,这被证明是非常内存密集型的,我正试图找到一个更好的解决方案。我主要使用CIFilter,但是GPUImage2提供了CIFilter不提供的AdaptiveThreshold过滤器。因此,我必须在我的项目中使用这两种方法。是否有一种方法可以将CIFilter的outputImage传输到GPUImage2,而不会产生太多开销?或者是否有方法将GPUImage2过滤器移植到CIFilter或反之亦然。下面是我现在使用的一些示例代码:

我正在使用
GPUImage
CIFilter
处理图像。然而,这被证明是非常内存密集型的,我正试图找到一个更好的解决方案。我主要使用
CIFilter
,但是
GPUImage2
提供了
CIFilter
不提供的
AdaptiveThreshold
过滤器。因此,我必须在我的项目中使用这两种方法。是否有一种方法可以将
CIFilter
outputImage
传输到
GPUImage2
,而不会产生太多开销?或者是否有方法将
GPUImage2
过滤器移植到
CIFilter
或反之亦然。下面是我现在使用的一些示例代码:

    let openGLContext = EAGLContext(api: .openGLES2)
    let context = CIContext(eaglContext: openGLContext!)

    guard let cgFilteredImage = context.createCGImage(noiseReductionOutput, from: noiseReductionOutput.extent) else {
        completionHandler(nil)
        return
    }

    let correctlyRotatedImage = UIImage(cgImage: cgFilteredImage, scale: imageToProcess.scale, orientation: imageToProcess.imageOrientation)

    //
    // GPUImage
    //

    let orientation = ImageOrientation.orientation(for: correctlyRotatedImage.imageOrientation)

    let pictureInput = PictureInput(image: correctlyRotatedImage, orientation: orientation)
    let processedImage = PictureOutput()

    pictureInput --> adaptiveThreshold --> processedImage

    processedImage.imageAvailableCallback = {
        image in
        completionHandler(image)
    }

    pictureInput.processImage(synchronously: true)
此外,我正试图通过如下链接过滤器,以最有效的方式使用
CIFilter

    let filter = CIFilter(name: "Filter_Name_Here")!
    guard let filterOutput = filter.outputImage else {
        completionHandler(nil)
        return
    }

    let secondFilter = CIFilter(name: "Filter_Name_Here")!
    secondFilter.setValuesForKeys([kCIInputImageKey: filterOutput])

你明白了吗?你介意分享你的发现吗?我遇到了同样的问题question@otusweb没有,我什么也没发现:(你弄明白了吗?你介意分享你的发现吗?我遇到了同样的问题question@otusweb没有,我什么也没找到:(