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.

66 lines
2.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __IM_DNNWORKER_H_INCL__
  2. #define __IM_DNNWORKER_H_INCL__
  3. #include "../../lib/components/base/basicThread.h"
  4. #include "../../lib/components/base/basicMutex.h"
  5. #include "../../lib/components/base/basicSettingsProvider.h"
  6. #include "../../lib/components/base/basicEventHeap.h"
  7. #include "IM_DataStructs.h"
  8. #define DARKNET
  9. #ifdef DARKNET
  10. #define GPU
  11. //#include <darknet/darknet.h>
  12. #include <darknet/yolo_v2_class.hpp>
  13. #undef GPU
  14. #endif
  15. #include <opencv2/opencv.hpp>
  16. #include <opencv2/core.hpp>
  17. #include <opencv2/imgcodecs.hpp>
  18. #include <opencv2/highgui.hpp>
  19. #include <opencv2/dnn/dnn.hpp>
  20. using namespace cv;
  21. /**
  22. * TODO: Add class description
  23. *
  24. * @author Gagua
  25. */
  26. class IM_DnnWorker : public basicThread {
  27. private:
  28. #ifdef DARKNET
  29. Detector * m_pDarknetDetector;
  30. #else
  31. #endif
  32. basicLogCollection * m_pLog;
  33. config_setting_t * m_pSettings;
  34. cv::dnn::Backend m_eBackendEngine;
  35. cv::dnn::Target m_eTargetDevice;
  36. cv::dnn::Net m_net;
  37. cv::Mat m_oWorkingMat;
  38. float m_fDetectionProbability;
  39. bool m_bUseClassMapping;
  40. std::vector<uint32_t> m_vClassesMap;
  41. basicEventHeap * m_pEvtHeap;
  42. char m_pPicturesBase[1024];
  43. char m_pConfigPath[1024];
  44. char m_pWeightsPath[1024];
  45. basicMutex m_mBufferProtectorMutex;
  46. IM_JOB * m_pActiveJob;
  47. bool m_bDataIsActive;
  48. IM_RESULT * m_fImageAnalyzer( Mat &Picture );
  49. protected:
  50. virtual void m_fThreadProc( void );//getLayerNames()
  51. public:
  52. // Constructor
  53. explicit IM_DnnWorker( config_setting_t * Settings = NULL );
  54. // Destructor
  55. virtual ~IM_DnnWorker();
  56. bool create( void );
  57. bool enqueueJob( IM_JOB *ptr );
  58. };
  59. #endif // __IM_DNNWORKER_H_INCL__