CameraShotCls.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. public void Connection()
  17. {
  18. foreach (DhCameraShot shot in CarCache.cameraShots)
  19. {
  20. shot.Connection();
  21. }
  22. }
  23. public void Close()
  24. {
  25. foreach (DhCameraShot shot in CarCache.cameraShots)
  26. {
  27. shot.Close();
  28. }
  29. }
  30. /// <summary>
  31. /// 截图
  32. /// </summary>
  33. /// <param name="actualFirstNo">作业编号</param>
  34. public void CapPic(string actualFirstNo)
  35. {
  36. int iCnt = 1; //抓拍摄像头配置顺序必须是前面2个
  37. foreach (DhCameraShot shot in CarCache.cameraShots)
  38. {
  39. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  40. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  41. shot.CapPic(iCnt < 1 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  42. // 第一次抓拍为仪表重量
  43. if(iCnt == 1)
  44. {
  45. Log.GetInstance().WriteLog(35, "完成仪表拍照 成功标识:" + PbCache.shotSuccess.ToString() + "车号:" + PbCache.lockCarNo + ";重量:" + PbCache.lockWgt + ";时间:" + DateTime.Now.ToLongTimeString());
  46. }
  47. iCnt++;
  48. }
  49. }
  50. /// <summary>
  51. /// 从硬盘录像机 进行截图
  52. /// </summary>
  53. /// <param name="actualFirstNo"></param>
  54. public void CapPicFromVideo(string actualFirstNo)
  55. {
  56. foreach (DhCameraShot shot in CarCache.cameraShots)
  57. {
  58. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  59. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  60. bool shotSuccess = shot.CapPicFromVedio(PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo));
  61. PbCache.shotSuccess = shotSuccess;
  62. }
  63. }
  64. /// <summary>
  65. /// 连接视频截图并关闭
  66. /// </summary>
  67. /// <param name="actualFirstNo">作业编号</param>
  68. public void CapMethod(string actualFirstNo)
  69. {
  70. Connection();
  71. CapPic(actualFirstNo);
  72. //CapPicFromVideo(actualFirstNo);
  73. Close();
  74. }
  75. }
  76. }