2017-12-26 15 views
1

タッチポイントから「inputFocusRect」値を設定する正しい方法を見つけることができません。 私は別のボケ関数にCIFilterにそれを渡すCIDepthBlurEffect:setting inputFocusRect

@IBAction func imageTapped(_ sender: UITapGestureRecognizer) { 
    var touchPoint = sender.location(in: self.imageView) 
    imageTapCoordinates = CIVector(cgPoint: touchPoint) 

を使用してタッチポイントをつかみました。

filter?.setValue(imageTapCoordinates, forKey: "inputFocusRect") 

ただし、座標系が一致しないようです。 "inputFocusRect"を決定する最善の方法は何ですか? Appleには、このサイトの多くのドキュメントがありません。

ありがとう!

+0

もう少しコードを投稿してください。 CIDepthBlurEffectという名前のCIFilterはありません。 https://developer.apple.com/library/content/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/uid/TP40004346 – dfd

+0

また、CoreImageフィルタのY軸座標が "原点(X == 0、Y == 0)のように、反転された "は、左*下*ではなく、左*下*である。 – dfd

+0

これはiOS11の新しいフィルタです! WWDCの話はこちらをご覧ください:https://developer.apple.com/videos/play/wwdc2017/508/ –

答えて

0

これは長さとフォーマットの良さのために答えとして投稿しています。

TL; DR;

このフィルタでは、入力画像とCoreMLまたは顔認識のVisionフレームワーク出力の2つ(またはそれ以上)の入力が必要になる可能性があります。

inputFocusRectCIVector(原点が左下にあるように反転した座標)は、CoreMLまたはVisionフレームワークの出力が大きな画像で顔を認識した場所です。

説明:

CIDepthBlurEffectは、iOS 11やMacOS 10.3で利用可能な新しいフィルタです。実際にはそれは新しく、AppleはまだCI Filter Referenceを更新していない。

私が見つけたものを投棄することに頼る必要がありました。むしろ単純なコードです。フィルタのインスタンスを作成し、その属性を出力します。

let filter = CIFilter(name: "CIDepthBlurEffect") 
print(filter?.attributes) 

理解し、これを行うには良い方法があります - 、利用可能なフィルタ(すべてまたは特定のカテゴリ)のための装置を照会自分の表示名を取得するには、特定の属性を使用して、より多くの。私の意図は、私がこの質問のためにできることを提供することでした。 「ダンプ」は、辞書要素の配列、つまり[String:Any]になり、ここではフォーマットされていません。手動フォーマット収率これ: - 2 CIImages、5 CIVectors、3 NSNumbers、1 NSDictionary、及び1 AVCameraCalibrationData

[ 
    "inputRightEyePositions": { 
     CIAttributeClass = CIVector; 
     CIAttributeDisplayName = "Right Eye Positions"; 
     CIAttributeType = CIAttributeTypePosition; 
    }, 
    "inputCalibrationData": { 
     CIAttributeClass = AVCameraCalibrationData; 
     CIAttributeDisplayName = CalibrationData; 
    }, 
    "inputImage": { 
     CIAttributeClass = CIImage; 
     CIAttributeDescription = "The image to use as an input image. For filters that also use a background image, this is the foreground image."; 
     CIAttributeDisplayName = Image; 
     CIAttributeType = CIAttributeTypeImage; 
    }, 
    "inputChinPositions": { 
     CIAttributeClass = CIVector; 
     CIAttributeDisplayName = "Chin Positions"; 
     CIAttributeType = CIAttributeTypePosition; 
    }, 
    "inputLeftEyePositions": { 
     CIAttributeClass = CIVector; 
     CIAttributeDisplayName = "Left Eye Positions"; 
     CIAttributeType = CIAttributeTypePosition; 
    }, 
    "inputAuxDataMetadata": { 
     CIAttributeClass = NSDictionary; 
     CIAttributeDisplayName = AuxDataMetadata; 
    }, 
    "CIAttributeFilterAvailable_Mac": 10.13, 
    "CIAttributeFilterName": CIDepthBlurEffect, 
    "CIAttributeReferenceDocumentation": http://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDepthBlurEffect, 
    "inputAperture": { 
     CIAttributeClass = NSNumber; 
     CIAttributeDefault = 0; 
     CIAttributeDisplayName = Aperture; 
     CIAttributeMax = 22; 
     CIAttributeMin = 0; 
     CIAttributeSliderMax = 22; 
     CIAttributeSliderMin = 1; 
     CIAttributeType = CIAttributeTypeScalar; 
    }, 
    "CIAttributeFilterDisplayName": Depth Blur Effect, 
    "CIAttributeFilterAvailable_iOS": 11, 
    "inputNosePositions": { 
     CIAttributeClass = CIVector; 
     CIAttributeDisplayName = "Nose Positions"; 
     CIAttributeType = CIAttributeTypePosition; 
    }, 
    "inputLumaNoiseScale": { 
     CIAttributeClass = NSNumber; 
     CIAttributeDefault = 0; 
     CIAttributeDisplayName = "Luma Noise Scale"; 
     CIAttributeMax = "0.1"; 
     CIAttributeMin = 0; 
     CIAttributeSliderMax = "0.1"; 
     CIAttributeSliderMin = 0; 
     CIAttributeType = CIAttributeTypeScalar; 
    }, 
    "inputScaleFactor": { 
     CIAttributeClass = NSNumber; 
     CIAttributeDefault = 1; 
     CIAttributeDisplayName = "Scale Factor"; 
     CIAttributeSliderMax = 1; 
     CIAttributeSliderMin = 0; 
     CIAttributeType = CIAttributeTypeScalar; 
    }, 
    "inputFocusRect": { 
     CIAttributeClass = CIVector; 
     CIAttributeDisplayName = "Focus Rectangle"; 
     CIAttributeIdentity = "[-8.98847e+307 -8.98847e+307 1.79769e+308 1.79769e+308]"; 
     CIAttributeType = CIAttributeTypeRectangle; 
    }, 
    "inputDisparityImage": { 
     CIAttributeClass = CIImage; 
     CIAttributeDisplayName = DisparityImage; 
    }, 
    "CIAttributeFilterCategories": <__NSArrayI 0x1c46588a0>(
     CICategoryBlur, 
     CICategoryVideo, 
     CICategoryStillImage, 
     CICategoryBuiltIn 
    ) 

Iは、12個の可能な入力を数えます。

これらはカメラ、画像、画像メタデータ、および顔のコンポーネントを扱いやすく、簡単に解読できます。そうではないものもありますが、ビジョンフレームワークにもっと深く関わっている人もいます。 (!でない場合は、多分それは見て良い場所だ)

具体的には、私の質問は以下のとおりです。

  • 正確inputDisparityImageは何?
  • nilまたはカイ位置が見つからないと思われるさまざまな入力顔の特徴は何ですか?

これは多くのSO標準では解決されていませんが、私が喜んで削除します。しかし、私はのアイデアを与えて、どのようにフィルタの属性であるかを知り、助けを求めようとしています。

私のCoreMLとVisionフレームワークの知識は、私の知識はほとんどありません。私は彼らの背後にあるコンセプトを理解することと、イメージ(またはビデオ)を見て、を検出/認識することの両方を手伝ってきました。があり、(通常)信頼係数を与えます。

顔の特徴の他の入力もCIVectorsですから、inputFocusRectは顔全体が検出された場所だと私は信じています。 Visionフレームワークがこのような出力をこのフィルタと緊密に統合できるようにするのは理にかなっています。

最後に、でした。属性内のドキュメントリンクを試してみると空になりました。

+0

ほとんどのご質問は、このビデオでお答えします:https://developer.apple.com/videos/play/wwdc2017/508 /?time = 1279 –