recorder.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <iostream>
  3. #include <map>
  4. #include <time.h>
  5. #include <dirent.h>
  6. #include <time.h>
  7. #include <cstdlib>
  8. #include <dirent.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. // opencv
  12. #include <opencv2/core.hpp>
  13. #include <opencv2/videoio.hpp>
  14. #include <opencv2/highgui.hpp>
  15. #include <opencv2/imgproc.hpp>
  16. #include <opencv2/imgproc/types_c.h>
  17. #include "Util/logger.h"
  18. #include "DataSource.h"
  19. #include "InferVideo.h"
  20. #include "Disposition.hpp"
  21. using namespace toolkit;
  22. using namespace std;
  23. //using namespace cv;
  24. namespace gsd_ds
  25. {
  26. class recorder
  27. {
  28. public:
  29. recorder() {}
  30. ~recorder() {}
  31. /**
  32. * @description: 构建New
  33. * @return {*}
  34. */
  35. static std::shared_ptr<recorder> CreateNew();
  36. /**
  37. * @description: 获取Ptr
  38. * @return {*}
  39. */
  40. static std::shared_ptr<recorder> getPtr();
  41. /**
  42. * @description: ConsumerData
  43. * @param {int} dv_id
  44. * @param {int} num
  45. * @param {Mat&} frame
  46. * @return {*}
  47. */
  48. void ConsumerData(int dv_id, int num, cv::Mat& frame);
  49. /**
  50. * @description: 获取文件名
  51. * @param {string} Pid
  52. * @return {*}
  53. */
  54. std::string GetFileName(int dv_id);
  55. private:
  56. struct Writer{
  57. std::shared_ptr<cv::VideoWriter> videoWriter = nullptr;
  58. std::shared_ptr<InferVideo> InferVideoWriter = nullptr;
  59. };
  60. map<int, Writer> videoWriters;
  61. public:
  62. bool enable = true;
  63. bool RecordEnable = true;
  64. std::string outDir = "";
  65. std::string Dir = "./video/";
  66. using Ptr = std::shared_ptr<recorder>;
  67. };
  68. } // namespace name