轮胎外观检测添加思谋语义分割模型检测工具
C3204
8 天以前 d1444a09d4a4811a9ea7b86cb264d753ef14088c
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
 
using LB_VisionProcesses;
using LB_VisionProcesses.Cameras;
using LB_VisionProcesses.Cameras.HikCameras;
using LB_VisionProcesses.Cameras.HRCameras;
using LB_VisionProcesses.Cameras.LBCameras;
using LB_VisionProcesses.Cameras.LocalCameras;
using LB_VisionProcesses.Cameras.MicroCameras;
using LB_VisionProcesses.Cameras.MindCameras;
using LB_VisionProcesses.Communicators;
using RJCP.IO.Ports;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 
namespace LB_SmartVision.Forms.Pages.CameraPage
{
    public partial class CreateCameraForm : Form
    {
        public BaseCamera camera { get; set; }
        public bool bCreate = false;
 
        public CreateCameraForm(ICamera camera = null)
        {
            InitializeComponent();
            // 禁止修改窗口大小
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            if (camera == null)
            {
                camera = new HRCamera();
            }
 
            uiButtonCreate.Enabled = false;
        }
 
        private void uiButtonTest_Click(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
 
            if (string.IsNullOrEmpty(uiComboBoxSN.Text))
            {
                MessageBox.Show($"初始化相机[{uiComboBoxSN.Text}]为空!", "异常");
            }
 
            if (camera == null)
            {
                MessageBox.Show("请先选择相机品牌!", "异常");
                return;
            }
 
            camera.CloseDevice();
            if (camera.InitDevice(uiComboBoxSN.Text, this.Handle))
            {
                uiButtonCreate.Enabled = true;
                camera.CloseDevice();
            }
            else
            {
                MessageBox.Show($"初始化相机[{uiComboBoxSN.Text}]失败!", "异常");
            }
        }
 
        private void uiButtonCreate_Click(object sender, EventArgs e)
        {
            if (camera.InitDevice(uiComboBoxSN.Text, this.Handle))
            {
                bCreate = true;
                this.Close();
            }
            else
            {
                MessageBox.Show($"初始化相机[{uiComboBoxSN.Text}]失败!", "异常");
            }
        }
 
        private void uiButtonCancel_Click(object sender, EventArgs e)
        {
            if (camera != null)
            {
                camera.CloseDevice();
            }
            bCreate = false;
            this.Close();
        }
 
        private void uiComboBoxBrand_MouseClick(object sender, MouseEventArgs e)
        {
            uiComboBoxBrand.Items.Clear();
            foreach (CameraBrand brand in Enum.GetValues(typeof(CameraBrand)))
            {
                if (brand != CameraBrand.UNSUPPORTED)
                {
                    uiComboBoxBrand.Items.Add(brand.ToString());
                }
            }
        }
 
        private void uiComboBoxBrand_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
            uiComboBoxSN.Text = string.Empty;
 
            if (camera != null)
            {
                camera.CloseDevice();
            }
 
            Enum.TryParse<CameraBrand>(uiComboBoxBrand.Text, out CameraBrand brand);
            switch (brand)
            {
                case CameraBrand.HRCamera:
                    {
                        camera = new HRCamera();
                        break;
                    }
                case CameraBrand.LBCamera:
                    {
                        camera = new LBCamera();
                        break;
                    }
                case CameraBrand.LocalCamera:
                    {
                        camera = new LocalCamera();
                        break;
                    }
                case CameraBrand.HikCamera:
                    {
                        camera = new HikCamera();
                        break;
                    }
                case CameraBrand.HikCodeReader:
                    {
                        camera = new HikCodeReader();
                        break;
                    }
                case CameraBrand.MindCamera:
                    {
                        camera = new MindCamera();
                        break;
                    }
                case CameraBrand.MicroCamera:
                    {
                        camera = new MicroCamera();
                        break;
                    }
                default:
                    {
                        return;
                    }
            }
        }
 
        private void uiComboBoxSN_MouseClick(object sender, MouseEventArgs e)
        {
            uiButtonCreate.Enabled = false;
            uiComboBoxSN.Text = string.Empty;
 
            uiComboBoxSN.Items.Clear();
            var list = camera.GetListEnum();
 
            foreach (string sn in list)
            {
                uiComboBoxSN.Items.Add(sn);
            }
        }
 
        private void uiComboBoxSN_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
    }
}