2

ドローン画像の特徴検出と説明にPythonOpenCVBRISK使用して実装したいと考えています。

も記述子であるためBRISK、その説明機能を使用して 2 つの画像を一致させたいと考えています。

どうすればいいのですか?

4

1 に答える 1

5

Local Binary DescriptorでFeature Detection と Descriptionを実行してから、またはアルゴリズムを使用して、 PythonOpenCVを使用してFeature Matchingを実行できます。 BRISKBrute ForceFLANN

この例では、アルゴリズムによる特徴検出とマッチングを示します。BRISKBrute Force

まず、入力画像とトレーニングに使用する画像を読み込みます。

この例では、これらの画像を使用しています。

image1:

ここに画像の説明を入力

image2:

ここに画像の説明を入力

# Imports
import cv2 as cv
import matplotlib.pyplot as plt

# Open and convert the input and training-set image from BGR to GRAYSCALE
image1 = cv.imread(filename = 'image1.jpg',
                   flags = cv.IMREAD_GRAYSCALE)

image2 = cv.imread(filename = 'image2.jpg',
                   flags = cv.IMREAD_GRAYSCALE)

OpenCVではデフォルトのカラーモード設定がBGRであるため、画像をインポートするときにflags = cv.IMREAD_GRAYSCALEパラメータを使用することに注意してください。したがって、記述子を操作するには、カラー モード パターンをBGRからグレースケールに変換する必要があります。

BRISK次に、アルゴリズムを使用します。

# Initiate BRISK descriptor
BRISK = cv.BRISK_create()

# Find the keypoints and compute the descriptors for input and training-set image
keypoints1, descriptors1 = BRISK.detectAndCompute(image1, None)
keypoints2, descriptors2 = BRISK.detectAndCompute(image2, None)

アルゴリズムによって検出された特徴を組み合わせて、異なる画像間で類似しているオブジェクトまたはパターンを見つけることができます。BRISK

Brute Force次に、アルゴリズムを使用します。

# create BFMatcher object
BFMatcher = cv.BFMatcher(normType = cv.NORM_HAMMING,
                         crossCheck = True)

# Matching descriptor vectors using Brute Force Matcher
matches = BFMatcher.match(queryDescriptors = descriptors1,
                          trainDescriptors = descriptors2)

# Sort them in the order of their distance
matches = sorted(matches, key = lambda x: x.distance)

# Draw first 15 matches
output = cv.drawMatches(img1 = image1,
                        keypoints1 = keypoints1,
                        img2 = image2,
                        keypoints2 = keypoints2,
                        matches1to2 = matches[:15],
                        outImg = None,
                        flags = cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)

plt.imshow(output)
plt.show()

出力は次のようになります。

ここに画像の説明を入力

この手法は、画像回復アプリケーション、モーション トラッキング、オブジェクト検出、認識とトラッキング、3D オブジェクト再構築などで広く使用されています。また、画像の読み込み方法を簡単に変更できます。このようにして、この手法を問題に簡単に適用できます。

DetectionDescription、およびFeature Matching手法、Local Feature DescriptorsLocal Binary Descriptors 、およびFeature Matchingのアルゴリズムの詳細については、 GitHubの次のリポジトリをお勧めします。

于 2021-01-23T19:51:28.930 に答える