diff --git a/include/easypr/chars_recognise.h b/include/easypr/chars_recognise.h index 2372904..1769008 100644 --- a/include/easypr/chars_recognise.h +++ b/include/easypr/chars_recognise.h @@ -24,6 +24,8 @@ class CCharsRecognise { public: CCharsRecognise(); + ~CCharsRecognise(); + //! 字符分割与识别 int charsRecognise(Mat, String&); diff --git a/include/easypr/plate_detect.h b/include/easypr/plate_detect.h index 0640fa5..c30cc48 100644 --- a/include/easypr/plate_detect.h +++ b/include/easypr/plate_detect.h @@ -25,9 +25,11 @@ class CPlateDetect { public: CPlateDetect(); + ~CPlateDetect(); + //! 深度车牌检测,使用颜色与二次Sobel法综合 int plateDetect(Mat src, vector& resultVec, - bool showDetectArea = true, int index = 0); + bool showDetectArea = true, int index = 0); //! 展示中间的结果 int showResult(const Mat& result); diff --git a/include/easypr/util.h b/include/easypr/util.h index da7bce6..4583a62 100644 --- a/include/easypr/util.h +++ b/include/easypr/util.h @@ -14,6 +14,14 @@ #define OS_LINUX #endif +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) \ + if ((p)) { \ + delete (p); \ + (p) = NULL; \ + } +#endif + namespace easypr { class Utils { public: diff --git a/src/core/chars_recognise.cpp b/src/core/chars_recognise.cpp index 3fe49bf..a327778 100644 --- a/src/core/chars_recognise.cpp +++ b/src/core/chars_recognise.cpp @@ -1,4 +1,5 @@ #include "easypr/chars_recognise.h" +#include "easypr/util.h" /*! \namespace easypr Namespace where all the C++ EasyPR functionality resides @@ -6,11 +7,15 @@ Namespace where all the C++ EasyPR functionality resides namespace easypr { CCharsRecognise::CCharsRecognise() { - // cout << "CCharsRecognise" << endl; m_charsSegment = new CCharsSegment(); m_charsIdentify = new CCharsIdentify(); } +CCharsRecognise::~CCharsRecognise() { + SAFE_RELEASE(m_charsSegment); + SAFE_RELEASE(m_charsIdentify); +} + void CCharsRecognise::LoadANN(string s) { m_charsIdentify->LoadModel(s.c_str()); } diff --git a/src/core/plate_detect.cpp b/src/core/plate_detect.cpp index 6271c94..6de8934 100644 --- a/src/core/plate_detect.cpp +++ b/src/core/plate_detect.cpp @@ -15,10 +15,15 @@ CPlateDetect::CPlateDetect() { m_maxPlates = 3; } +CPlateDetect::~CPlateDetect() { + SAFE_RELEASE(m_plateLocate); + SAFE_RELEASE(m_plateJudge); +} + void CPlateDetect::LoadSVM(string s) { m_plateJudge->LoadModel(s.c_str()); } int CPlateDetect::plateDetect(Mat src, vector& resultVec, - bool showDetectArea, int index) { + bool showDetectArea, int index) { vector resultPlates; vector color_Plates;