You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASIC_VIDEO_ANALYZER_HEADER__
  2. #define __BASIC_VIDEO_ANALYZER_HEADER__
  3. #ifndef M_E
  4. #include <math.h>
  5. #endif
  6. #include <opencv2/core/core.hpp>
  7. #include <opencv2/features2d/features2d.hpp>
  8. #include <opencv2/opencv.hpp>
  9. #include <stdio.h>
  10. #include <vector>
  11. // #include <opencv2/nonfree/features2d.hpp>
  12. // #include <opencv2/nonfree/nonfree.hpp>
  13. #include <opencv2/highgui/highgui.hpp>
  14. #include <opencv2/stitching/detail/matchers.hpp>
  15. #undef min
  16. #undef max
  17. // #include <opencv2/gpu/gpu.hpp>
  18. #include <opencv2/video/tracking.hpp>
  19. // #ifdef _DEBUG
  20. // #pragma comment(lib,"opencv_core249d")
  21. // #pragma comment(lib,"opencv_gpu249d")
  22. // #pragma comment(lib,"opencv_highgui249d")
  23. // #else
  24. // #pragma comment(lib,"opencv_core249")
  25. // #pragma comment(lib,"opencv_gpu249")
  26. // #pragma comment(lib,"opencv_highgui249")
  27. // #endif
  28. #include "basicEventHeap.h"
  29. #include "basicLogCollection.h"
  30. #include "basicLoggingService.h"
  31. #include "basicMediaDestination.h"
  32. #include "basicMediaSource.h"
  33. #include "basicMutex.h"
  34. #include "basicThread.h"
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. using namespace cv;
  38. using namespace std;
  39. typedef vector<Point> tContour;
  40. typedef vector<Point2f> tPoints2F;
  41. typedef vector<tContour> tContours;
  42. typedef vector<Vec4i> tHierarhy;
  43. typedef enum E_VIDEO_ANALYZER_TYPE
  44. {
  45. VA_NO_TYPE = 0,
  46. VA_BLOB_DETECT = 1,
  47. VA_VM_DETECT = 2,
  48. VA_OPTIC_FLOW = 3,
  49. VA_SURF_DETECT = 4,
  50. VA_FEAT_DETECT = 5,
  51. VA_HAAR_DETECT = 6,
  52. VA_DNN_ANAL = 7
  53. } VIDEO_ANALYZER_TYPE;
  54. class basicVideoAnalyzer : public basicThread, public basicMediaDestination, public basicMediaSource
  55. {
  56. private:
  57. basicLogCollection * m_pLog;
  58. basicEventHeap * m_pEventHeap;
  59. protected:
  60. virtual void m_fThreadProc(void);
  61. protected:
  62. VIDEO_ANALYZER_TYPE type;
  63. basicMutex m_mBufferProtectorMutex;
  64. bool m_bPIP;
  65. bool m_bDetectionStatus;
  66. bool m_bDataIsActive;
  67. Mat m_oWorkingMat;
  68. virtual bool m_fImageAnalyzer(Mat & Picture)
  69. {
  70. return false;
  71. }
  72. virtual EVENT_CONTAINER * createVAEvent(bool Status)
  73. {
  74. return NULL;
  75. }
  76. public:
  77. basicVideoAnalyzer();
  78. ~basicVideoAnalyzer();
  79. bool getDetectionStatus(void)
  80. {
  81. return m_bDetectionStatus;
  82. }
  83. virtual void pushFrame(cv::Mat * Frame);
  84. virtual void markup(Mat & Picture) {}
  85. void setPIP(bool Val)
  86. {
  87. m_bPIP = Val;
  88. }
  89. VIDEO_ANALYZER_TYPE getType(void)
  90. {
  91. return type;
  92. }
  93. };
  94. typedef vector<basicVideoAnalyzer *> vectorVA;
  95. #endif