轮胎外观检测添加思谋语义分割模型检测工具
C3204
6 小时以前 98c0775fe3b61a37d90dd5756287f385a311adf0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using LB_VisionProcesses.Cameras;
using LB_VisionProcesses.Communicators;
using LB_VisionProcesses.Alogrithms;
using LB_VisionProcesses.Alogrithms.Halcon;
using System.Collections.Concurrent;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json.Serialization;
 
namespace LB_VisionProcesses
{
    public abstract class IProcess : IDisposable, ICloneable
    {
        /// <summary>
        /// 流程集合
        /// </summary>
        public static Dictionary<string, string> dicProcesses = new Dictionary<string, string>
        {
            //相机
            { "相机取图", "LB_VisionProcesses.Cameras.CameraConfig" },
            ////读码器
            //{ "读码器", "LB_VisionProcesses.Cameras.CameraConfig" },
            //通讯
            { "通讯测试", "LB_VisionProcesses.Communicators.CommunicatorConfig" },
            //{ "T306通讯", "LB_VisionProcesses.Communicators.T306CommandTool" },
            { "T306通讯", "LB_VisionProcesses.Communicators.T306CommandTool" },
            { "ModbusRTU", "LB_VisionProcesses.Processes.ModbusRTUMasterTool" },
            { "ModbusTCP", "LB_VisionProcesses.Processes.ModbusTCPMasterTool" },
 
            //Halcon2D算法
            { "Halcon2D_模板匹配工具", "LB_VisionProcesses.Alogrithms.Halcon.HFindModelTool" },
            { "Halcon2D_多模板匹配工具", "LB_VisionProcesses.Alogrithms.Halcon.HFindMultiModelTool" },
            { "Halcon2D_斑点工具", "LB_VisionProcesses.Alogrithms.Halcon.HBlobTool" },
            { "Halcon2D_读码工具", "LB_VisionProcesses.Alogrithms.Halcon.HFindCode2dTool" },
            { "Halcon2D_找线工具", "LB_VisionProcesses.Alogrithms.Halcon.HFindLineTool" },
            { "Halcon2D_找弧工具", "LB_VisionProcesses.Alogrithms.Halcon.HFindEllipseTool" },
            { "Halcon2D_图像增强工具", "LB_VisionProcesses.Alogrithms.Halcon.HImageEnhancementTool" },
            
            //思谋深度学习算法
            { "语义分割工具", "LB_VisionProcesses.Alogrithms.BigModel.Segment.SegmentTool" },
 
            //图像处理
            { "单图像处理工具", "LB_VisionProcesses.Alogrithms.OneImageConvertTool" },
            { "点云转换工具", "LB_VisionProcesses.Alogrithms.PointsCloudConvertTool" },
            { "畸变矫正工具", "LB_VisionProcesses.Alogrithms.Halcon.HCaltabTool" },
 
            //OpenCvSharp
            { "OpenCvSharp_模板匹配工具", "LB_VisionProcesses.Alogrithms.OpenCvSharp.FindModelTool" },
            { "OpenCvSharp_斑点工具", "LB_VisionProcesses.Alogrithms.OpenCvSharp.BlobTool" },
            { "OpenCvSharp_找线工具", "LB_VisionProcesses.Alogrithms.OpenCvSharp.FindLineTool" },
 
            //工具
            { "创建绘制工具", "LB_VisionProcesses.Processes.RecordTool" },
            { "创建固定跟随", "LB_VisionProcesses.Alogrithms.CreateFixtureTool" },
            { "创建线段工具", "LB_VisionProcesses.Alogrithms.CreateSegmentTool" },
            { "创建垂线工具", "LB_VisionProcesses.Alogrithms.CreateVerticalTool" },
            { "线线交点工具", "LB_VisionProcesses.Alogrithms.IntersectionLine2Tool" },
            { "轮胎计数", "LB_VisionProcesses.Processes.TyreCounterProcess" },
            { "脚本", "LB_VisionProcesses.Processes.ScriptTool" },
            { "延时", "LB_VisionProcesses.Processes.DelayTime" },
            { "分支", "LB_VisionProcesses.Processes.ScriptTool" },
            { "多分支", "LB_VisionProcesses.Processes.ScriptTool" },
 
        };
 
        static IProcess()
        {
            _isRunningVisionProServer = true;
        }
 
        public static bool _isRunningVisionProServer = false;
 
        /// <summary>
        /// 通讯和相机集合
        /// </summary>
        public static List<BaseCommunicator> lstCommunicators = new List<BaseCommunicator>();
        public static List<BaseCamera> lstCameras = new List<BaseCamera>();
 
        /// <summary>
        /// 固定跟随集合
        /// </summary>
        public static ConcurrentDictionary<string, Fixture> dicFixtures = new ConcurrentDictionary<string, Fixture>();
 
        /// <summary>
        /// 畸变矫正集合
        /// </summary>
        public static ConcurrentDictionary<string, HCaltabMap> dicHCaltabMaps = new ConcurrentDictionary<string, HCaltabMap>();
 
        /// <summary>
        /// 全局变量集合(Key:变量名,Value:变量值)
        /// </summary>
        public static ConcurrentDictionary<string, object> dicGlobalVars = new ConcurrentDictionary<string, object>();
 
        /// <summary>
        /// 运行日志
        /// </summary>
        public string Msg = "运行成功";
 
        /// <summary>
        /// 运行结果
        /// </summary>
        public bool Result = true;
 
        /// <summary>
        /// 运行时间
        /// </summary>
        public double RunTime = 0;
 
        /// <summary>
        /// 允许运行时间
        /// </summary>
        public double MaxTimeOut = 2000;
 
        /// <summary>
        /// 工具名称
        /// </summary>
        public string strProcessName = string.Empty;
 
        /// <summary>
        /// 工具类名
        /// </summary>
        public string strProcessClass = "LB_VisionProcesses.IProcess";
 
        /// <summary>
        /// 算法参数
        /// </summary>
        public ProcessParams Params = new ProcessParams();
 
        /// <summary>
        /// 输入图片
        /// </summary>
        public object InputImage;
 
        /// <summary>
        /// 输出图片
        /// </summary>
        public object OutputImage;
 
        /// <summary>
        /// 结果区域
        /// </summary>
        public ObjectRecord Record = new ObjectRecord();
 
        /// <summary>
        /// 运行完成标记
        /// </summary>
        public bool bCompleted = false;
 
        public abstract void InitRunParams();
 
        public abstract bool Run();
 
        public abstract bool Load(string fullPath);
 
        public abstract bool Save(string filePath);
 
        public static Assembly GetExecutingAssembly()
        {
            return Assembly.GetExecutingAssembly();
        }
 
        public abstract object Clone();
 
        public abstract void Dispose();
    }
 
 
    [Serializable]
    public class Fixture
    {
        /// <summary>
        /// 横坐标X
        /// </summary>
        public double X = 0;
        public double Column
        {
            get { return X; }
            set { X = value; }
        }
 
        /// <summary>
        /// 纵坐标Y
        /// </summary>
        public double Y = 0;
        public double Row
        {
            get { return Y; }
            set { Y = value; }
        }
 
        /// <summary>
        /// 弧度Phi
        /// </summary>
        public double Phi = 0;
        public double Angle
        {
            get { return Phi / Math.PI * 180; }
            set { Phi = value / 180 * Math.PI; }
        }
 
        public string strName = "";
 
        public Fixture() { }
 
        [JsonConstructor]  // 标记为用于反序列化
        public Fixture(double x, double y, double phi, string strName)
        {
            this.X = x; this.Y = y; this.Phi = phi;
            this.strName = strName;
        }
 
        public Fixture(Fixture fixture)
        {
            if (fixture == null)
                return;
            this.X = fixture.X; this.Y = fixture.Y; this.Phi = fixture.Phi;
            this.strName = fixture.strName;
        }
 
        public Fixture(string strName) => this.strName = strName;
 
        public void GetOffset(double x, double y, double phi, out double offsetX, out double offsetY, out double offsetPhi)
        {
            offsetX = X - x; offsetY = Y - y; offsetPhi = Phi - phi;
        }
 
        public object Clone()
        {
            return MemberwiseClone();
        }
    }
 
    public class NaturalStringComparer : IComparer<string>
    {
        [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
        public static extern int StrCmpLogicalW(string psz1, string psz2);
        public int Compare(string x, string y)
        {
            return StrCmpLogicalW(x, y);
        }
    }
}