CameraShotCls.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using Common;
  2. using MeterPlugInLibrary;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace RailMeterSystem
  9. {
  10. /// <summary>
  11. /// 截图调用类
  12. /// </summary>
  13. public class CameraShotCls
  14. {
  15. public void Connection()
  16. {
  17. foreach (DhCameraShot shot in CarCache.cameraShots)
  18. {
  19. shot.Connection();
  20. }
  21. }
  22. public void Close()
  23. {
  24. foreach (DhCameraShot shot in CarCache.cameraShots)
  25. {
  26. shot.Close();
  27. }
  28. }
  29. /// <summary>
  30. /// 截图
  31. /// </summary>
  32. /// <param name="actualFirstNo">作业编号</param>
  33. public void CapPic(string actualFirstNo)
  34. {
  35. int iCnt = 1; //抓拍摄像头配置顺序必须是前面2个
  36. foreach (DhCameraShot shot in CarCache.cameraShots)
  37. {
  38. shot.CapPic(1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbStaticRailwayCache.sportInfo.baseSpotNo, "R" + actualFirstNo, iCnt));
  39. iCnt++;
  40. }
  41. }
  42. /// <summary>
  43. /// 从硬盘录像机 进行截图
  44. /// </summary>
  45. /// <param name="actualFirstNo"></param>
  46. public void CapPicFromVideo(string actualFirstNo)
  47. {
  48. foreach (DhCameraShot shot in CarCache.cameraShots)
  49. {
  50. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  51. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  52. shot.CapPicFromVedio(PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_", PbStaticRailwayCache.sportInfo.baseSpotNo, "R" + actualFirstNo));
  53. }
  54. }
  55. /// <summary>
  56. /// 连接视频截图并关闭
  57. /// </summary>
  58. /// <param name="actualFirstNo">作业编号</param>
  59. public void CapMethod(string actualFirstNo)
  60. {
  61. Connection();
  62. CapPic(actualFirstNo);
  63. Close();
  64. }
  65. /// <summary>
  66. /// 连接视频截图并关闭;使用硬盘录像机
  67. /// </summary>
  68. /// <param name="actualFirstNo">作业编号</param>
  69. public void CapMethodFromVideo(string actualFirstNo)
  70. {
  71. Connection();
  72. CapPicFromVideo(actualFirstNo);
  73. Close();
  74. }
  75. }
  76. public class CarCache
  77. {
  78. /// <summary>
  79. /// 摄像头的开关类集合
  80. /// </summary>
  81. public static List<DhCameraShot> cameraShots { get; set; }
  82. }
  83. }