轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-03-30 06c627ec032b3f3876fd7db8a3ff0ff1a6614fa2
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
using HalconDotNet;
using LB_SmartVisionCommon;
using LB_VisionProcesses.Processes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
 
namespace LB_VisionProcesses.Alogrithms
{
    public class CreateFixtureTool : TAlgorithm
    {
        public CreateFixtureTool()
        {
            strProcessClass = "LB_VisionProcesses.Alogrithms.CreateFixtureTool";
            strProcessName = "创建固定跟随";
 
            Params.Inputs.Add("X", 0.0);
            Params.Inputs.Add("Y", 0.0);
            Params.Inputs.Add("Phi", 0.0);
            Params.Inputs.Add("Name", "Fixture1");
        }
 
        public override bool Run()
        {
            try
            {
                InitRunParams();
 
                Record = new MsgRecord();
 
                double X = 0, Y = 0, Phi = 0;
                string Name = string.Empty;
 
                if (Params.Inputs["X"] is List<double> && (Params.Inputs["X"] as List<double>).Count > 0)
                {
                    X = (Params.Inputs["X"] as List<double>)[0];
                    Y = (Params.Inputs["Y"] as List<double>)[0];
                    Phi = (Params.Inputs["Phi"] as List<double>)[0];
                    Name = (string)Params.Inputs["Name"];
                }
                else if (Params.Inputs.ContainsKey("X") && Params.Inputs["X"] is double)
                {
                    X = (double)Params.Inputs["X"];
                    Y = (double)Params.Inputs["Y"];
                    Phi = (double)Params.Inputs["Phi"];
                    Name = (string)Params.Inputs["Name"];
                }
 
                Params.Fixture = new Fixture(X, Y, Phi, Name);
                if (!dicFixtures.ContainsKey(Name))
                {
                    dicFixtures.TryAdd(Name, Params.Fixture);
                }
                else if (dicFixtures.ContainsKey(Name))
                {
                    dicFixtures[Name] = Params.Fixture;
                }
 
                if (Params.Fixture == null)
                {
                    Result = false;
 
                    Msg = $"生成[{Name}]错误({X},{Y},{Phi})";
                    AsyncLogHelper.Error(Msg);
                }
                else
                {
                    Result = true;
                    ((MsgRecord)Record).AddRecord("·", Y, X);
                }
 
                return Result;
            }
            catch
            {
                OutputImage = null;
                Result = false;
                Msg = string.Format("运行出现异常");
                AsyncLogHelper.Error(Msg);
                return false;
            }
            finally
            {
                if (!Result)
                {
                    OutputImage = null;
                }
                bCompleted = true;
            }
        }
 
        public override bool Save(string filePath = "")
        {
            return base.Save(filePath);
        }
 
        public override bool Load(string fullPath = "")
        {
            if (base.Load(fullPath))
            {
                double X = 0, Y = 0, Phi = 0;
                string Name = string.Empty;
 
                if (Params.Inputs["X"] is List<double> && (Params.Inputs["X"] as List<double>).Count > 0)
                {
                    X = (Params.Inputs["X"] as List<double>)[0];
                    Y = (Params.Inputs["Y"] as List<double>)[0];
                    Phi = (Params.Inputs["Phi"] as List<double>)[0];
                    Name = (string)Params.Inputs["Name"];
                }
                else if (Params.Inputs.ContainsKey("X") && Params.Inputs["X"] is double)
                {
                    X = (double)Params.Inputs["X"];
                    Y = (double)Params.Inputs["Y"];
                    Phi = (double)Params.Inputs["Phi"];
                    Name = (string)Params.Inputs["Name"];
                }
 
                Params.Fixture = new Fixture(X, Y, Phi, Name);
                if (!dicFixtures.ContainsKey(Name))
                {
                    dicFixtures.TryAdd(Name, Params.Fixture);
                }
                else if (dicFixtures.ContainsKey(Name))
                {
                    dicFixtures[Name] = Params.Fixture;
                }
 
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}