WIL説明書(.NET)  3.1.0
特徴点応用マッチング

濃淡画像からテンプレートに一致する箇所を複数検出し、2つの検出位置の角度を計測する例です。


プレビュー:

Step2.FPM2.Preview.1.png
マッチング結果
Step2.FPM2.Preview.2.png
2点間の角度

ワークフロー:

Step2.FPM2.Component.1.png
Step2.FPM2.Component.2.png

ソースコード:
1 Option Strict Off
2 Option Explicit On
3 
4 Imports fvalgcli
5 Imports System
6 Imports System.Collections.Generic
7 Imports System.ComponentModel
8 Imports System.Drawing
9 Imports System.Globalization
10 Imports System.Reflection
11 Imports System.Runtime.Serialization
12 Imports System.Security.Permissions
13 Imports System.Text
14 Imports System.Windows.Forms
15 
16 Namespace FVIL.Parser
17 
18  <System.SerializableAttribute(), _
19  System.ComponentModel.TypeConverterAttribute(GetType(System.ComponentModel.ExpandableObjectConverter))> _
20  Partial Public Class ParserNodeUser
21  Inherits FVIL.Parser.ParserNodeUnit
22 
23  Public Overrides Sub Execute(ByVal sender As Object, ByVal e As System.EventArgs)
24  Dim target1_out0 As FVIL.Data.CFviPattern = New FVIL.Data.CFviPattern
25  Dim target2_out0 As FVIL.Data.CFviImage = New FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1)
26  Dim target3_out0 As FVIL.FPM2.CFviFPM2Result = New FVIL.FPM2.CFviFPM2Result
27  Dim target3_out1 As FVIL.FPM2.CFviFPM2Feature = New FVIL.FPM2.CFviFPM2Feature
28  Dim target3_out2 As FVIL.FPM2.CFviFPM2Template = New FVIL.FPM2.CFviFPM2Template
29  Dim target4_out0 As FVIL.FPM2.CFviFPM2Data = New FVIL.FPM2.CFviFPM2Data
30  Dim target4_out1 As FVIL.Data.CFviPoint = _
31  New FVIL.Data.CFviPoint(249.70567094915978, 138.18345899249812)
32  Dim target4_out2 As Integer = 93
33  Dim target4_out3 As Double = 100
34  Dim target4_out4 As FVIL.Data.CFviAngle = New FVIL.Data.CFviAngle(26.1572265625)
35  Dim target5_out0 As FVIL.FPM2.CFviFPM2Data = New FVIL.FPM2.CFviFPM2Data
36  Dim target5_out1 As FVIL.Data.CFviPoint = _
37  New FVIL.Data.CFviPoint(17.561377904272945, 56.351870454164015)
38  Dim target5_out2 As Integer = 88
39  Dim target5_out3 As Double = 100
40  Dim target5_out4 As FVIL.Data.CFviAngle = New FVIL.Data.CFviAngle(138.5)
41  Dim target6_out0 As FVIL.Data.CFviAngle = New FVIL.Data.CFviAngle(19.417713355354906)
42 
43  'パタン画像#1
44  target1_out0 = CType(ParserInfo,FVIL.Parser.IDataObject(Of FVIL.Data.CFviPattern)).Infos(0).Data
45 
46  '画像#1
47  target2_out0 = CType(ParserInfo,FVIL.Parser.IDataObject(Of FVIL.Data.CFviImage)).Infos(0).Data
48 
49  'FPM2#1
50  'FPM2#1 (Matching Parameter)
51  Dim target3_param As FVIL.FPM2.CFviFPM2Param = New FVIL.FPM2.CFviFPM2Param
52  target3_param.Polarity = FVIL.FPM2.Polarity.Same
53  target3_param.RefineScoreThreshold = 60
54  target3_param.RefineErrorRange = 1
55  target3_param.RefineEnable = true
56  target3_param.ScoreThresholdH = 50
57  target3_param.ScoreThresholdL = 50
58  target3_param.ErrorRange = 1
59  target3_param.CompressionLevel = 3
60  target3_param.ScaleMax = 100
61  target3_param.ScaleMin = 100
62  target3_param.AngleMax = New FVIL.Data.CFviAngle(180)
63  target3_param.AngleMin = New FVIL.Data.CFviAngle(-180)
64  target3_param.Count = 3
65  'FPM2#1 (Edge Parameter)
66  Dim target3_edge As FVIL.Edge.CFviEdge2DCorrelationParam = New FVIL.Edge.CFviEdge2DCorrelationParam
67  target3_edge.VarThreshold = 25
68  target3_edge.SigmoidK = 1
69  target3_edge.RegionHeight = 5
70  target3_edge.RegionWidth = 13
71  target3_edge.NmsLength = 6
72  target3_edge.EdgeThreshold = 160
73  'FPM2#1 (Template)
74  Dim target3_out2 As FVIL.FPM2.CFviFPM2Template = _
75  New FVIL.FPM2.CFviFPM2Template(target1_out0, FVIL.FPM2.MatchMode.HighSpeed, target3_edge)
76  'FPM2#1 (Target)
77  Dim target3_out1 As FVIL.FPM2.CFviFPM2Feature = _
78  New FVIL.FPM2.CFviFPM2Feature(target2_out0, FVIL.FPM2.MatchMode.HighSpeed, target3_edge, false)
79  'FPM2#1 (Execute)
80  Dim target3 As FVIL.FPM2.CFviFPM2Matching = _
81  New FVIL.FPM2.CFviFPM2Matching(target3_out1, target3_out2, target3_out0)
82  target3.EnableAreaScore = false
83  target3.EnableEssential = false
84  target3.Param = target3_param
85  target3.Execute
86 
87  'FPM2 データ#1
88  target4_out0.CopyFrom(target3_out0(1))
89  target4_out1 = target4_out0.Position
90  target4_out2 = target4_out0.Score
91  target4_out3 = target4_out0.Scale
92  target4_out4 = target4_out0.Angle
93 
94  'FPM2 データ#2
95  target5_out0.CopyFrom(target3_out0(2))
96  target5_out1 = target5_out0.Position
97  target5_out2 = target5_out0.Score
98  target5_out3 = target5_out0.Scale
99  target5_out4 = target5_out0.Angle
100 
101  '角度(2点間)#1
102  target6_out0 = FVIL.Caliper.[Function].Angle(target5_out1, target4_out1)
103  End Sub
104  End Class
105 End Namespace

Documentation copyright © 2008 FAST Corporation. [B-001864]
Generated on 2024年10月10日(木) 10時07分53秒 for WIL説明書(.NET) by doxygen 1.8.11