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