InfineFilter.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-03-22 14:00:35
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-08-01 16:34:15
  8. */
  9. #ifndef __INFINEFILTER_H_
  10. #define __INFINEFILTER_H_
  11. #include <memory>
  12. #include <string>
  13. #include <vector>
  14. #include <map>
  15. #include <list>
  16. #include <queue>
  17. #include "cnstream_frame.hpp"
  18. #include "cnstream_module.hpp"
  19. #include "easyinfer/model_loader.h"
  20. #include "easytrack/easy_track.h"
  21. #include "cnstream_frame_va.hpp"
  22. #include "opencv2/highgui/highgui.hpp"
  23. #include "opencv2/imgproc/imgproc.hpp"
  24. #include "opencv2/dnn.hpp"
  25. #include "opencv2/opencv.hpp"
  26. #include "opencv2/highgui.hpp"
  27. #include "opencv2/imgcodecs/imgcodecs.hpp"
  28. #include <rapidjson/document.h>
  29. #include <rapidjson/rapidjson.h>
  30. #include <rapidjson/stringbuffer.h>
  31. #include <rapidjson/writer.h>
  32. #include <ctime>
  33. #include <iostream>
  34. #include <time.h>
  35. #include <cstdlib>
  36. #include <dirent.h>
  37. #include <sys/types.h>
  38. #include <sys/stat.h>
  39. using namespace std;
  40. namespace cnstream{
  41. // Pointer for frame info
  42. using CNFrameInfoPtr = std::shared_ptr<CNFrameInfo>;
  43. /// Pointer for infer object
  44. using CNInferObjectPtr = std::shared_ptr<CNInferObject>;
  45. class InfineFilter : public cnstream::Module, public cnstream::ModuleCreator<InfineFilter> {
  46. using super = cnstream::Module;
  47. public:
  48. explicit InfineFilter(const std::string &name) : super(name) {}
  49. bool Open(cnstream::ModuleParamSet paramSet) override;
  50. void Close() override { std::cout << this->GetName() << " Close called" << std::endl; }
  51. int Process(std::shared_ptr<cnstream::CNFrameInfo> data) override;
  52. bool filter(cv::Mat& image, CNInferObjsPtr objs_holder);
  53. bool AlienFilter(CNInferObjsPtr& objs_holder);
  54. bool proportionalFilter(cv::Mat& image, CNInferObjsPtr objs_holder);
  55. bool nightFilter(cv::Mat& image, CNInferObjsPtr objs_holder);
  56. bool getNight();
  57. std::string getTime();
  58. private:
  59. InfineFilter(const InfineFilter &) = delete;
  60. InfineFilter &operator=(InfineFilter const &) = delete;
  61. vector<std::string> labels;
  62. vector<std::string> AlienLabels;
  63. bool saveFilterResult = true;
  64. bool Night_Filter = true;
  65. std::string files = "./output/";
  66. double Proportion_th = 0.2;
  67. double Night_th = 0.2;
  68. int start = 21;
  69. int end = 6;
  70. };
  71. };
  72. #endif