| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //海康相机操作类
- using MvCameraControl;
- using MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera;
- using System.Collections.Generic;
- namespace MvvmScaffoldFrame48.DLL.CameraTools
- {
- /// <summary>
- /// HIKVISION相机类
- /// </summary>
- public static class HikVision
- {
- #region 常量
- private readonly static DeviceTLayerType enumTLayerType = DeviceTLayerType.MvGigEDevice | DeviceTLayerType.MvUsbDevice
- | DeviceTLayerType.MvGenTLGigEDevice | DeviceTLayerType.MvGenTLCXPDevice
- | DeviceTLayerType.MvGenTLCameraLinkDevice | DeviceTLayerType.MvGenTLXoFDevice;
- #endregion
- #region 变量
- #endregion
- #region 实例
- /// <summary>
- /// 相机列表
- /// </summary>
- private static List<IDeviceInfo> CamList;
- #endregion
- #region 公共方法
- /// <summary>
- /// 获取相机列表
- /// </summary>
- /// <param name="CamList"></param>
- /// <returns></returns>
- public static void GetCameraList(out List<CameraInfoModel> CameraInfoList)
- {
- CamList = new List<IDeviceInfo>();
- CameraInfoList = new List<CameraInfoModel>();
- int nRet = DeviceEnumerator.EnumDevices(enumTLayerType, out CamList);
- if (nRet != MvError.MV_OK)
- {
- return;
- }
- else
- {
- //输出相机名称及SN码以方便选择设备
- foreach (var item in CamList)
- {
- CameraInfoList.Add(new CameraInfoModel
- {
- DeviceName = item.ModelName,
- DeviceSN = item.SerialNumber,
- });
- }
- }
- return;
- }
- /// <summary>
- /// 获取相机列表
- /// </summary>
- /// <param name="CamList"></param>
- /// <returns></returns>
- public static void GetCameraList(out List<IDeviceInfo> CameraInfoList)
- {
- CamList = new List<IDeviceInfo>();
- int nRet = DeviceEnumerator.EnumDevices(enumTLayerType, out CamList);
- if (nRet != MvError.MV_OK)
- {
- CameraInfoList = null;
- return;
- }
- else
- {
- CameraInfoList = CamList;
- }
- return;
- }
- #endregion
- }
- }
|