CameraShotCls.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Common;
  2. using MeterPlugInLibrary;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CarMeterSystem.OptionCls
  10. {
  11. /// <summary>
  12. /// 截图调用类
  13. /// </summary>
  14. public class CameraShotCls
  15. {
  16. private Log lg = Log.GetInstance(); //写日志
  17. public void Connection()
  18. {
  19. try
  20. {
  21. foreach (DhCameraShot shot in CarCache.cameraShots)
  22. {
  23. shot.Connection();
  24. }
  25. }
  26. catch (Exception ex)
  27. {
  28. lg.WriteLog(39, ex.Message);
  29. }
  30. }
  31. public void Close()
  32. {
  33. try
  34. {
  35. foreach (DhCameraShot shot in CarCache.cameraShots)
  36. {
  37. shot.Close();
  38. }
  39. }
  40. catch (Exception ex)
  41. {
  42. lg.WriteLog(39, ex.Message);
  43. }
  44. }
  45. /// <summary>
  46. /// 截图
  47. /// </summary>
  48. /// <param name="actualFirstNo">作业编号</param>
  49. public void CapPic(string actualFirstNo)
  50. {
  51. try
  52. {
  53. int iCnt = 1; //抓拍摄像头配置顺序必须是前面2个
  54. foreach (DhCameraShot shot in CarCache.cameraShots)
  55. {
  56. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  57. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  58. shot.CapPic(iCnt < 2 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  59. // 第一次抓拍为仪表重量
  60. //if(iCnt == 1)
  61. //{
  62. // Log.GetInstance().WriteLog(35, "完成仪表拍照 成功标识:" + PbCache.shotSuccess.ToString() + "车号:" + PbCache.lockCarNo + ";重量:" + PbCache.lockWgt + ";时间:" + DateTime.Now.ToLongTimeString());
  63. //}
  64. iCnt++;
  65. }
  66. }
  67. catch (Exception ex)
  68. {
  69. lg.WriteLog(39,ex.Message);
  70. }
  71. }
  72. /// <summary>
  73. /// 从硬盘录像机 进行截图
  74. /// </summary>
  75. /// <param name="actualFirstNo"></param>
  76. public void CapPicFromVideo(string actualFirstNo)
  77. {
  78. try
  79. {
  80. foreach (DhCameraShot shot in CarCache.cameraShots)
  81. {
  82. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  83. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  84. bool shotSuccess = shot.CapPicFromVedio(PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo));
  85. PbCache.shotSuccess = shotSuccess;
  86. }
  87. }
  88. catch (Exception ex)
  89. {
  90. lg.WriteLog(39, ex.Message);
  91. }
  92. }
  93. /// <summary>
  94. /// 连接视频截图并关闭
  95. /// </summary>
  96. /// <param name="actualFirstNo">作业编号</param>
  97. public void CapMethod(string actualFirstNo)
  98. {
  99. Connection();
  100. CapPic(actualFirstNo);
  101. //CapPicFromVideo(actualFirstNo);
  102. Close();
  103. }
  104. }
  105. }