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.

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