核心图像滤镜“CIDepthBlurEffect”在iOS 11 / Xcode 9.0上无法工作

4
我无法让新的CIDepthBlurEffect生效。我是做错了什么,还是这是一个已知的问题?
以下是我的Objective-C代码:
    NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSNumber numberWithBool:YES], [NSNumber numberWithBool:YES], nil] forKeys:[NSArray arrayWithObjects:kCIImageAuxiliaryDisparity, @"kCIImageApplyOrientationProperty", nil]];

CIImage *disparityImage = [CIImage imageWithData:imageData options:dict];

CIFilter *ciDepthBlurEffect = [CIFilter filterWithName:@"CIDepthBlurEffect"];
[ciDepthBlurEffect setDefaults];
[ciDepthBlurEffect setValue:disparityImage forKey:@"inputDisparityImage"];
[ciDepthBlurEffect setValue:originalImage forKey:@"inputImage"];
CIImage *outputImage = [ciDepthBlurEffect valueForKey:@"outputImage"];

EAGLContext *previewEaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

CIContext *context = [CIContext contextWithEAGLContext:previewEaglContext options:@{kCIContextWorkingFormat :[NSNumber numberWithInt:kCIFormatRGBAh]} ];

CGImageRef cgimg = [context createCGImage:disparityImage fromRect:[disparityImage extent]];

image = [[UIImage alloc] initWithCGImage:cgimg];

CGImageRelease(cgimg);

它能在iOS 10上运行吗? - Artem Novichkov
不,这个过滤器只支持iOS 11。 - user1752054
刚刚偶然发现了这个问题。看下面已经在后期beta版本中解决了,但是很难看出它如何工作,因为你甚至从未使用“outputImage”。也就是说,这将返回深度地图的渲染,而不是模糊图像。 - John Scalo
1个回答

0

这个问题已经在Xcode 9 beta 2和iOS 11 beta 2的发布中得到解决。


之前你遇到了什么问题?当我应用滤镜时,图像的错误部分被模糊处理了,这是你看到的吗?我有最新的Beta版本,所以我也不确定是代码还是操作系统的问题。 - Jimmy
1
请确保对视差图像进行缩放。 - user1752054
你知道在哪里可以获取有关扩展视差图像的更多信息吗? - Gizmodo
1
如果你正在使用CIDepthBlurEffect滤镜,那么视差图像会自动放大。如果你没有使用它,可以使用CIEdgePreserveUpsampleFilter。 - user1752054

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接