CameraShotCls.cs 2.7 KB

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