HikVision.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using MvCameraControl;
  2. using MvvmScaffoldFrame48.Model.HikVisionCamera;
  3. using System.Collections.Generic;
  4. namespace MvvmScaffoldFrame48.DLL.CameraTools
  5. {
  6. /// <summary>
  7. /// HIKVISION相机类
  8. /// </summary>
  9. public static class HikVision
  10. {
  11. #region 常量
  12. private readonly static DeviceTLayerType enumTLayerType = DeviceTLayerType.MvGigEDevice | DeviceTLayerType.MvUsbDevice
  13. | DeviceTLayerType.MvGenTLGigEDevice | DeviceTLayerType.MvGenTLCXPDevice
  14. | DeviceTLayerType.MvGenTLCameraLinkDevice | DeviceTLayerType.MvGenTLXoFDevice;
  15. #endregion
  16. #region 变量
  17. #endregion
  18. #region 实例
  19. /// <summary>
  20. /// 相机列表
  21. /// </summary>
  22. private static List<IDeviceInfo> CamList;
  23. #endregion
  24. #region 公共方法
  25. /// <summary>
  26. /// 获取相机列表
  27. /// </summary>
  28. /// <param name="CamList"></param>
  29. /// <returns></returns>
  30. public static void GetCameraList(out List<CameraInfoClassModel> CameraInfoList)
  31. {
  32. CamList = new List<IDeviceInfo>();
  33. CameraInfoList = new List<CameraInfoClassModel>();
  34. int nRet = DeviceEnumerator.EnumDevices(enumTLayerType, out CamList);
  35. if (nRet != MvError.MV_OK)
  36. {
  37. return;
  38. }
  39. else
  40. {
  41. //输出相机名称及SN码以方便选择设备
  42. foreach (var item in CamList)
  43. {
  44. CameraInfoList.Add(new CameraInfoClassModel
  45. {
  46. DeviceName = item.ModelName,
  47. DeviceSN = item.SerialNumber,
  48. });
  49. }
  50. }
  51. return;
  52. }
  53. #endregion
  54. }
  55. }