CameraShotCls.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  42. iCnt++;
  43. }
  44. }
  45. /// <summary>
  46. /// 从硬盘录像机 进行截图
  47. /// </summary>
  48. /// <param name="actualFirstNo"></param>
  49. public void CapPicFromVideo(string actualFirstNo)
  50. {
  51. string fullfilename = Path.Combine(AppConfigCache.ftpPath, DateTime.Now.ToString("yyyy-MM-dd"));
  52. if (fullfilename.Substring(0, 8) == "https://")
  53. {
  54. fullfilename = fullfilename.Substring(0, 8) + fullfilename.Substring(8).Replace("//", "/").Replace("//", "/");
  55. }
  56. else if (fullfilename.Substring(0, 7) == "http://")
  57. {
  58. fullfilename = fullfilename.Substring(0, 7) + fullfilename.Substring(7).Replace("//", "/").Replace("//", "/");
  59. }
  60. else
  61. {
  62. fullfilename = fullfilename.Replace("//", "/").Replace("//", "/");
  63. }
  64. fullfilename = fullfilename.Replace("upload", "download");
  65. foreach (DhCameraShot shot in CarCache.cameraShots)
  66. {
  67. //放在tempImg文件夹下面就进行图片的压缩操作,否则不进行图片压缩
  68. //shot.CapPic(iCnt < 3 ? 0 : 1, PbCache.path + string.Format("\\imgShort\\tempImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, iCnt));
  69. shot.CapPicFromVedio(PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo));
  70. PbCache.listImage[0].imageFile1 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "1.jpg";
  71. PbCache.listImage[0].imageFile2 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "2.jpg";
  72. PbCache.listImage[0].imageFile3 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "3.jpg";
  73. PbCache.listImage[0].imageFile4 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "4.jpg";
  74. PbCache.listImage[0].imageFile5 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "5.jpg";
  75. PbCache.listImage[0].imageFile6 = fullfilename + string.Format("/{0}_{1}_", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo) + "6.jpg";
  76. }
  77. }
  78. /// <summary>
  79. /// 连接视频截图并关闭
  80. /// </summary>
  81. /// <param name="actualFirstNo">作业编号</param>
  82. public void CapMethod(string actualFirstNo)
  83. {
  84. Connection();
  85. //CapPic(actualFirstNo);
  86. CapPicFromVideo(actualFirstNo);
  87. Close();
  88. }
  89. }
  90. }