0
在我的应用程序中,我试图将CIFilter(CIBumpDistortion)应用于我的图像。 我的问题是使用kcIInputCenterKey参数时,它似乎我必须给编号的坐标。当我运行应用程序,此代码返回左眼坐标:IOS Core Image Filter参数
if (face.hasLeftEyePosition) {
NSLog("Left eye %g %g", face.leftEyePosition.x, face.leftEyePosition.y);
Hence, I can manually then enter the left eye coordinates into the kCInputCenterKey and then run the app again and the filter is applied to the left eye centre point:
let filter = CIFilter(name: "CIBumpDistortion")
filter?.setValue(ciImage, forKey: kCIInputImageKey)
filter?.setValue(0.5, forKey: kCIInputScaleKey)
filter?.setValue(200, forKey: kCIInputRadiusKey)
filter?.setValue(CIVector(x:150, y: 150), forKey: kCIInputCenterKey)
if let output = filter?.value(forKey: kCIOutputImageKey) as? CIImage {
self.chosenImage?.image = UIImage(cgImage: context.createCGImage(output, from: output.extent)!)
不过,我希望用户能够选择任何图像时使用的,我需要的Xcode找到左眼位置和应用过滤到该区域,而不必手动输入坐标。
我尝试过使用字符串,不同类型等来代替x和y坐标所需的数字,所有这些都没有运气。
任何帮助将非常欢迎和非常感谢!
嗨,dfd,非常感谢您的建议。我对编码一般都比较陌生,从来没有想过尝试使用手势识别器!再次感谢,我再给它一次。 – Henry