JP2021071979A - Template matching method - Google Patents

Template matching method Download PDF

Info

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
Application number
JP2019199119A
Other languages
Japanese (ja)
Inventor
近藤 貴幸
Takayuki Kondo
貴幸 近藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Seiko Epson Corp
Original Assignee
Seiko Epson Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Seiko Epson Corp filed Critical Seiko Epson Corp
Priority to JP2019199119A priority Critical patent/JP2021071979A/en
Publication of JP2021071979A publication Critical patent/JP2021071979A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Length Measuring Devices By Optical Means (AREA)
  • Optical Transform (AREA)
  • Image Analysis (AREA)

Abstract

To provide a template matching method having an excellent detection accuracy.SOLUTION: A template matching method includes: a step S2 of generating a similarity map M1 in which similarities of a reference image with a picked-up image from an image pick-up device are arranged according to the coordinates of the reference image in the picked-up image by using an imaging-type encoder; a step S3 of generating a processing similarity map M2 in which processing similarities obtained based on the plurality of similarities adjacent to each other in the similarity map M1 are arranged according to the coordinates of the similarities in the similarity map; and a step S4 of extracting the maximum processing similarity from the processing similarity map M2.SELECTED DRAWING: Figure 4

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 Patent Document 1 reads a code plate on which a numerical pattern such as a Gray code and a striped pattern are formed by an image sensor, and detects a position from the read numerical pattern and the striped pattern.

また、特許文献1のような光学式のエンコーダーよりも高い検出精度を容易にかつ安定して実現することのできるエンコーダーとして、基準画像および撮像画像を用いて撮像画像内で基準画像と最も類似する画素座標を特定するテンプレートマッチングを行うことにより位置を検出する撮像式のエンコーダーが考えられる。 Further, as an encoder capable of easily and stably realizing higher detection accuracy than an optical encoder as in Patent Document 1, the reference image and the captured image are used and are most similar to the reference image in the captured image. An image pickup type encoder that detects a position by performing template matching that specifies pixel coordinates can be considered.

特開昭63−187118号公報Japanese Unexamined Patent Publication No. 63-187118

しかしながら、このような撮像式のエンコーダーでは、経時的に生じるコード板や軸の歪み、機械的ながたつき等によって、撮像対象であるコード板と撮像素子との位置関係がずれてしまうことがある。その結果、基準画像と撮像画像とでターゲットとなるマークと画素との位置関係がずれて、基準画像と撮像画像との類似度が顕著に低下してしまう場合がある。そして、基準画像と撮像画像とでマークが異なるにもかかわらず誤ってテンプレートマッチングしてしまうおそれがある。 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.

本発明の実施形態に係るロボットを示す側面図である。It is a side view which shows the robot which concerns on embodiment of this invention. 図1のロボットが有するエンコーダーを示す断面図である。It is sectional drawing which shows the encoder which the robot of FIG. 1 has. 第1アームに設けられたマークを示す平面図である。It is a top view which shows the mark provided on the 1st arm. エンコーダーで用いられるテンプレートマッチング方法を示すフローチャートである。It is a flowchart which shows the template matching method used in the encoder. 基準画像を取得する方法を説明する図である。It is a figure explaining the method of acquiring a reference image. 類似度マップを示す図である。It is a figure which shows the similarity map. 図6中の領域Q1を拡大した図である。It is an enlarged view of the region Q1 in FIG. 画素ずれが生じていない状態を示す図である。It is a figure which shows the state which the pixel shift does not occur. 画素ずれが生じている状態を示す図である。It is a figure which shows the state which the pixel shift occurs. 画素ずれが生じている状態の類似度マップを示す図である。It is a figure which shows the similarity degree map in the state where a pixel shift occurs. 図10中の領域Q21を拡大した図である。It is an enlarged view of the region Q21 in FIG. 図10中の領域Q22を拡大した図である。It is an enlarged view of the region Q22 in FIG. 類似度マップに設定する領域を示す図である。It is a figure which shows the area to be set in the similarity map. 加工類似度マップを示す図である。It is a figure which shows the processing similarity map. 加工類似度マップを示す図である。It is a figure which shows the processing similarity map. 類似度マップに設定する領域の変形例を示す図である。It is a figure which shows the modification of the area set in the 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 robot 100 shown in FIG. 1 is a horizontal articulated robot, and is used, for example, in a manufacturing process for manufacturing precision equipment and the like, and can grip and transport precision equipment and parts. The robot 100 includes a base 110, a first arm 120 that rotates around the first axis J1 with respect to the base 110, and a second arm 130 that rotates around the second axis J2 with respect to the first arm 120. A work head 140 provided at the tip of the second arm 130, which includes a spline shaft 141 that rotates around the third axis J3 with respect to the second arm 130 and moves up and down along the third axis J3. It has an end effector 150 mounted on the tip of the spline shaft 141. Then, such a robot 100 includes a first encoder that detects the rotation angle of the first arm 120 around the first axis J1 with respect to the base 110, and a second axis J2 of the second arm 130 with respect to the first arm 120. A second encoder that detects the rotation angle around it is provided. The template matching method of the present invention can be applied to both the first encoder and the second encoder. Hereinafter, the configuration applied to the first encoder will be described, and the first encoder will be described as the encoder 1.

図2に示すように、エンコーダー1は、第1アーム120に設けられているスケール部2と、基台110に設けられ、スケール部2を検出する検出部3と、検出部3に電気的に接続されている回路部4と、を有する。 As shown in FIG. 2, the encoder 1 is provided on the scale unit 2 provided on the first arm 120, the detection unit 3 provided on the base 110 to detect the scale unit 2, and electrically on the detection unit 3. It has a circuit unit 4 and a connected circuit unit 4.

スケール部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 scale portion 2 is provided at a portion of the first arm 120 facing the base 110. As shown in FIG. 3, the scale portion 2 has a unique pattern provided on the surface of the first arm 120 and arranged along the first axis J1 at a position different from that of the first axis J1. doing. The "unique pattern" means that when the scale portion 2 is rotated around the first axis J1 over a required angle range, the same pattern does not appear twice or more in a predetermined region in the captured image G described later. .. Therefore, each of the plurality of portions of the scale portion 2 having different positions can be used as the mark 21 for identifying the position of the scale portion 2 in the circumferential direction. Note that FIG. 3 illustrates a case where a plurality of marks 21 are arranged along the circumference centered on the first axis J1. Further, the positions, sizes, numbers, and the like of the marks 21 shown in FIG. 3 are examples, and are not limited thereto.

スケール部2のユニークなパターンは、白地に複数の黒地のドット20をユニークに配置することにより構成されている。なお、ドット20の形状は、図示では円形であるが、これに限定されず、例えば、楕円形、四角形、異形状等であってもよい。また、スケール部2のパターンは、前述した複数のドット20で構成されたパターンのようなドットパターンに限定されず、例えば、直線状のラインで構成されたパターン、曲線状のラインで構成されたパターン、ドット、直線状のラインおよび曲線状のラインのうちの少なくとも2つを組み合わせて構成されたパターン、またはこれらの反転パターン等であってもよい。また、スケール部2のパターンは、検出部3で検出可能なパターンであればよく、例えば、染料、顔料等のインクで形成されたパターン、凹凸形状によるパターン、自然物に形成されているパターン等であってもよい。 The unique pattern of the scale portion 2 is formed by uniquely arranging a plurality of dots 20 on a black background on a white background. The shape of the dot 20 is circular in the drawing, but is not limited to this, and may be, for example, an ellipse, a quadrangle, or an irregular shape. Further, the pattern of the scale unit 2 is not limited to a dot pattern such as the above-mentioned pattern composed of a plurality of dots 20, and is composed of, for example, a pattern composed of linear lines and a curved line. It may be a pattern composed of a combination of at least two of a pattern, a dot, a linear line, and a curved line, or an inverted pattern thereof. Further, the pattern of the scale unit 2 may be a pattern that can be detected by the detection unit 3, and may be, for example, a pattern formed by ink such as dye or pigment, a pattern having an uneven shape, a pattern formed by a natural object, or the like. There may be.

また、スケール部2のマーク21は、前述したパターンを用いたものに限定されず、例えば、数字を用いてもよいし、ローマ字、アラビア文字、漢字等の文字を用いてもよいし、文字以外の記号、符号、しるし、標章、図案、一次元バーコード、QRコード(登録商標)等を用いてもよい。 Further, the mark 21 of the scale unit 2 is not limited to the one using the above-mentioned pattern, and for example, a number may be used, characters such as Roman characters, Arabic characters, and Kanji characters may be used, and characters other than characters may be used. Symbols, symbols, signs, marks, designs, one-dimensional barcodes, QR codes (registered trademarks) and the like may be used.

また、スケール部2は、第1アーム120の表面に直に設けられている場合に限定されず、例えば、第1アーム120の表面に貼着されたシート状の部材に設けられていてもよいし、第1アーム120とともに回動するように設けられた板状の部材に設けられていてもよい。すなわち、スケール部2が設けられる部材は、第1アーム120とともに基台110に対して第1軸J1まわりに回動する部材であればよい。 Further, the scale portion 2 is not limited to the case where it is provided directly on the surface of the first arm 120, and may be provided on, for example, a sheet-like member attached to the surface of the first arm 120. However, it may be provided on a plate-shaped member provided so as to rotate together with the first arm 120. That is, the member provided with the scale portion 2 may be a member that rotates around the first axis J1 with respect to the base 110 together with the first arm 120.

図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 detection unit 3 includes an image sensor 31 provided in the base 110 and an imaging optical system 32 provided in the opening of the base 110. Then, the image sensor 31 images the image pickup region RI which is a part of the scale unit 2 in the circumferential direction via the image pickup optical system 32. The detection unit 3 may be provided with a light source for illuminating the image pickup region RI of the image pickup device 31, if necessary. The image pickup device 31 is not particularly limited, and for example, a CCD (Charge Coupled Devices), a CMOS (Complementary Metal Oxide Semiconductor), or the like can be used.

撮像素子31は、撮影された画像を画素ごとの電気信号に変換して出力する。撮像素子31は、二次元撮像素子(エリアイメージセンサ)、あるいは一次元撮像素子(ラインイメージセンサ)のどちらでも適用可能である。二次元撮像素子を用いた場合は、情報量の多い二次元画像を取得でき、後述のテンプレートマッチングによるマーク21の検出精度を高めやすい。その結果、第1アーム120の回動状態を高精度に検出することができる。一方、一次元撮像素子を用いた場合は、画像取得周期いわゆるフレームレートが高いため、検出頻度を高めることが可能になり、高速動作時に有利となる。 The image sensor 31 converts the captured image into an electric signal for each pixel and outputs the image. The image sensor 31 can be applied to either a two-dimensional image sensor (area image sensor) or a one-dimensional image sensor (line image sensor). When a two-dimensional image sensor is used, a two-dimensional image having a large amount of information can be acquired, and it is easy to improve the detection accuracy of the mark 21 by template matching described later. As a result, the rotational state of the first arm 120 can be detected with high accuracy. On the other hand, when the one-dimensional image sensor is used, the image acquisition cycle, that is, the frame rate, is high, so that the detection frequency can be increased, which is advantageous at high speed operation.

ここで、図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 image pickup device 31 is set on the lower surface of the first arm 120 so as to overlap a part of the scale portion 2 in the circumferential direction. As a result, the image sensor 31 can image the mark 21 in the image pickup region RI. Therefore, the rotational state of the first arm 120 can be known by reading the mark 21 located in the imaging region RI.

図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 circuit unit 4 includes a processing unit 5 such as a CPU (Central Processing Unit) and a template matching dedicated arithmetic circuit, and a storage unit 6 such as a ROM (Read only memory) and a RAM (Random Access Memory). Has. Here, the storage unit 6 stores instructions that can be read by the processing unit 5, and the processing unit 5 realizes various functions by appropriately reading and executing the instructions from the storage unit 6. Such a circuit unit 4 can be configured by using, for example, an ASIC (application specific integrated circuit) or an FPGA (field-programmable gate array). By hardwareizing the circuit unit 4 using the ASIC or FPGA in this way, it is possible to increase the processing speed, reduce the size, and reduce the cost of the circuit unit 4.

処理部5は、検出部3の検出結果に基づいて、基台110および第1アーム120の相対的な回動状態を推定する。この回動状態としては、例えば、回動角度、回動速度、回動方向等が挙げられる。特に、処理部5は、撮像素子31の撮像画像に対して基準画像を用いてテンプレートマッチングすることでマーク21を画像認識し、その認識結果を用いて、基台110に対する第1アーム120の回動角度を推定する。以下、基準画像の取得について詳述する。また、処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定について、図4に示すフローチャートに基づいて詳述する。 The processing unit 5 estimates the relative rotational state of the base 110 and the first arm 120 based on the detection result of the detection unit 3. Examples of the rotation state include a rotation angle, a rotation speed, a rotation direction, and the like. In particular, the processing unit 5 recognizes the mark 21 by template matching the image captured by the image sensor 31 using the reference image, and uses the recognition result to rotate the first arm 120 with respect to the base 110. Estimate the moving angle. The acquisition of the reference image will be described in detail below. Further, the template matching in the processing unit 5 and the estimation of the rotation state using the template matching will be described in detail based on the flowchart shown in FIG.

処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定は、撮像素子31を用いて撮像画像Gを取得する撮像画像取得ステップと、基準画像TAを用いて撮像画像Gに対してテンプレートマッチングを行って類似度マップM1を生成する類似度マップ生成ステップと、類似度マップM1に基づいて加工類似度マップM2を生成する加工類似度マップ生成ステップと、加工類似度マップM2および類似度マップM1に基づいて、第1アーム120の位置を推定する推定ステップと、を有する。以下、図4に示すフローチャートに基づいて、詳細に説明する。 The template matching in the processing unit 5 and the estimation of the rotation state using the template matching are performed by the captured image acquisition step of acquiring the captured image G using the imaging element 31 and the template matching with respect to the captured image G using the reference image TA. A similarity map generation step for generating a similarity map M1 by performing the above, a machining similarity map generation step for generating a machining similarity map M2 based on the similarity map M1, a machining similarity map M2, and a machining similarity map M1. Has an estimation step of estimating the position of the first arm 120 based on. Hereinafter, a detailed description will be given based on the flowchart shown in FIG.

1.基準画像の取得
エンコーダー1は、テンプレートマッチングを用いて基台110に対する第1アーム120の回動状態を推定するのに先立って、テンプレートマッチングに用いる基準画像TAを予め取得する。この基準画像TAの取得は、最初のテンプレートマッチングの前に1回行うだけでよいが、その後必要に応じて適時行ってもよい。その場合、テンプレートマッチングに用いる基準画像TAを、新たに取得した基準画像TAに更新することができる。
1. 1. Acquisition of Reference Image The encoder 1 acquires the reference image TA used for template matching in advance prior to estimating the rotational state of the first arm 120 with respect to the base 110 using template matching. The acquisition of the reference image TA may be performed only once before the first template matching, but may be performed after that as needed. In that case, the reference image TA used for template matching can be updated with the newly acquired reference image TA.

基準画像を取得する際には、第1アーム120を基台110に対して第1軸J1まわりに適宜回動させ、撮像素子31で複数のマーク21をそのマーク21毎に撮像する。そして、得られた各撮像画像Gをトリミングして不要部分を削除することにより、マーク21毎の基準画像TAを生成する。つまり、マーク21の数だけ基準画像TAを生成する。生成された各基準画像TAは、その画素座標情報および角度情報とともにこれらに対応付けられて記憶部6に記憶される。 When acquiring the reference image, the first arm 120 is appropriately rotated around the first axis J1 with respect to the base 110, and a plurality of marks 21 are imaged for each of the marks 21 by the image sensor 31. Then, by trimming each of the obtained captured images G and deleting unnecessary portions, a reference image TA for each mark 21 is generated. That is, the reference image TA is generated for the number of marks 21. Each of the generated reference image TAs is associated with the pixel coordinate information and the angle information and stored in the storage unit 6.

より具体的に説明すると、図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 mark 21 indicated by the arrow as much as possible. Further, the captured image G has a plurality of pixels arranged in a matrix in the X direction and the Y direction. Here, the pixel positions are represented by a pixel coordinate system (X, Y) represented by "X" indicating the position of the pixel in the X direction and "Y" indicating the position of the pixel in the Y direction. To. Further, the pixel at the upper left end of the image of the captured image G is set as the origin pixel (0,0) of the image coordinate system (X, Y).

例えば、図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 mark 21A in FIG. 5, the first arm 120 is appropriately rotated with respect to the base 110, and the mark 21A is moved to a predetermined position in the captured image G, or the X axis in the drawing. It is positioned on the center line LY set at the center in the direction. The rotation angle θA0 of the first arm 120 with respect to the base 110 when the mark 21 is located on the center line LY has been acquired in advance by measurement or the like.

次に、マーク21を中心線LY上に位置させた状態を撮像素子31で撮像し、得られた撮像画像Gを、マーク21Aを包含する必要最小限の範囲となるような矩形の画素範囲でトリミングする。これにより、マーク21Aに対応する基準画像TAが得られ、得られた基準画像TAは、記憶部6に記憶される。このとき、基準画像TAは、前述した回動角度θA0に関する角度情報および基準画像TAの画素範囲に含まれる基準画素P0の画素座標である基準画素座標(Xp0,Yp0)に関する画素情報とともに、これらに対応付けられて記憶される。すなわち、基準画像TA、角度情報および画素座標情報がテンプレートマッチングに用いる1つのテンプレートセットとなる。 Next, the state in which the mark 21 is positioned on the center line LY is imaged by the image sensor 31, and the obtained image G is captured in a rectangular pixel range that is the minimum necessary range including the mark 21A. Trim. As a result, the reference image TA corresponding to the mark 21A is obtained, and the obtained reference image TA is stored in the storage unit 6. At this time, the reference image TA includes the above-mentioned angle information regarding the rotation angle θA0 and the pixel information regarding the reference pixel coordinates (Xp0, Yp0) which are the pixel coordinates of the reference pixel P0 included in the pixel range of the reference image TA. It is associated and stored. That is, the reference image TA, the angle information, and the pixel coordinate information form one template set used for template matching.

エンコーダー1がアブソリュート型である場合、このテンプレートセットにおける角度情報は絶対角度である。また、エンコーダー1がインクリメント型である場合、このテンプレートセットにおける角度情報は相対角度である。 When the encoder 1 is an absolute type, the angle information in this template set is an absolute angle. When the encoder 1 is an increment type, the angle information in this template set is a relative angle.

2.テンプレートマッチングおよびそれを用いた回動状態の推定
以下、処理部5におけるテンプレートマッチングおよびそれを用いた回動状態の推定について詳述する。
2. Template matching and estimation of the rotating state using the template matching The template matching in the processing unit 5 and the estimation of the rotating state using the template matching will be described in detail below.

[撮像画像取得ステップ]
まず、処理部5は、撮像素子31を用い、スケール部2の一部である撮像領域RIを撮像して、撮像画像Gを得る(ステップS1)。
[Captured image acquisition step]
First, the processing unit 5 uses the image sensor 31 to image the image pickup region RI that is a part of the scale unit 2 to obtain the image pickup image G (step S1).

[類似度マップ生成ステップ]
まず、処理部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 processing unit 5 performs template matching on the image G of the image sensor 31 using the reference image TA prepared in advance to generate the similarity map M1 (step S2). Specifically, the processing unit 5 sets the entire area of the captured image G as the search area, superimposes the reference image TA on the search area, and calculates the similarity of the overlapping portion between the search area and the reference image TA. The processing unit 5 moves the reference image TA along the pixel arrangement of the captured image G, and calculates the similarity of the overlapping portion between the search region and the reference image TA for the pixels in the entire search region. Specifically, the processing unit 5 moves the pixel coordinates (Xp, Yp) of the reference pixel P0 set in the reference image TA from the start coordinate PSp to the end pixel PEp one pixel at a time, and pixels in the entire search area. The degree of similarity between the search area and the overlapping portion of the reference image TA is calculated. That is, the processing unit 5 calculates the similarity for each pixel coordinate (Xp, Yp) of the reference pixel P0 of the reference image TA. Then, the processing unit 5 arranges the similarity calculated for each pixel coordinate (Xp, Yp) corresponding to the position of the pixel coordinate (Xp, Yp), that is, along the order of the pixel coordinates (Xp, Yp). A similarity map M1 as shown in FIGS. 6 and 7 arranged side by side is generated. At this time, the similarity map M1 is a map including a point at which the similarity is maximized, that is, a plurality of peaks. The region Q1 shown in FIG. 7 is a region including pixel coordinates (Xp, Yp) = (Xn, Yn) having the maximum similarity. The generated similarity map M1 is stored in the storage unit 6. As a method for obtaining the degree of similarity, there are SAD, SSD, ZNCC and the like. In SAD and SSD, the value is the minimum, and in ZNCC, the similarity is the maximum when the value is the maximum. In the figure, since the degree of difference obtained by using SAD is described as the degree of similarity, the degree of similarity is maximized when the value is the minimum.

なお、従来のテンプレートマッチングであれば、次に、処理部5は、記憶部6に記憶されている類似度マップM1から最大値の類似度を選択する。図7の例では、画素座標(Xp,Yp)=(Xn,Yn)の類似度を選択する。そして、処理部5は、選択した類似度に対応する基準画像TAの基準画素P0の画素座標(Xp,Yp)をマーク21の画素座標として決定し、撮像画像G内でのマーク21の位置を検出する。 In the case of conventional template matching, the processing unit 5 next selects the maximum similarity degree from the similarity degree map M1 stored in the storage unit 6. In the example of FIG. 7, the similarity of pixel coordinates (Xp, Yp) = (Xn, Yn) is selected. Then, the processing unit 5 determines the pixel coordinates (Xp, Yp) of the reference pixel P0 of the reference image TA corresponding to the selected similarity as the pixel coordinates of the mark 21, and determines the position of the mark 21 in the captured image G. To detect.

ここで、例えば、図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 target mark 21A and the pixel Px in the reference image TA and the captured image G is the same, the similarity map M1 shown in FIG. 7 is obtained. , The similarity measured at pixel coordinates (Xp, Yp) = (Xn, Yn) is sufficiently larger than the similarity measured at other pixel coordinates (Xp, Yp). Therefore, the position of the mark 21A in the captured image G can be detected with high accuracy.

これに対して、図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 target mark 21A and the pixel Px in the reference image TA and the captured image G may deviate by about 0.5 pixel. In this case, the peak having the maximum similarity is also shifted by about 0.5 pixel. FIG. 10 shows a similarity map M1 generated in a state where pixel shift occurs. The region Q21 shown in FIG. 11 is a region including pixel coordinates (Xp, Yp) = (Xn, Yn) that maximizes the similarity when there is no pixel deviation. The region Q22 shown in FIG. 12 is a region including pixel coordinates (Xp, Yp) = (Xz, Yz) in which a mark 21 similar to the target mark 21A but different from the mark 21 exists. Since the similarity is calculated discretely in units of one pixel, it is different from the reference image TA of adjacent pixel coordinates (Xp, Yp) = (Xn, Yn) as shown in the similarity map M1 shown in FIG. The similarity of the peak with the maximum similarity is shared with the reference image TA of pixel coordinates (Xp, Yp) = (Xn-1, Yn). Therefore, the similarity measured at the pixel coordinates (Xp, Yp) = (Xn, Yn) is significantly lower than the similarity when there is no pixel deviation. Therefore, when a mark 21 similar to the target mark 21A exists in the captured image G, the pixel coordinates (Xp, Yp) = (as shown in FIGS. 11 and 12) = ( There is a possibility that a “reversal phenomenon” may occur in which pixel coordinates (Xp, Yp) = (Xz, Yz) having a similarity larger than the actually measured similarity in Xn, Yn) occur. In other words, when searching for the peak with the maximum similarity from the similarity map M1, the similarity is discretely sampled in units of one pixel. Therefore, for example, the peak having the maximum sampling range is removed by pixel deviation. And when it coincides with the next largest peak and the difference in similarity between the maximum peak and the next largest peak is small, a "reversal phenomenon" may occur. When such a reversal phenomenon occurs, the processing unit 5 determines the pixel coordinates (Xp, Yp) = (Xz, Yz) as the pixel coordinates of the mark 21A. As a result, the position of the mark 21A is erroneously determined.

そこで、このようなマーク21の位置の誤決定を抑制するために、本実施形態の処理部5は、類似度マップM1を生成した後に、次のような処理を実行する。 Therefore, in order to suppress such erroneous determination of the position of the mark 21, the processing unit 5 of the present embodiment executes the following processing after generating the similarity map M1.

[加工類似度マップ生成ステップ]
まず、処理部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 processing unit 5 processes the similarity map M1 stored in the storage unit 6 to generate the processing similarity map M2 (step S3). Specifically, first, as shown in FIG. 13, the processing unit 5 has a square-shaped region 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. Set R. Next, the processing unit 5 calculates the average value of the similarity of the four pixel coordinates (Xp, Yp) included in the region R as the processing similarity. The processing unit 5 moves the area R along the coordinates of the similarity map M1 and calculates the processing similarity for the coordinates of the entire similarity map M1. Specifically, the processing unit 5 moves the coordinates (Xs, Ys) of the reference pixel coordinates S0 set in the area R from the start coordinate PSs to the end pixel PEs one by one, and covers the entire similarity map M1. For the coordinates, the processing similarity is calculated. That is, the processing unit 5 calculates the processing similarity for each coordinate (Xs, Ys) of the reference pixel coordinate S0.

そして、処理部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 processing unit 5 arranges the processing similarity calculated for each coordinate (Xs, Ys) corresponding to the position of the coordinate (Xs, Ys), that is, along the order of the coordinates (Xs, Ys). A machining similarity map M2 as shown in FIGS. 14 and 15 arranged side by side is generated. The generated processing similarity map M2 is stored in the storage unit 6. The machining similarity map M2 shown in FIG. 14 corresponds to the similarity map M1 shown in FIG. 11, and the machining similarity map M2 shown in FIG. 15 corresponds to the similarity map M1 shown in FIG. The processing similarity is not limited to the average value of the four similarity included in the region R, and may be, for example, the total value of the four similarity. By setting the processing similarity as the average value or the total value of the four similarities included in the region R, it becomes easy to obtain the processing similarity. In addition to this, the processing similarity may be a value obtained by substituting four similarity into a predetermined formula, for example.

[推定ステップ]
次に、処理部5は、記憶部6に記憶されている加工類似度マップM2に含まれている複数の加工類似度から、最大の加工類似度を抽出する(ステップS4)。次に、処理部5は、抽出した加工類似度に対応する領域R中に含まれる4つの類似度から、最大の類似度を抽出する(ステップS5)。そして、処理部5は、類似度マップM1に基づいて、抽出した類似度に対応する基準画像TAの基準画素P0の画素座標(Xp,Yp)=(Xn,Yn)をマッチング位置、つまり、マーク21の画素座標として決定する(ステップS6)。さらに、処理部5は、決定したマッチング位置、つまり、画素座標に基づく回動角度θを出力する(ステップS7)。
[Estimation step]
Next, the processing unit 5 extracts the maximum processing similarity from the plurality of processing similarity included in the processing similarity map M2 stored in the storage unit 6 (step S4). Next, the processing unit 5 extracts the maximum similarity from the four similarity included in the region R corresponding to the extracted processing similarity (step S5). Then, the processing unit 5 sets the pixel coordinates (Xp, Yp) = (Xn, Yn) of the reference pixel P0 of the reference image TA corresponding to the extracted similarity as the matching position, that is, the mark, based on the similarity map M1. It is determined as the pixel coordinates of 21 (step S6). Further, the processing unit 5 outputs the determined matching position, that is, the rotation angle θ based on the pixel coordinates (step S7).

このとき、基準画素座標(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 image sensor 31 in the X-axis direction (one pixel of the image sensor 31). The rotation angle θ of the first arm 120 with respect to the base 110 can be obtained by using the following equation (1), where W is the visual field size per unit.

Figure 2021071979
Figure 2021071979

この式(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 mark 21 when the first arm 120 is rotated 360 ° with respect to the base 110. As described above, θA0 is the rotation angle of the first arm 120 with respect to the base 110 when the mark 21A is positioned at a predetermined position. The rotation angle θ is the angle at which the first arm 120 rotates with respect to the base 110 from the reference state (0 °).

以上により、基台110に対する第1アーム120の回動角度θが推定される。このようなテンプレートマッチングおよびそれを用いた回動角度θの算出を他のマーク21についても同様に行う。ここで、任意の回動角度θにおいて、撮像画像G内に少なくとも1つのマーク21が欠けなく映り、かつ、テンプレートマッチング可能なように各マーク21に対応した基準画像が登録されている。これにより、テンプレートマッチングが不可能な角度範囲が生じることを防止することができる。 From the above, the rotation angle θ of the first arm 120 with respect to the base 110 is estimated. Such template matching and calculation of the rotation angle θ using the same are performed for the other marks 21 in the same manner. Here, at an arbitrary rotation angle θ, at least one mark 21 is displayed in the captured image G without chipping, and a reference image corresponding to each mark 21 is registered so that template matching is possible. This makes it possible to prevent an angle range in which template matching is not possible.

加工類似度マップ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 mark 21 are not the pixel coordinates (Xp, Yp) = (Xn, Yn) but the pixel coordinates (Xp, Yp). It is possible to effectively suppress the erroneous selection of = (Xz, Yz). As described above, according to the above-mentioned method, excellent detection accuracy can be exhibited.

特に、本実施形態では、領域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 encoder 1, it is conceivable that only the pixel shift in the X direction occurs. In this case, for example, as shown in FIG. 16, the region R3 including two pixel coordinates (Xp, Yp) arranged adjacent to each other in the X direction can be set. Similarly, depending on the configuration of the encoder 1, it is possible that only pixel shift in the Y direction occurs. In this case, for example, as shown in FIG. 16, the region R4 including two pixel coordinates (Xp, Yp) arranged adjacent to each other in the Y direction can be set. Similarly, depending on the configuration of the encoder 1, it is conceivable that only pixel deviation in the oblique direction occurs. In this case, for example, as shown in FIG. 16, the region R5 including two pixel coordinates (Xp, Yp) arranged adjacent to each other in the oblique direction can be set. As a result, it is possible to obtain a processing similarity with less noise.

以上、本実施形態のテンプレートマッチング方法について説明した。このようなテンプレートマッチング方法は、前述したように、撮像式エンコーダーであるエンコーダー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 encoder 1 which is an imaging type encoder is used to determine the similarity of the imaging element 31 with the reference image TA with respect to the captured image G, and the reference image TA and the captured image G are combined. A similarity map M1 is generated in which the similarity of the above is arranged according to the coordinates (Xp, Yp) of the reference image TA in the captured image G, and the processing is obtained based on a plurality of adjacent similarities in the similarity map M1. A processing similarity map M2 in which the similarity is arranged according to the coordinates (Xs, Ys) of the similarity in the similarity map M1 is generated, and the maximum processing similarity is extracted from the processing similarity map M2. According to such a method, the influence of the pixel shift as shown in FIG. 9 can be canceled, and the pixel coordinates of the mark 21 are not the pixel coordinates (Xp, Yp) = (Xn, Yn) but the pixels. It is possible to effectively suppress the erroneous selection of coordinates (Xp, Yp) = (Xz, Yz). Therefore, according to such a method, excellent detection accuracy can be exhibited.

また、前述したように、テンプレートマッチング方法は、抽出した加工類似度を求めるのに用いた複数の類似度から最大の類似度を抽出する。これにより、マーク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 mark 21. Can be suppressed. Therefore, according to such a method, excellent detection accuracy can be exhibited.

また、前述したように、抽出した類似度を有する基準画像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 encoder 1 can be applied to both absolute type and incremental type. Further, the encoder 1 can be applied not only to a rotary encoder but also to a linear encoder.

また、前述したエンコーダー1は、前述した第2軸J2まわりの回動角度を検出する第2エンコーダーに適用してもよい。また、前述したエンコーダー1は、前述した水平多関節ロボット以外の型のロボット、例えば、6軸多関節ロボット、双腕ロボット等にも設置可能である。また、エンコーダー1は、ロボット100以外の電子機器、例えば、プリンター、プロジェクター等に搭載してもよい。さらには、エンコーダー1、車輌、航空機、船舶等の移動体に搭載してもよい。 Further, the above-mentioned encoder 1 may be applied to the above-mentioned second encoder that detects the rotation angle around the second axis J2. Further, the encoder 1 described above can be installed in a robot of a type other than the horizontal articulated robot described above, for example, a 6-axis articulated robot, a dual-arm robot, or the like. Further, the encoder 1 may be mounted on an electronic device other than the robot 100, for example, a printer, a projector, or the like. Further, it may be mounted on a moving body such as an encoder 1, a vehicle, an aircraft, or a ship.

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.
前記抽出した前記加工類似度を求めるのに用いた複数の前記類似度から最大の類似度を抽出する請求項1に記載のテンプレートマッチング方法。 The template matching method according to claim 1, wherein the maximum similarity is extracted from a plurality of the extracted similarity used to obtain the processing similarity. 前記抽出した前記類似度を有する前記基準画像の位置を検出位置として決定する請求項2に記載のテンプレートマッチング方法。 The template matching method according to claim 2, wherein the position of the reference image having the extracted similarity is determined as a detection position. 前記加工類似度は、複数の前記類似度の平均値である請求項1ないし3のいずれか1項に記載のテンプレートマッチング方法。 The template matching method according to any one of claims 1 to 3, wherein the processing similarity is an average value of a plurality of the similarity. 前記加工類似度は、複数の前記類似度の合計値である請求項1ないし3のいずれか1項に記載のテンプレートマッチング方法。 The template matching method according to any one of claims 1 to 3, wherein the processing similarity is a total value of a plurality of the similarity. 前記加工類似度マップ中では、複数の前記類似度が互いに直交するX方向およびY方向に並んで行列状に配置され、
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.
前記加工類似度マップ中では、複数の前記類似度が互いに直交するX方向およびY方向に並んで行列状に配置され、
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.
JP2019199119A 2019-10-31 2019-10-31 Template matching method Pending JP2021071979A (en)

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)

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