recorder.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. using namespace toolkit;
  20. using namespace std;
  21. //using namespace cv;
  22. namespace MIVA
  23. {
  24. class recorder
  25. {
  26. public:
  27. recorder() {}
  28. ~recorder() {}
  29. static std::shared_ptr<recorder> CreateNew();
  30. void Start();
  31. void Finish();
  32. void ConsumerData(std::string Pid,cv::Mat& frame);
  33. std::string GetFileName(std::string Pid);
  34. private:
  35. struct Writer{
  36. std::string fileName = "";
  37. std::shared_ptr<cv::VideoWriter> videoWriter = nullptr;
  38. };
  39. map<std::string, Writer> videoWriters;
  40. public:
  41. bool enable = true;
  42. bool RecordEnable = true;
  43. int outType = 0; // 0 图片 1视频
  44. std::string outDir = "";
  45. std::string Dir = "./video/";
  46. using Ptr = std::shared_ptr<recorder>;
  47. };
  48. } // namespace name