Python で OpenCV 2.4 を使用して 2 つの画像の特徴を一致させてきましたが、「ORB」検出器のパラメーターの 1 つ (「nfeatures」を抽出する特徴の数) を変更したいのですが、方法がないようです。 Pythonでそうしてください。
C++ の場合、FeatureDetector/DescriptorExtractor の 'read' (または java の場合は 'load') メソッドによってパラメーター yml/xml ファイルをロードできます。ただし、Python バインディングにはこの関数/メソッドがありません。
また、ORB オブジェクトを直接作成するバインディングがないため、そこにパラメーターを渡すことができません (Python バインディングでは、文字列名で cv2.DescriptorExtractor_create を使用する必要があるようです。これは、間違った文字列名またはそれと一緒にパラメーター...さらに、その関数は、コンストラクターに渡すように見える他の引数を取ることができません。
私の唯一の希望は、xml から cv2.cv.Load(filename) を使用して完全なオブジェクトをロードすることのように見えましたが、それはアルゴリズム定義ではなくオブジェクト インスタンスを期待しているようで、新しいまたは古い Python バインディングが見つかりません。構文。OpenCV から保存された xml ファイルのスタイルを模倣するなど、ファイルの読み込みステップでいくつかのバリエーションを試しましたが、うまくいきませんでした。
OpenCVでパラメーターを検出器(SURFまたはORB、または任意の汎用アルゴリズム)に渡すために上で試した手順の1つに成功した人はいますか?
機能を抽出するために使用しているコードは次のとおりです。
def findFeatures(greyimg, detector="ORB", descriptor="ORB"):
nfeatures = 2000 # No way to pass to detector...?
detector = cv2.FeatureDetector_create(detector)
descriptorExtractor = cv2.DescriptorExtractor_create(descriptor)
keypoints = detector.detect(greyimg)
(keypoints, descriptors) = descriptorExtractor.compute(greyimg, keypoints)
return keypoints, descriptors
編集
検出器の設定を変更すると、Windows の実装でセグメンテーション違反のみが発生するようです。パッチまたは修正プログラムが OpenCV のサイトに表示されるのを待っています。