轮胎外观检测添加思谋语义分割模型检测工具
C3204
14 小时以前 848ae3a7841a16322c23f9c0d10b2fab83a97c2c
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
using LB_SmartVisionCameraDevice.Data;
using LB_SmartVisionCameraDevice.PHM6000;
using LB_SmartVisionCameraSDK.PHM6000;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace LB_SmartVisionCameraDevice
{
    /// <summary>
    /// PHM6000SensorManager
    /// </summary>
    public class PHM6000SensorManager
    {
        /// <summary>
        /// GetCameraList
        /// </summary>
        /// <returns>Dictionary<string, PHM6000SensorModel></returns>
        /// <exception cref="Exception">Exception</exception>
        #region 得到摄像头列表
        public static Dictionary<string, PHM6000SensorModel> GetCameraDictionary()
        {
            //创建照相机接口,返回其句柄
            IntPtr entry = PHM6000Profiler.CreateCameraEntry();
 
            //返回相机个数,-1则为查失败
            var count = PHM6000Profiler.DiscoverCameras(entry);
            if (count == -1)
            {
                throw new Exception("查找摄像头失败!");
            }
            byte[] bytes = new byte[16];
            byte[] modelBytes = new byte[64];
            byte[] serialNOBytes = new byte[64];
            int port = 0;
            Dictionary<string, PHM6000SensorModel> ipList = new Dictionary<string, PHM6000SensorModel>();
            //对每个相机进行查找IP
            for (int i = 0; i < count; i++)
            {
                var ipResult = PHM6000Profiler.GetCameraAddress(entry, i, bytes, ref port);
                if (ipResult == -1)
                {
                    throw new Exception("获取摄像头IP错误");
                }
                var infoResult = PHM6000Profiler.GetCameraInformation(entry, i, modelBytes, serialNOBytes);
                if (infoResult == -1)
                {
                    throw new Exception("获取摄像头信息错误");
                }
                var ip = Encoding.ASCII.GetString(bytes);
                var serialNo = Encoding.ASCII.GetString(serialNOBytes);
                var model = Encoding.ASCII.GetString(modelBytes);
                ip = ip.Replace("\0", "");
                serialNo = serialNo.Replace("\0", "").Replace("X", "B");
                model = model.Replace("\0", "");
                if (model.Contains("8080"))
                {
                    model = "PHM6080";
                }
                if (model.Contains("8300"))
                {
                    model = "PHM6300";
                }
                if (model.Contains("8030"))
                {
                    model = "PHM6030";
                }
                ipList.Add(serialNo, new PHM6000SensorModel
                {
                    IP = ip,
                    Port = port,
                    Model = model,
                    SerialNo = serialNo,
                    State = StateIcon.DisConnect,
                });
            }
            PHM6000Profiler.DestroyCameraEntry(entry);//销毁
            return ipList;
        }
        #endregion
 
        #region 得到摄像头列表
        public static List<PHM6000SensorModel> GetCameraList()
        {
            //创建照相机接口,返回其句柄
            IntPtr entry = PHM6000Profiler.CreateCameraEntry();
            //返回相机个数,-1则为查失败
            var count = PHM6000Profiler.DiscoverCameras(entry);
            if (count == -1)
            {
                throw new Exception("查找摄像头失败!");
            }
            byte[] bytes = new byte[16];
            byte[] modelBytes = new byte[64];
            byte[] serialNOBytes = new byte[64];
            int port = 0;
            List<PHM6000SensorModel> ipList = new List<PHM6000SensorModel>();
            //对每个相机进行查找IP
            for (int i = 0; i < count; i++)
            {
                var ipResult = PHM6000Profiler.GetCameraAddress(entry, i, bytes, ref port);
                if (ipResult == -1)
                {
                    throw new Exception("获取摄像头IP错误");
                }
                var infoResult = PHM6000Profiler.GetCameraInformation(entry, i, modelBytes, serialNOBytes);
                if (infoResult == -1)
                {
                    throw new Exception("获取摄像头信息错误");
                }
                var ip = Encoding.ASCII.GetString(bytes);
                var serialNo = Encoding.ASCII.GetString(serialNOBytes);
                var model = Encoding.ASCII.GetString(modelBytes);
                ip = ip.Replace("\0", "");
                serialNo = serialNo.Replace("\0", "").Replace("X", "B");
                model = model.Replace("\0", "");
                if (model.Contains("8080"))
                {
                    model = "PHM6080";
                }
                if (model.Contains("8300"))
                {
                    model = "PHM6300";
                }
                if (model.Contains("8030"))
                {
                    model = "PHM6030";
                }
                ipList.Add(new PHM6000SensorModel
                {
                    IP = ip,
                    Port = port,
                    Model = model,
                    SerialNo = serialNo,
                    State = StateIcon.DisConnect,
                });
            }
            PHM6000Profiler.DestroyCameraEntry(entry);//销毁
            return ipList;
        }
        #endregion
    }
}