轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-04-02 3c837a3be1548e296d6ed1afb32ebe418b69db25
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
243
244
245
246
247
248
249
250
251
using Newtonsoft.Json;
using System.Collections.Concurrent;
using static ReaLTaiizor.Util.RoundInt;
 
namespace LB_VisionFlowNode
{
    [Serializable]
    public class FlowNode
    {
        // 用于标识节点的唯一ID
        [JsonProperty]
        public string Id { get; set; } = Guid.NewGuid().ToString();
 
        [JsonProperty]
        public bool Result { get; set; } = true;
 
        [JsonProperty]
        public bool Break { get; set; } = false;
 
        [JsonProperty]
        public RunState RunState { get; set; } = RunState.Wait;
 
        [JsonProperty]
        public NodeType NodeType { get; set; } = NodeType.Normal;
 
        [JsonProperty]
        public string Text { get; set; } = "名称";
 
        [JsonProperty]
        public string Description { get; set; } = "描述";
 
        //[JsonProperty]
        //public string NextNodeId { get; set; }
 
        [JsonIgnore]
        public FlowNode NextNode { get; set; } = null;
 
        #region 分支流程相关
        /// <summary>
        /// 多分支和并行节点的分支节点集合【Key: 分支名称, Value: 所链接的分支节点名称】
        /// </summary>
        public ConcurrentDictionary<string, string> BranchNodes { get; set; }
            = new ConcurrentDictionary<string, string>();
 
        [JsonProperty]
        public string BranchIndex { get; set; } = "0";
 
        // 分支条件(可选)
        public Func<bool> BranchCondition { get; set; }
 
        // 超时设置(用于并行执行)
        public int TimeoutMilliseconds { get; set; } = 60000;
        #endregion
 
        public int X { get; set; } = 0;
 
        public int Y { get; set; } = 0;
 
        public int Width { get; set; } = 100;
 
        public int Height { get; set; } = 40;
 
        public Point LeftPoint
        {
            get { return new Point(X - Width / 2, Y); }
        }
 
        public Point RightPoint
        {
            get { return new Point(X + Width / 2, Y); }
        }
 
        public Point BtmPoint
        {
            get { return new Point(X, Y + Height / 2); }
        }
 
        public Point TopPoint
        {
            get { return new Point(X, Y - Height / 2); }
        }
 
        public Rectangle GetBounds()
        {
            return new Rectangle(X - Width / 2, Y - Height / 2, Width, Height);
        }
 
        public Color GetColor()
        {
            if (Break)
                return Color.SlateGray;
 
            switch (RunState)
            {
                case RunState.Wait:
                    return Color.Gray;
                case RunState.Running:
                    return Color.LightYellow;
                case RunState.Error:
                    return Color.MediumVioletRed;
                case RunState.Pass:
                    return Color.LightGreen;
                default:
                    return Color.DimGray;
            }
        }
 
        public List<Point> GetConnectionPoints()
        {
            List<Point> points = new List<Point>() { };
            switch (NodeType)
            {
                case NodeType.Begin:
                    points.Add(BtmPoint);
                    break;
                case NodeType.End:
                    points.Add(TopPoint);
                    break;
                case NodeType.Switch:
                    points.Add(TopPoint);
                    points.Add(LeftPoint);
                    points.Add(RightPoint);
                    break;
                case NodeType.MultiBranch:
                case NodeType.Parallel:
                    points.Add(TopPoint);
                    int branchCount = BranchNodes.Count;
                    if (branchCount == 0)
                        break;
                    int spacing = Width / (branchCount + 1);
                    for (int i = 1; i <= branchCount; i++)
                        points.Add(new Point(X - Width / 2 + i * spacing, Y + Height / 2));
                    break;
                case NodeType.Join:
                case NodeType.Normal:
                    points.Add(TopPoint);
                    points.Add(BtmPoint);
                    break;
                default: break;
            }
            return points;
        }
 
        public Point GetBranchPoints(int index)
        {
            List<Point> points = new List<Point>() { };
            switch (NodeType)
            {
                case NodeType.Begin:
                    points.Add(BtmPoint);
                    break;
                case NodeType.End:
                    break;
                case NodeType.Switch:
                    points.Add(LeftPoint);
                    points.Add(RightPoint);
                    break;
                case NodeType.MultiBranch:
                case NodeType.Parallel:
                    int branchCount = BranchNodes.Count;
                    if (branchCount == 0)
                        break;
                    int spacing = Width / (branchCount + 1);
                    for (int i = 1; i <= branchCount; i++)
                        points.Add(new Point(X - Width / 2 + i * spacing, Y + Height / 2));
                    break;
                case NodeType.Join:
                case NodeType.Normal:
                    points.Add(BtmPoint);
                    break;
                default: break;
            }
 
            if (index >= 0 && index < points.Count)
                return points[index];
            else
                return new Point(-1, -1);
        }
 
        public List<Point> GetBranchPoints()
        {
            List<Point> points = new List<Point>() { };
            switch (NodeType)
            {
                case NodeType.Begin:
                    points.Add(BtmPoint);
                    break;
                case NodeType.End:
                    break;
                case NodeType.Switch:
                    points.Add(LeftPoint);
                    points.Add(RightPoint);
                    break;
                case NodeType.MultiBranch:
                case NodeType.Parallel:
                    int branchCount = BranchNodes.Count;
                    if (branchCount == 0)
                        break;
                    int spacing = Width / (branchCount + 1);
                    for (int i = 1; i <= branchCount; i++)
                        points.Add(new Point(X - Width / 2 + i * spacing, Y + Height / 2));
                    break;
                case NodeType.Join:
                case NodeType.Normal:
                    points.Add(BtmPoint);
                    break;
                default: break;
            }
            return points;
        }
 
        public FlowNode() { }
 
        public FlowNode(NodeType nodeType, Point location, string text, string description, int width = 100, int height = 40)
        {
            NodeType = nodeType;
            X = location.X;
            Y = location.Y;
            Width = width;
            Height = height;
            Text = text;
            Description = description;
        }
 
        public static Point[] GetDiamondPoints(Rectangle bounds)
        {
            int centerX = bounds.X + bounds.Width / 2;
            int centerY = bounds.Y + bounds.Height / 2;
 
            return new Point[]{ new Point(centerX, bounds.Y), new Point(bounds.Right, centerY)
                , new Point(centerX, bounds.Bottom), new Point(bounds.X, centerY)};
        }
    }
 
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public class NodeAttribute : Attribute
    {
        public string Name { get; }
        public string Category { get; }
        public string Group { get; }
        public string Description { get; }
 
        public NodeAttribute(string name, string category, string group, string description)
        {
            Name = name;
            Category = category;
            Group = group;
            Description = description;
        }
    }
}