JP2021071979A - Template matching method - Google Patents
Template matching method Download PDFInfo
- Publication number
- JP2021071979A JP2021071979A JP2019199119A JP2019199119A JP2021071979A JP 2021071979 A JP2021071979 A JP 2021071979A JP 2019199119 A JP2019199119 A JP 2019199119A JP 2019199119 A JP2019199119 A JP 2019199119A JP 2021071979 A JP2021071979 A JP 2021071979A
- Authority
- JP
- Japan
- Prior art keywords
- similarity
- pixel
- processing
- image
- template matching
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Length Measuring Devices By Optical Means (AREA)
- Optical Transform (AREA)
- Image Analysis (AREA)
Abstract
Description
本発明は、テンプレートマッチング方法に関する。 The present invention relates to a template matching method.
エンコーダーの一種として光学式のロータリーエンコーダーが一般に知られている。例えば、特許文献1に記載のエンコーダーは、グレイ符号等の数値パターンおよびストライプ状のパターンが形成されているコード板を撮像素子で読み取り、読み取った数値パターンおよびストライプ状のパターンから位置を検出する。
An optical rotary encoder is generally known as a kind of encoder. For example, the encoder described in
また、特許文献1のような光学式のエンコーダーよりも高い検出精度を容易にかつ安定して実現することのできるエンコーダーとして、基準画像および撮像画像を用いて撮像画像内で基準画像と最も類似する画素座標を特定するテンプレートマッチングを行うことにより位置を検出する撮像式のエンコーダーが考えられる。
Further, as an encoder capable of easily and stably realizing higher detection accuracy than an optical encoder as in
しかしながら、このような撮像式のエンコーダーでは、経時的に生じるコード板や軸の歪み、機械的ながたつき等によって、撮像対象であるコード板と撮像素子との位置関係がずれてしまうことがある。その結果、基準画像と撮像画像とでターゲットとなるマークと画素との位置関係がずれて、基準画像と撮像画像との類似度が顕著に低下してしまう場合がある。そして、基準画像と撮像画像とでマークが異なるにもかかわらず誤ってテンプレートマッチングしてしまうおそれがある。 However, in such an image pickup type encoder, the positional relationship between the code plate to be imaged and the image sensor may shift due to distortion of the cord plate and shaft that occur over time, mechanical rattling, and the like. is there. As a result, the positional relationship between the target mark and the pixel may deviate between the reference image and the captured image, and the degree of similarity between the reference image and the captured image may be significantly reduced. Then, even though the marks are different between the reference image and the captured image, there is a risk of erroneous template matching.
本発明の適用例に係るテンプレートマッチング方法は、撮像式エンコーダーを用いて、撮像素子の撮像画像に対する基準画像との類似度を求め、
前記類似度を前記撮像画像中の前記基準画像の座標に応じて並べた類似度マップを生成し、
前記類似度マップ中の隣り合う複数の前記類似度に基づいて求めた加工類似度を前記類似度マップ中の前記類似度の座標に応じて並べた加工類似度マップを生成し、
前記加工類似度マップ中から最大の加工類似度を抽出することを特徴とする。
In the template matching method according to the application example of the present invention, the similarity between the image captured by the image sensor and the reference image is obtained by using an imaging encoder.
A similarity map in which the similarity is arranged according to the coordinates of the reference image in the captured image is generated.
A machining similarity map is generated in which the machining similarity obtained based on a plurality of adjacent similarity in the similarity map is arranged according to the coordinates of the similarity in the similarity map.
It is characterized in that the maximum processing similarity is extracted from the processing similarity map.
以下、本発明のテンプレートマッチング方法を添付図面に示す好適な実施形態に基づいて詳細に説明する。 Hereinafter, the template matching method of the present invention will be described in detail based on the preferred embodiments shown in the accompanying drawings.
図1は、本発明の実施形態に係るロボットを示す側面図である。図2は、図1のロボットが有するエンコーダーを示す断面図である。図3は、第1アームに設けられたマークを示す平面図である。図4は、エンコーダーで用いられるテンプレートマッチング方法を示すフローチャートである。図5は、基準画像を取得する方法を説明する図である。図6は、類似度マップを示す図である。図7は、図6中の領域Q1を拡大した図である。図8は、画素ずれが生じていない状態を示す図である。図9は、画素ずれが生じている状態を示す図である。図10は、画素ずれが生じている状態の類似度マップを示す図である。図11は、図10中の領域Q21を拡大した図である。図12は、図10中の領域Q22を拡大した図である。図13は、類似度マップに設定する領域を示す図である。図14および図15は、それぞれ、加工類似度マップを示す図である。図16は、類似度マップに設定する領域の変形例を示す図である。なお、以下では、説明の便宜上、図1中の上側を「上」、下側を「下」と言う。また、図1中の基台側を「基端」、その反対側(エンドエフェクター側)を「先端側」と言う。また、図1の上下方向を「鉛直方向」とし、左右方向を「水平方向」とする。 FIG. 1 is a side view showing a robot according to an embodiment of the present invention. FIG. 2 is a cross-sectional view showing an encoder included in the robot of FIG. FIG. 3 is a plan view showing a mark provided on the first arm. FIG. 4 is a flowchart showing a template matching method used in the encoder. FIG. 5 is a diagram illustrating a method of acquiring a reference image. FIG. 6 is a diagram showing a similarity map. FIG. 7 is an enlarged view of the region Q1 in FIG. FIG. 8 is a diagram showing a state in which pixel deviation does not occur. FIG. 9 is a diagram showing a state in which pixel shift occurs. FIG. 10 is a diagram showing a similarity map in a state where pixel deviation occurs. FIG. 11 is an enlarged view of the region Q21 in FIG. FIG. 12 is an enlarged view of the region Q22 in FIG. FIG. 13 is a diagram showing a region to be set in the similarity map. 14 and 15 are diagrams showing processing similarity maps, respectively. FIG. 16 is a diagram showing a modified example of the region set in the similarity map. In the following, for convenience of explanation, the upper side in FIG. 1 is referred to as “upper” and the lower side is referred to as “lower”. Further, the base side in FIG. 1 is referred to as a "base end", and the opposite side (end effector side) is referred to as a "tip side". Further, the vertical direction in FIG. 1 is defined as the "vertical direction", and the horizontal direction is defined as the "horizontal direction".
図1に示すロボット100は、水平多関節ロボットであり、例えば、精密機器等を製造する製造工程等で用いられ、精密機器や部品等の把持や搬送等を行うことができる。ロボット100は、基台110と、基台110に対して第1軸J1まわりに回動する第1アーム120と、第1アーム120に対して第2軸J2まわりに回動する第2アーム130と、第2アーム130の先端部に設けられ、第2アーム130に対して第3軸J3まわりに回動し、第3軸J3に沿って上下移動するスプラインシャフト141を備える作業ヘッド140と、スプラインシャフト141の先端部に装着されているエンドエフェクター150と、を有する。そして、このようなロボット100には、基台110に対する第1アーム120の第1軸J1まわりの回動角度を検出する第1エンコーダーや、第1アーム120に対する第2アーム130の第2軸J2まわりの回動角度を検出する第2エンコーダーが設けられている。本発明のテンプレートマッチング方法は、前記第1エンコーダーおよび前記第2エンコーダーの双方に適用可能であるが、以下、前記第1エンコーダーに適用した構成について説明し、第1エンコーダーをエンコーダー1として説明する。
The
図2に示すように、エンコーダー1は、第1アーム120に設けられているスケール部2と、基台110に設けられ、スケール部2を検出する検出部3と、検出部3に電気的に接続されている回路部4と、を有する。
As shown in FIG. 2, the
スケール部2は、第1アーム120の基台110と対向する部分に設けられている。スケール部2は、図3に示すように、第1アーム120の表面に設けられており、第1軸J1とは異なる位置で第1軸J1まわりに沿って配置されているユニークなパターンを有している。「ユニークなパターン」とは、スケール部2を第1軸J1まわりに必要な角度範囲にわたって回動させたとき、後述する撮像画像G内の所定領域に同じパターンが2回以上出現しないことを言う。そのため、スケール部2の互いに位置の異なる複数の部分のそれぞれを、スケール部2の周方向における位置識別のためのマーク21として用いることができる。なお、図3では、複数のマーク21が第1軸J1を中心とする円周に沿って並んでいる場合を図示している。また、図3に示すマーク21の位置、大きさ、数等は、一例であり、これに限定されるものではない。
The
スケール部2のユニークなパターンは、白地に複数の黒地のドット20をユニークに配置することにより構成されている。なお、ドット20の形状は、図示では円形であるが、これに限定されず、例えば、楕円形、四角形、異形状等であってもよい。また、スケール部2のパターンは、前述した複数のドット20で構成されたパターンのようなドットパターンに限定されず、例えば、直線状のラインで構成されたパターン、曲線状のラインで構成されたパターン、ドット、直線状のラインおよび曲線状のラインのうちの少なくとも2つを組み合わせて構成されたパターン、またはこれらの反転パターン等であってもよい。また、スケール部2のパターンは、検出部3で検出可能なパターンであればよく、例えば、染料、顔料等のインクで形成されたパターン、凹凸形状によるパターン、自然物に形成されているパターン等であってもよい。
The unique pattern of the
また、スケール部2のマーク21は、前述したパターンを用いたものに限定されず、例えば、数字を用いてもよいし、ローマ字、アラビア文字、漢字等の文字を用いてもよいし、文字以外の記号、符号、しるし、標章、図案、一次元バーコード、QRコード(登録商標)等を用いてもよい。
Further, the
また、スケール部2は、第1アーム120の表面に直に設けられている場合に限定されず、例えば、第1アーム120の表面に貼着されたシート状の部材に設けられていてもよいし、第1アーム120とともに回動するように設けられた板状の部材に設けられていてもよい。すなわち、スケール部2が設けられる部材は、第1アーム120とともに基台110に対して第1軸J1まわりに回動する部材であればよい。
Further, the
図2に示すように、検出部3は、基台110内に設けられている撮像素子31と、基台110が有する開口に設けられている結像光学系32と、を有する。そして、撮像素子31が結像光学系32を介してスケール部2の周方向での一部である撮像領域RIを撮像する。なお、検出部3は、必要に応じて、撮像素子31の撮像領域RIを照明するための光源を備えていてもよい。撮像素子31としては、特に限定されず、例えば、CCD(Charge Coupled Devices)、CMOS(Complementary Metal Oxide Semiconductor)等を用いることができる。
As shown in FIG. 2, the
撮像素子31は、撮影された画像を画素ごとの電気信号に変換して出力する。撮像素子31は、二次元撮像素子(エリアイメージセンサ)、あるいは一次元撮像素子(ラインイメージセンサ)のどちらでも適用可能である。二次元撮像素子を用いた場合は、情報量の多い二次元画像を取得でき、後述のテンプレートマッチングによるマーク21の検出精度を高めやすい。その結果、第1アーム120の回動状態を高精度に検出することができる。一方、一次元撮像素子を用いた場合は、画像取得周期いわゆるフレームレートが高いため、検出頻度を高めることが可能になり、高速動作時に有利となる。
The
ここで、図3に示すように、撮像素子31の撮像領域RIは、第1アーム120の下面に、スケール部2の周方向での一部に重なるように設定されている。これにより、撮像素子31は、撮像領域RI内にあるマーク21を撮像することができる。したがって、撮像領域RIに位置するマーク21を読み取ることにより、第1アーム120の回動状態を知ることができる。
Here, as shown in FIG. 3, the image pickup region RI of the
図2に示すように、回路部4は、CPU(Central Processing Unit)、テンプレートマッチング専用演算回路等の処理部5と、ROM(Read only memory)、RAM(Random Access Memory)等の記憶部6と、を有する。ここで、記憶部6には、処理部5で読み取り可能な指示が記憶されており、処理部5は、記憶部6から指示を適宜読み取って実行することで、各種機能を実現する。このような回路部4は、例えば、ASIC(application specific integrated circuit)またはFPGA(field-programmable gate array)等を用いて構成することができる。このようにASICまたはFPGAを用いて回路部4をハードウエア化することで、回路部4の高処理速度化、小型化および低コスト化を図ることできる。
As shown in FIG. 2, the
処理部5は、検出部3の検出結果に基づいて、基台110および第1アーム120の相対的な回動状態を推定する。この回動状態としては、例えば、回動角度、回動速度、回動方向等が挙げられる。特に、処理部5は、撮像素子31の撮像画像に対して基準画像を用いてテンプレートマッチングすることでマーク21を画像認識し、その認識結果を用いて、基台110に対する第1アーム120の回動角度を推定する。以下、基準画像の取得について詳述する。また、処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定について、図4に示すフローチャートに基づいて詳述する。
The
処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定は、撮像素子31を用いて撮像画像Gを取得する撮像画像取得ステップと、基準画像TAを用いて撮像画像Gに対してテンプレートマッチングを行って類似度マップM1を生成する類似度マップ生成ステップと、類似度マップM1に基づいて加工類似度マップM2を生成する加工類似度マップ生成ステップと、加工類似度マップM2および類似度マップM1に基づいて、第1アーム120の位置を推定する推定ステップと、を有する。以下、図4に示すフローチャートに基づいて、詳細に説明する。
The template matching in the
1.基準画像の取得
エンコーダー1は、テンプレートマッチングを用いて基台110に対する第1アーム120の回動状態を推定するのに先立って、テンプレートマッチングに用いる基準画像TAを予め取得する。この基準画像TAの取得は、最初のテンプレートマッチングの前に1回行うだけでよいが、その後必要に応じて適時行ってもよい。その場合、テンプレートマッチングに用いる基準画像TAを、新たに取得した基準画像TAに更新することができる。
1. 1. Acquisition of Reference Image The
基準画像を取得する際には、第1アーム120を基台110に対して第1軸J1まわりに適宜回動させ、撮像素子31で複数のマーク21をそのマーク21毎に撮像する。そして、得られた各撮像画像Gをトリミングして不要部分を削除することにより、マーク21毎の基準画像TAを生成する。つまり、マーク21の数だけ基準画像TAを生成する。生成された各基準画像TAは、その画素座標情報および角度情報とともにこれらに対応付けられて記憶部6に記憶される。
When acquiring the reference image, the
より具体的に説明すると、図5に示すように、撮像画像Gは、撮像領域RIに対応した形状であって、X方向に沿って延びている2つの辺と、X方向に直交するY方向に沿って延びている2つの辺とを有する矩形をなす。また、撮像画像GのX軸方向に沿って延びている2つの辺は、矢印で示すマーク21の移動方向にできるだけ沿うように配置されている。また、撮像画像Gは、X方向およびY方向に行列状に並んでいる複数の画素を有する。ここで、画素の位置は、X方向での画素の位置を示す「X」、および、Y方向での画素の位置を示す「Y」で表される画素座標系(X,Y)で表される。また、撮像画像Gの図中左上端の画素が画像座標系(X,Y)の原点画素(0,0)に設定されている。
More specifically, as shown in FIG. 5, the captured image G has a shape corresponding to the imaging region RI, and has two sides extending along the X direction and the Y direction orthogonal to the X direction. It forms a rectangle with two sides extending along. Further, the two sides extending along the X-axis direction of the captured image G are arranged so as to be along the moving direction of the
例えば、図5中のマーク21Aに対応する基準画像TAを生成する場合、第1アーム120を基台110に対して適宜回動させ、マーク21Aを撮像画像G内の所定位置、図示ではX軸方向での中央に設定された中心線LY上に位置させる。なお、マーク21が中心線LY上に位置するときの、基台110に対する第1アーム120の回動角度θA0は、測定等により事前に取得されている。
For example, when generating the reference image TA corresponding to the
次に、マーク21を中心線LY上に位置させた状態を撮像素子31で撮像し、得られた撮像画像Gを、マーク21Aを包含する必要最小限の範囲となるような矩形の画素範囲でトリミングする。これにより、マーク21Aに対応する基準画像TAが得られ、得られた基準画像TAは、記憶部6に記憶される。このとき、基準画像TAは、前述した回動角度θA0に関する角度情報および基準画像TAの画素範囲に含まれる基準画素P0の画素座標である基準画素座標(Xp0,Yp0)に関する画素情報とともに、これらに対応付けられて記憶される。すなわち、基準画像TA、角度情報および画素座標情報がテンプレートマッチングに用いる1つのテンプレートセットとなる。
Next, the state in which the
エンコーダー1がアブソリュート型である場合、このテンプレートセットにおける角度情報は絶対角度である。また、エンコーダー1がインクリメント型である場合、このテンプレートセットにおける角度情報は相対角度である。
When the
2.テンプレートマッチングおよびそれを用いた回動状態の推定
以下、処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定について詳述する。
2. Template matching and estimation of the rotating state using the template matching The template matching in the
[撮像画像取得ステップ]
まず、処理部5は、撮像素子31を用い、スケール部2の一部である撮像領域RIを撮像して、撮像画像Gを得る(ステップS1)。
[Captured image acquisition step]
First, the
[類似度マップ生成ステップ]
まず、処理部5は、撮像素子31の撮像画像Gに対して、予め準備しておいた基準画像TAを用いてテンプレートマッチングを行って類似度マップM1を生成する(ステップS2)。具体的には、処理部5は、撮像画像Gの全域を探索領域とし、探索領域に基準画像TAを重ね、探索領域と基準画像TAとの重なり部分の類似度を算出する。処理部5は、基準画像TAを、撮像画像Gの画素配列に沿って移動させて、探索領域全域の画素について、探索領域と基準画像TAとの重なり部分の類似度を算出する。具体的には、処理部5は、基準画像TA中に設定されている基準画素P0の画素座標(Xp,Yp)を開始座標PSpから終了画素PEpまで1画素ずつ移動し、探索領域全域の画素について、探索領域と基準画像TAとの重なり部分の類似度を算出する。つまり、処理部5は、類似度を基準画像TAの基準画素P0の画素座標(Xp,Yp)ごとに算出する。そして、処理部5は、画素座標(Xp,Yp)毎に算出した類似度を画素座標(Xp,Yp)の位置に対応させて並べた、つまり、画素座標(Xp,Yp)の並び順に沿って並べた図6および図7に示すような類似度マップM1を生成する。このとき、類似度マップM1は、類似度が極大となる点、すなわち、ピークが複数含まれるマップとなる。図7に示す領域Q1は、類似度が最大となる画素座標(Xp,Yp)=(Xn,Yn)を含む領域である。生成された類似度マップM1は、記憶部6に記憶される。類似度を求める手法としては、SAD、SSD、ZNCCなどがある。SAD、SSDではその値が最小、ZNCCではその値が最大のとき類似度最大となる。なお、図では、SADを用いて求めた相違度を類似度として記載しているため、値が最小のときに類似度が最大となる。
[Similarity map generation step]
First, the
なお、従来のテンプレートマッチングであれば、次に、処理部5は、記憶部6に記憶されている類似度マップM1から最大値の類似度を選択する。図7の例では、画素座標(Xp,Yp)=(Xn,Yn)の類似度を選択する。そして、処理部5は、選択した類似度に対応する基準画像TAの基準画素P0の画素座標(Xp,Yp)をマーク21の画素座標として決定し、撮像画像G内でのマーク21の位置を検出する。
In the case of conventional template matching, the
ここで、例えば、図8に示すように、基準画像TAと撮像画像Gとでターゲットとなるマーク21Aと画素Pxとの位置関係が同じであれば、図7に示す類似度マップM1のように、画素座標(Xp,Yp)=(Xn,Yn)において実測される類似度が、他の画素座標(Xp,Yp)において実測される類似度よりも十分に大きくなる。そのため、撮像画像G中のマーク21Aの位置を精度よく検出することができる。
Here, for example, as shown in FIG. 8, if the positional relationship between the
これに対して、図9に示すように、基準画像TAと撮像画像Gとでターゲットとなるマーク21Aと画素Pxとの位置関係が0.5画素程度ずれてしまう場合がある。この場合、類似度が最大となるピークも0.5画素程度ずれてしまう。図10に、画素ずれが生じた状態で生成された類似度マップM1を示す。図11に示す領域Q21は、画素ずれが無かった場合に類似度が最大となる画素座標(Xp,Yp)=(Xn,Yn)を含む領域である。図12に示す領域Q22は、ターゲットとなるマーク21Aと似ているが異なるマーク21が存在している画素座標(Xp,Yp)=(Xz,Yz)を含む領域である。類似度は、1画素単位と離散的に算出されるため、図11に示す類似度マップM1のように、隣り合っている画素座標(Xp,Yp)=(Xn,Yn)の基準画像TAと画素座標(Xp,Yp)=(Xn−1,Yn)の基準画像TAとで、類似度が最大となるピークの類似度を分け合ってしまう。そのため、画素座標(Xp,Yp)=(Xn,Yn)において実測される類似度が画素ずれが無かった場合の類似度から大幅に低下する。したがって、撮像画像G内にターゲットとなるマーク21Aと似たマーク21が存在している場合等では、図11および図12に示すように、撮像画像G内に画素座標(Xp,Yp)=(Xn,Yn)において実測される類似度よりも大きい類似度を有する画素座標(Xp,Yp)=(Xz,Yz)が発生する「逆転現象」が生じるおそれがある。言い換えると、類似度マップM1から類似度が最大となるピークを探索する際に、1画素単位で離散的に類似度をサンプリングするため、例えば、サンプリング範囲が、最大となるピークを画素ずれにより外し、かつ次に大きいピークと一致し、さらに、最大となるピークと次に大きいピークとの類似度の差が小さい場合には、「逆転現象」を生じることがある。このような逆転現象が生じると、処理部5は、画素座標(Xp,Yp)=(Xz,Yz)をマーク21Aの画素座標として決定してしまう。その結果、マーク21Aの位置が誤って決定されてしまう。
On the other hand, as shown in FIG. 9, the positional relationship between the
そこで、このようなマーク21の位置の誤決定を抑制するために、本実施形態の処理部5は、類似度マップM1を生成した後に、次のような処理を実行する。
Therefore, in order to suppress such erroneous determination of the position of the
[加工類似度マップ生成ステップ]
まず、処理部5は、記憶部6に記憶されている類似度マップM1を加工して、加工類似度マップM2を生成する(ステップS3)。具体的には、まず、処理部5は、図13に示すように、X方向およびY方向に隣り合って並ぶ2行2列の計4つの画素座標(Xp,Yp)を含む正方形状の領域Rを設定する。次に、処理部5は、領域R内に含まれる4つの画素座標(Xp,Yp)の類似度の平均値を加工類似度として算出する。処理部5は、領域Rを、類似度マップM1の座標に沿って移動させて、類似度マップM1全域の座標について加工類似度を算出する。具体的には、処理部5は、領域R中に設定されている基準画素座標S0の座標(Xs,Ys)を開始座標PSsから終了画素PEsまで1座標ずつ移動し、類似度マップM1全域の座標について、加工類似度を算出する。つまり、処理部5は、加工類似度を基準画素座標S0の座標(Xs,Ys)ごとに算出する。
[Processing similarity map generation step]
First, the
そして、処理部5は、座標(Xs,Ys)毎に算出された加工類似度を座標(Xs,Ys)の位置に対応させて並べた、すなわち、座標(Xs,Ys)の並び順に沿って並べた図14および図15に示すような加工類似度マップM2を生成する。生成された加工類似度マップM2は、記憶部6に記憶される。図14に示す加工類似度マップM2は、図11に示す類似度マップM1に対応し、図15に示す加工類似度マップM2は、図12に示す類似度マップM1に対応する。なお、加工類似度としては、領域Rに含まれる4つの類似度の平均値に限定されず、例えば、4つの類似度の合計値であってもよい。加工類似度を領域Rに含まれる4つの類似度の平均値や合計値とすることにより、加工類似度を求めやすくなる。加工類似度としては、この他にも、例えば、4つの類似度を所定の公式に代入して求められる値であってもよい。
Then, the
[推定ステップ]
次に、処理部5は、記憶部6に記憶されている加工類似度マップM2に含まれている複数の加工類似度から、最大の加工類似度を抽出する(ステップS4)。次に、処理部5は、抽出した加工類似度に対応する領域R中に含まれる4つの類似度から、最大の類似度を抽出する(ステップS5)。そして、処理部5は、類似度マップM1に基づいて、抽出した類似度に対応する基準画像TAの基準画素P0の画素座標(Xp,Yp)=(Xn,Yn)をマッチング位置、つまり、マーク21の画素座標として決定する(ステップS6)。さらに、処理部5は、決定したマッチング位置、つまり、画素座標に基づく回動角度θを出力する(ステップS7)。
[Estimation step]
Next, the
このとき、基準画素座標(Xp0,Yp0)にある基準画像TAに対してX軸方向に画素数(Xn−Xp0)分ずれた位置にあることとなる。したがって、撮像領域RIの中心と第1軸J1との間の距離をrとし、撮像素子31の1画素に対応する撮像領域RI上の領域のX軸方向での幅(撮像素子31の1画素あたりの視野サイズ)をWとしたとき、基台110に対する第1アーム120の回動角度θは、下記式(1)を用いて求めることができる。
At this time, the position is deviated from the reference image TA at the reference pixel coordinates (Xp0, Yp0) by the number of pixels (Xn−Xp0) in the X-axis direction. Therefore, the distance between the center of the image pickup region RI and the first axis J1 is r, and the width of the region on the image pickup region RI corresponding to one pixel of the
この式(1)において、(Xn−Xp0)×Wは、基準画像TAの基準画素座標(Xp0,Yp0)に対応する実位置と、前述した類似度が最大値となる基準画像TAの画素座標(Xn,Yn)に対応する実位置との間の距離に相当する。また、2rπは、基台110に対して第1アーム120が360°回転したときのマーク21の軌跡の長さ(円周の長さ)に相当する。なお、θA0は、前述したように、マーク21Aが所定位置に位置するときの、基台110に対する第1アーム120の回動角度である。また、回動角度θは、第1アーム120が基台110に対して基準状態(0°)から回動した角度である。
In this formula (1), (Xn-Xp0) × W is the actual position corresponding to the reference pixel coordinates (Xp0, Yp0) of the reference image TA and the pixel coordinates of the reference image TA in which the above-mentioned similarity is the maximum value. It corresponds to the distance from the actual position corresponding to (Xn, Yn). Further, 2rπ corresponds to the length (circumferential length) of the locus of the
以上により、基台110に対する第1アーム120の回動角度θが推定される。このようなテンプレートマッチングおよびそれを用いた回動角度θの算出を他のマーク21についても同様に行う。ここで、任意の回動角度θにおいて、撮像画像G内に少なくとも1つのマーク21が欠けなく映り、かつ、テンプレートマッチング可能なように各マーク21に対応した基準画像が登録されている。これにより、テンプレートマッチングが不可能な角度範囲が生じることを防止することができる。
From the above, the rotation angle θ of the
加工類似度マップM2によれば、隣り合う座標が有する類似度の平均値を加工類似度としているため、隣り合う座標で分け合った類似度を足し合わせることができ、類似度マップM1における類似度のピークを画素幅で平均化したのと同じ効果を生じる。そのため、加工類似度マップM2を用いて1画素単位で離散的に類似度をサンプリングした場合、サンプリング範囲が最大となるピークを外すか一致するかにかかわらず同じサンプリング値を得ることができ、最大となるピークと次に大きいピークとの類似度の差が小さい場合であっても、間違えることがない。したがって、図9で示したような画素ずれの影響をキャンセルすることができ、マーク21の画素座標として、画素座標(Xp,Yp)=(Xn,Yn)ではなく、画素座標(Xp,Yp)=(Xz,Yz)を誤って選択してしまうことを効果的に抑制することができる。このように、上述の方法によれば、優れた検出精度を発揮することができる。
According to the processing similarity map M2, since the average value of the similarity between the adjacent coordinates is used as the processing similarity, the similarity divided by the adjacent coordinates can be added up, and the similarity in the similarity map M1 can be added up. It produces the same effect as averaging the peaks by pixel width. Therefore, when the similarity is discretely sampled in units of one pixel using the processing similarity map M2, the same sampling value can be obtained regardless of whether the peak that maximizes the sampling range is removed or matches, and the maximum is obtained. Even if the difference in similarity between the peak and the next largest peak is small, there is no mistake. Therefore, the influence of the pixel shift as shown in FIG. 9 can be canceled, and the pixel coordinates of the
特に、本実施形態では、領域Rが、X方向およびY方向に隣り合って並ぶ2行2列の計4つの画素座標(Xp,Yp)を含む正方形状となっている。そのため、領域Rには、X方向に隣り合う画素座標(Xp,Yp)が含まれ、Y方向に隣り合う画素座標(Xp,Yp)が含まれ、X、Y方向の両方向に対して45°傾斜する斜め方向に隣り合う画素座標(Xp,Yp)が含まれている。したがって、図9に示すような画素ずれが、X方向、Y方向、斜め方向のいかなる方向に生じても、画素ずれの影響を加工類似度マップM2によってキャンセルすることができる。また、図9に示す画素ずれは、最大で1画素未満であるため、X方向、Y方向、斜め方向のそれぞれで隣り合う2つの画素座標(Xp,Yp)が含まれていれば十分である。そのため、領域Rに無駄な画素座標(Xp,Yp)が含まれることを抑制することができ、この無駄な画素座標(Xp,Yp)の類似度が平均化に用いられることにより生じるノイズが実質的に生じない。そのため、2行2列の領域Rとすることにより、より優れた検出精度を発揮することができる。 In particular, in the present embodiment, the region R has a square shape including a total of four pixel coordinates (Xp, Yp) of 2 rows and 2 columns arranged adjacently in the X direction and the Y direction. Therefore, the region R includes pixel coordinates (Xp, Yp) adjacent to each other in the X direction, pixel coordinates (Xp, Yp) adjacent to each other in the Y direction, and 45 ° with respect to both directions of the X and Y directions. Pixel coordinates (Xp, Yp) adjacent to each other in the oblique direction of inclination are included. Therefore, even if the pixel shift as shown in FIG. 9 occurs in any of the X direction, the Y direction, and the oblique direction, the influence of the pixel shift can be canceled by the processing similarity map M2. Further, since the pixel shift shown in FIG. 9 is less than one pixel at the maximum, it is sufficient if two adjacent pixel coordinates (Xp, Yp) are included in each of the X direction, the Y direction, and the oblique direction. .. Therefore, it is possible to suppress the inclusion of useless pixel coordinates (Xp, Yp) in the region R, and the noise generated by using the similarity of the useless pixel coordinates (Xp, Yp) for averaging is substantially present. Does not occur. Therefore, better detection accuracy can be exhibited by setting the region R in 2 rows and 2 columns.
なお、領域Rとしては、上述した2行2列の形状が最も好ましいが、これに限定されず、X方向、Y方向および斜め方向の少なくとも1つの方向に隣り合って並ぶ2つの画素座標(Xp,Yp)を含んでいればよい。ただし、この中でも、X方向およびY方向に隣り合って並ぶ3行3列の計9つの画素座標(Xp,Yp)から選択することが好ましい。これにより、領域Rに無駄な画素座標(Xp,Yp)が含まれることを抑制することができ、ノイズの少ない加工類似度を求めることができる。なお、3行3列の計9つの画素座標(Xp,Yp)から選択される領域Rとしては、特に限定されないが、例えば、図16に示すような、十字型をなす領域R1、格子型をなす領域R2等が挙げられる。 As the region R, the above-mentioned two-row, two-column shape is most preferable, but the region R is not limited to this, and two pixel coordinates (Xp) arranged adjacent to each other in at least one direction of the X direction, the Y direction, and the diagonal direction. , Yp) may be included. However, among these, it is preferable to select from a total of nine pixel coordinates (Xp, Yp) of 3 rows and 3 columns arranged adjacently in the X direction and the Y direction. As a result, it is possible to prevent the region R from including unnecessary pixel coordinates (Xp, Yp), and it is possible to obtain a processing similarity with less noise. The region R selected from a total of nine pixel coordinates (Xp, Yp) in 3 rows and 3 columns is not particularly limited, but for example, as shown in FIG. 16, a cross-shaped region R1 and a grid type are used. An eggplant region R2 and the like can be mentioned.
また、エンコーダー1の構成によっては、X方向の画素ずれだけが生じる場合も考えられる。この場合には、例えば、図16に示すような、X方向に隣り合って並んだ2つの画素座標(Xp,Yp)を含む領域R3とすることができる。同様に、エンコーダー1の構成によっては、Y方向の画素ずれだけが生じる場合も考えられる。この場合には、例えば、図16に示すような、Y方向に隣り合って並んだ2つの画素座標(Xp,Yp)を含む領域R4とすることができる。同様に、エンコーダー1の構成によっては、斜め方向の画素ずれだけが生じる場合も考えられる。この場合には、例えば、図16に示すような、斜め方向に隣り合って並んだ2つの画素座標(Xp,Yp)を含む領域R5とすることができる。これにより、よりノイズの少ない加工類似度を求めることができる。
Further, depending on the configuration of the
以上、本実施形態のテンプレートマッチング方法について説明した。このようなテンプレートマッチング方法は、前述したように、撮像式エンコーダーであるエンコーダー1を用いて、撮像素子31の撮像画像Gに対する基準画像TAとの類似度を求め、基準画像TAと撮像画像Gとの類似度を撮像画像G中の基準画像TAの座標(Xp,Yp)に応じて並べた類似度マップM1を生成し、類似度マップM1中の隣り合う複数の類似度に基づいて求めた加工類似度を類似度マップM1中の類似度の座標(Xs,Ys)に応じて並べた加工類似度マップM2を生成し、加工類似度マップM2中から最大の加工類似度を抽出する。このような方法によれば、図9で示したような画素ずれの影響をキャンセルすることができ、マーク21の画素座標として、画素座標(Xp,Yp)=(Xn,Yn)ではなく、画素座標(Xp,Yp)=(Xz,Yz)を誤って選択してしまうことを効果的に抑制することができる。したがって、このような方法によれば、優れた検出精度を発揮することができる。
The template matching method of the present embodiment has been described above. In such a template matching method, as described above, the
また、前述したように、テンプレートマッチング方法は、抽出した加工類似度を求めるのに用いた複数の類似度から最大の類似度を抽出する。これにより、マーク21の画素座標として、画素座標(Xp,Yp)=(Xn,Yn)ではなく、画素座標(Xp,Yp)=(Xz,Yz)を誤って選択してしまうことを効果的に抑制することができる。したがって、このような方法によれば、優れた検出精度を発揮することができる。
Further, as described above, the template matching method extracts the maximum similarity from a plurality of similarity used to obtain the extracted processing similarity. As a result, it is effective to mistakenly select the pixel coordinates (Xp, Yp) = (Xz, Yz) instead of the pixel coordinates (Xp, Yp) = (Xn, Yn) as the pixel coordinates of the
また、前述したように、抽出した類似度を有する基準画像TAの位置すなわち画素座標(Xp,Yp)を検出位置として決定する。これにより、精度のよい位置検出を行うことができる。 Further, as described above, the position of the extracted reference image TA having the similarity, that is, the pixel coordinates (Xp, Yp) is determined as the detection position. As a result, accurate position detection can be performed.
また、前述したように、加工類似度は、複数の類似度の平均値である。これにより、加工類似度を簡単に求めることができる。また、より確実に、図9で示したような画素ずれの影響をキャンセルすることがでる。 Further, as described above, the processing similarity is an average value of a plurality of similarity. Thereby, the processing similarity can be easily obtained. Further, it is possible to more reliably cancel the influence of the pixel shift as shown in FIG.
また、前述したように、加工類似度は、複数の類似度の合計値である。これにより、加工類似度を簡単に求めることができる。また、より確実に、図9で示したような画素ずれの影響をキャンセルすることがでる。 Further, as described above, the processing similarity is the total value of a plurality of similarity. Thereby, the processing similarity can be easily obtained. Further, it is possible to more reliably cancel the influence of the pixel shift as shown in FIG.
また、前述したように、加工類似度マップM2中では、複数の類似度が互いに直交するX方向およびY方向に並んで行列状に配置されている。そして、3行3列の行列状となるように配列されているX方向およびY方向に隣り合う9つの類似度の中から選択された複数の類似度を用いて加工類似度を求める。これにより、ノイズの少ない加工類似度を求めることができる。 Further, as described above, in the processing similarity map M2, a plurality of similarities are arranged in a matrix in the X direction and the Y direction which are orthogonal to each other. Then, the processing similarity is obtained by using a plurality of similarities selected from nine similarities adjacent to each other in the X direction and the Y direction arranged so as to form a matrix of 3 rows and 3 columns. As a result, it is possible to obtain a processing similarity with less noise.
また、前述したように、2行2列の行列状となるように配列されているX方向およびY方向に隣り合う4つの類似度を用いて加工類似度を求める。これにより、よりノイズの少ない加工類似度を求めることができる。 Further, as described above, the processing similarity is obtained by using four similarities adjacent to each other in the X direction and the Y direction, which are arranged so as to form a matrix of 2 rows and 2 columns. As a result, it is possible to obtain a processing similarity with less noise.
以上、本発明のテンプレートマッチング方法を図示の好適な実施形態に基づいて説明したが、本発明はこれに限定されるものではなく、各部の構成や各ステップは、同様の機能を有する任意の構成のものに置換することができる。また、他の任意の構成物やステップが付加されていてもよい。また、前述した2つ以上の実施形態の構成を組み合わせてもよい。 Although the template matching method of the present invention has been described above based on the preferred embodiment shown in the illustration, the present invention is not limited to this, and the configuration of each part and each step have any configuration having the same function. Can be replaced with one. Further, any other components or steps may be added. Further, the configurations of the two or more embodiments described above may be combined.
また、前述したエンコーダー1は、アブソリュート型およびインクリメンタル型のいずれの形式にも適用可能である。また、エンコーダー1は、ロータリーエンコーダーだけではなく、リニアエンコーダーにも適用可能である。
Further, the above-mentioned
また、前述したエンコーダー1は、前述した第2軸J2まわりの回動角度を検出する第2エンコーダーに適用してもよい。また、前述したエンコーダー1は、前述した水平多関節ロボット以外の型のロボット、例えば、6軸多関節ロボット、双腕ロボット等にも設置可能である。また、エンコーダー1は、ロボット100以外の電子機器、例えば、プリンター、プロジェクター等に搭載してもよい。さらには、エンコーダー1、車輌、航空機、船舶等の移動体に搭載してもよい。
Further, the above-mentioned
1…エンコーダー、2…スケール部、20…ドット、21、21A…マーク、3…検出部、31…撮像素子、32…結像光学系、4…回路部、5…処理部、6…記憶部、100…ロボット、110…基台、120…第1アーム、130…第2アーム、140…作業ヘッド、141…スプラインシャフト、150…エンドエフェクター、G…撮像画像、J1…第1軸、J2…第2軸、J3…第3軸、LY…中心線、M1…類似度マップ、M2…加工類似度マップ、P0…基準画素、PEp…終了画素、PEs…終了画素、PSp…開始座標、PSs…開始座標、Px…画素、R、R1、R2、R3、R4、R5…領域、RI…撮像領域、S0…基準画素座標、S1〜S7…ステップ、TA…基準画像 1 ... Encoder, 2 ... Scale unit, 20 ... Dot, 21, 21A ... Mark, 3 ... Detection unit, 31 ... Imaging element, 32 ... Imaging optical system, 4 ... Circuit unit, 5 ... Processing unit, 6 ... Storage unit , 100 ... robot, 110 ... base, 120 ... first arm, 130 ... second arm, 140 ... work head, 141 ... spline shaft, 150 ... end effector, G ... captured image, J1 ... first axis, J2 ... 2nd axis, J3 ... 3rd axis, LY ... center line, M1 ... similarity map, M2 ... processing similarity map, P0 ... reference pixel, PEp ... end pixel, PEs ... end pixel, PSp ... start coordinate, PSs ... Start coordinates, Px ... pixels, R, R1, R2, R3, R4, R5 ... regions, RI ... imaging regions, S0 ... reference pixel coordinates, S1 to S7 ... steps, TA ... reference images
Claims (7)
前記類似度を前記撮像画像中の前記基準画像の座標に応じて並べた類似度マップを生成し、
前記類似度マップ中の隣り合う複数の前記類似度に基づいて求めた加工類似度を前記類似度マップ中の前記類似度の座標に応じて並べた加工類似度マップを生成し、
前記加工類似度マップ中から最大の加工類似度を抽出することを特徴とするテンプレートマッチング方法。 Using an imaging encoder, determine the similarity of the image captured by the image sensor with the reference image.
A similarity map in which the similarity is arranged according to the coordinates of the reference image in the captured image is generated.
A machining similarity map is generated in which the machining similarity obtained based on a plurality of adjacent similarity in the similarity map is arranged according to the coordinates of the similarity in the similarity map.
A template matching method characterized by extracting the maximum machining similarity from the machining similarity map.
2行2列の行列状となるように配列されている前記X方向および前記Y方向に隣り合う4つの前記類似度を用いて前記加工類似度を求める請求項1ないし5のいずれか1項に記載のテンプレートマッチング方法。 In the processing similarity map, a plurality of the similarities are arranged in a matrix in the X and Y directions orthogonal to each other.
In any one of claims 1 to 5, the processing similarity is obtained by using the four similarities adjacent to each other in the X direction and the Y direction, which are arranged in a matrix of 2 rows and 2 columns. Described template matching method.
3行3列の行列状となるように配列されている前記X方向および前記Y方向に隣り合う9つの前記類似度の中から選択された複数の前記類似度を用いて前記加工類似度を求める請求項1ないし5のいずれか1項に記載のテンプレートマッチング方法。 In the processing similarity map, a plurality of the similarities are arranged in a matrix in the X and Y directions orthogonal to each other.
The processing similarity is obtained using a plurality of the similarity selected from the nine adjacent similarity in the X direction and the Y direction arranged in a matrix of 3 rows and 3 columns. The template matching method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019199119A JP2021071979A (en) | 2019-10-31 | 2019-10-31 | Template matching method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019199119A JP2021071979A (en) | 2019-10-31 | 2019-10-31 | Template matching method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2021071979A true JP2021071979A (en) | 2021-05-06 |
Family
ID=75713313
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2019199119A Pending JP2021071979A (en) | 2019-10-31 | 2019-10-31 | Template matching method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2021071979A (en) |
-
2019
- 2019-10-31 JP JP2019199119A patent/JP2021071979A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4418841B2 (en) | Working device and calibration method thereof | |
US9495749B2 (en) | Method and system for detecting pose of marker | |
CN110160566B (en) | Encoder unit, angle detection method, and robot | |
CN108489486A (en) | Quick Response Code and be used for robotic vision-inertia combined navigation system and method | |
CN110763204B (en) | Planar coding target and pose measurement method thereof | |
JP6809245B2 (en) | robot | |
JP2008036918A (en) | Screen printing equipment, and method for image recognition and alignment | |
CN109556510B (en) | Position detection device and computer-readable storage medium | |
TWI628415B (en) | Positioning and measuring system based on image scale | |
CN114332486A (en) | Visual precision measurement method for center point of round steel seal | |
JP2021071979A (en) | Template matching method | |
JP2013134176A (en) | Imaging apparatus and imaging method | |
JP2010091525A (en) | Pattern matching method of electronic component | |
JP2021157378A (en) | Template matching method for imaging type encoder | |
JP5280337B2 (en) | Character recognition method and character recognition device | |
JP2021072000A (en) | Template matching method | |
WO2019013035A1 (en) | Position measurement system and position measurement method | |
JP5605491B2 (en) | Chassis dynamometer | |
JP5446502B2 (en) | Chassis dynamometer | |
JP6655422B2 (en) | Image processing apparatus, mounting apparatus, image processing method, and program | |
JP2010151582A (en) | Camera calibration target and camera calibration method | |
KR20120134962A (en) | Method for recognizing coordinate from coordinate pattern on pattern sheet | |
JP3714459B2 (en) | Position detection method for moving objects | |
JP5434724B2 (en) | Image processing apparatus and image processing program | |
CN112020730A (en) | Method for detecting the arrangement of cameras of a moving carrier platform relative to each other and for detecting the arrangement of cameras relative to an object outside the moving carrier platform |