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

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