Skip to content

sakusakueva/KeypointMatching_AKAZE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

キーポイントマッチング(AKAZE)のサンプルプログラム

OpenCVライブラリを使用してAKAZEを実行します.
後処理として,検出した位置を描画することができます.

動作確認済みの環境

OS:Ubuntu 20.04 macOS
OpenCV:3.4.3

事前準備

$ git clone https://github.com/sakusakueva/KeypointMatching_AKAZE.git
$ cd KeypointMatching_AKAZE

KeypointMatching_AKAZE直下で以下のコマンドを実行してコンパイルする.

$ mkdir build
$ cd build
$ cmake ..
$ make -j
$ cd ../

実行

複数のサンプルデータ(choco)に対して実行する場合,

$ bash scripts/run_choco.sh

1セットのデータ(choco/data0.png)に対して実行する場合,

$ ./keypoint_matching -tmp data/choco/template.png -input data/choco/data0.png -best_match_size=50 -use_color -use_rect -time

プログラムの解説

1. 処理の流れ

program

キーポイントマッチングは,

  1. キーポイント検出 detect()
  2. 特徴量記述 compute()
  3. マッチング match()

のステップに分かれており,1. キーポイント検出,2. 特徴量記述は一つの関数detectAndCompute()で処理することもできます.

キーポイント検出後,特徴量の類似度をもとにキーポイントをソートし,上位best_match_size個のキーポイントを使いホモグラフィ行列を算出します.(RANSAC使用)
ホモグラフィ行列を使って射影変換し対象物の位置を求めます.

なお,正解位置が分かる場合は,JudgeSuccess()関数から,検出成功か判定することができます.

AKAZEのプログラムの詳細は,こちらを参照してください.

2. 実行結果の描画

(1) 検出結果を射影変換で描画する(--use_project

projection_trans

(2) 検出結果を射影変換(矩形)で描画する(--use_rect

rect

(3) キーポイントマッチングの対応点を描画する(--use_all

all

(4) キーポイントマッチングの対応点のうちインライアのみを描画する(--use_inlier

inlier

コマンドライン引数

引数 デフォルト設定 説明
tmp cv::String data/template.png テンプレート画像のパス
input cv::String data/data0.png 入力画像のパス
best_match_size int 30 ホモグラフィ行列算出に使用するキーポイント対応数
use_color bool false モノクロ or カラー
use_project bool false キーポイントの対応点から射影変換し描画する.
use_rect bool false キーポイントの対応点から射影変換し矩形を描画する.
use_all bool false キーポイントの対応点を描画する.
use_inlier bool false キーポイントの対応点のうちインライアのみを描画する.
time t bool false 処理時間を計測する.
help h bool false コマンドライン引数の例を表示する.