Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document of easyPR #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions easyPR-doc/algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- NMS(非极大值抑制)
- 选取邻近区域中得分最高的矩形块,以区分多个矩形重叠的情况
- SVM(支持向量机)
- <img src="./img/SVM.png" wid=600px/>
9 changes: 9 additions & 0 deletions easyPR-doc/classDemo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Class

#### Properties

#### Functions

***

***
34 changes: 34 additions & 0 deletions easyPR-doc/core/chars_identify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Class CharsIdentify

#### Properties
- (private:)
- [`annCallback extractFeature`](#extractFeature)
- [`static CharsIdentify* instance_`](#instance_)
- [`cv::Ptr<cv::ml::ANN_MLP> ann_`](#ann_)
- [`cv::Ptr<cv::ml::ANN_MLP> annChinese_`](#annChinese_)
- [`cv::Ptr<cv::ml::ANN_MLP> annGray_`](#annGray_)
- [`std::shared_ptr<Kv> kv_`](#kv_)

#### Functions
- (public:)
- [`static CharsIdentify* instance()`](#instance)
- [`int classify(cv::Mat f, float& maxVal, bool isChinses = false, bool isAlphabet = false)`](#classify1)
- [`void classify(cv::Mat featureRows, std::vector<int>& out_maxIndexs,std::vector<float>& out_maxVals, std::vector<bool> isChineseVec)`](#classify2)
- [`void classify(std::vector<CCharacter>& charVec)`](#classify3)
- [`void classifyChinese(std::vector<CCharacter>& charVec)`](#classifyChinese)
- [`void classifyChineseGray(std::vector<CCharacter>& charVec)`](#classifyChineseGray)
- [`std::pair<std::string, std::string> identify(cv::Mat input, bool isChinese = false, bool isAlphabet = false)`](#identify1)
- [`int identify(std::vector<cv::Mat> inputs, std::vector<std::pair<std::string, std::string>>& outputs,std::vector<bool> isChineseVec)`](#identify2)
- [`std::pair<std::string, std::string> identifyChinese(cv::Mat input, float& result, bool& isChinese)`](#identifyChinese)
- [`std::pair<std::string, std::string> identifyChineseGray(cv::Mat input, float& result, bool& isChinese)`](#identifyChineseGray)
- [`bool isCharacter(cv::Mat input, std::string& label, float& maxVal, bool isChinese = false)`](#isCharacter)
- [`void LoadModel(std::string path)`](#LoadModel)
- [`void LoadChineseModel(std::string path)`](#LoadChineseModel)
- [`void LoadGrayChANN(std::string path)`](#LoadGrayChANN)
- [`void LoadChineseMapping(std::string path)`](#LoadChineseMapping)
- (private:)
- [`CharsIdentify()`](#CharsIdentify)

***

***
85 changes: 85 additions & 0 deletions easyPR-doc/core/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
### feature

#### Functions
- [`cv::Mat getHistogram(cv::Mat in)`](#getHistogram)
- [`typedef void (*svmCallback)(const cv::Mat& image, cv::Mat& features)`](#svmCallback)
- [`typedef void (*annCallback)(const cv::Mat& image, cv::Mat& features)`](#annCallback)
- [`void getGrayPlusProject(const cv::Mat& grayChar, cv::Mat& features)`](#getGrayPlusProject)
- [`void getHistogramFeatures(const cv::Mat& image, cv::Mat& features)`](#getHistogramFeatures)
- [`void getSIFTFeatures(const cv::Mat& image, cv::Mat& features)`](#getSIFTFeatures)
- [`void getHOGFeatures(const cv::Mat& image, cv::Mat& features)`](#getHOGFeatures)
- [`void getHSVHistFeatures(const cv::Mat& image, cv::Mat& features)`](#getHSVHistFeatures)
- [`void getLBPFeatures(const cv::Mat& image, cv::Mat& features)`](#getLBPFeatures)
- [`void getColorFeatures(const cv::Mat& src, cv::Mat& features)`](#getColorFeatures)
- [`void getHistomPlusColoFeatures(const cv::Mat& image, cv::Mat& features)`](#getHistomPlusColoFeatures)
- [`cv::Mat charFeatures(cv::Mat in, int sizeData)`](#charFeatures)
- [`cv::Mat charFeatures2(cv::Mat in, int sizeData)`](#charFeatures2)
- [`void getLBPplusHistFeatures(const cv::Mat& image, cv::Mat& features)`](#getLBPplusHistFeatures)
- [`void getGrayCharFeatures(const cv::Mat& grayChar, cv::Mat& features)`](#getGrayCharFeatures)
- [`void getGrayPlusLBP(const Mat& grayChar, Mat& features)`](#getGrayPlusLBP)

***
<a id="getHistogram"></a>
#### cv::Mat getHistogram(cv::Mat in)
- 获得车牌的特征数

<a id="svmCallback"></a>
#### typedef void (*svmCallback)(const cv::Mat& image, cv::Mat& features)
- EasyPR的getFeatures回调函数
- 用于从车牌的image生成svm的训练特征features

<a id="annCallback"></a>
#### typedef void (*annCallback)(const cv::Mat& image, cv::Mat& features)
- EasyPR的getFeatures回调函数
- convert from images to features used by gray char ann

<a id="getGrayPlusProject"></a>
#### void getGrayPlusProject(const cv::Mat& grayChar, cv::Mat& features)
- gray and project feature

<a id="getHistogramFeatures"></a>
#### void getHistogramFeatures(const cv::Mat& image, cv::Mat& features)
- EasyPR的getFeatures回调函数
- 本函数是获取垂直和水平的直方图图值

<a id="getSIFTFeatures"></a>
#### void getSIFTFeatures(const cv::Mat& image, cv::Mat& features)
- 本函数是获取SIFT特征子

<a id="getHOGFeatures"></a>
#### void getHOGFeatures(const cv::Mat& image, cv::Mat& features)
- 本函数是获取HOG特征子

<a id="getHSVHistFeatures"></a>
#### void getHSVHistFeatures(const cv::Mat& image, cv::Mat& features)
- 本函数是获取HSV空间量化的直方图特征子

<a id="getLBPFeatures"></a>
#### void getLBPFeatures(const cv::Mat& image, cv::Mat& features)
- LBP feature

<a id="getColorFeatures"></a>
#### void getColorFeatures(const cv::Mat& src, cv::Mat& features)
- color feature

<a id="getHistomPlusColoFeatures"></a>
#### void getHistomPlusColoFeatures(const cv::Mat& image, cv::Mat& features)
- color feature and histom

<a id="charFeatures"></a>
#### cv::Mat charFeatures(cv::Mat in, int sizeData)
- get character feature

<a id="charFeatures2"></a>
#### cv::Mat charFeatures2(cv::Mat in, int sizeData)
- get character feature

<a id="getLBPplusHistFeatures"></a>
#### void getLBPplusHistFeatures(const cv::Mat& image, cv::Mat& features)
- LBP feature + Histom feature

<a id="getGrayCharFeatures"></a>
#### void getGrayCharFeatures(const cv::Mat& grayChar, cv::Mat& features)

<a id="getGrayPlusLBP"></a>
#### void getGrayPlusLBP(const Mat& grayChar, Mat& features)
16 changes: 16 additions & 0 deletions easyPR-doc/core/plate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Class

#### Properties
- (private:)
- [`Mat m_plateMat`](#m_plateMat)
- [`RotatedRect m_platePos`](#m_platePos)
- [`double m_score`](#m_score)

#### Functions

***
<a id="m_score"></a>
####double m_score
- 保存了`SVM`后的分数,越大证明越可能是车牌

***
29 changes: 29 additions & 0 deletions easyPR-doc/core/plate_detect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### Class CPlateDetect

#### Properties
- (priavte:)
- [`int m_maxPlates`](#m_maxPlates)
- [`CPlateLocate* m_plateLocate`](#m_plateLocate)
- [`int m_type`](#m_type)
- [`static std::string m_pathSvm`](#m_pathSvm)
- [`bool m_showDetect`](#m_showDetect)

#### Functions
- (public:)
- [`int plateDetect(Mat src, s td::vector<CPlate> &resultVec, int type,bool showDetectArea, int img_index = 0)`](#plateDetect1)
- [`int plateDetect(Mat src, std::vector<CPlate> &resultVec, int img_index = 0)`](#plateDetect2)
- [`void LoadSVM(std::string s)`](#LoadSVM)

***
<a id="m_maxPlates"></a>
#### int m_maxPlates(`get|set`)

<a id="m_plateLocate"></a>
#### CPlateLocate* m_plateLocate
- 用于车牌定位的对象,完成了所有车牌定位的操作

<a id="m_type"></a>
#### m_type(`set`)
-

***
71 changes: 71 additions & 0 deletions easyPR-doc/core/plate_judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
### Class PlateJudge

#### Properties
- (private:)
- [`static PlateJudge* instance_`](#instance_)
- [`svmCallback extractFeature`](#extractFeature)
- [`cv::Ptr<ml::SVM> svm_`](#svm_)

#### Functions
- (public:)
- [`static PlateJudge* instance()`](#instance)
- [`void LoadModel(std::string path)`](#LoadModel)
- [`int plateJudgeUsingNMS(const std::vector<CPlate>&, std::vector<CPlate>&, int maxPlates = 5)`](#plateJudgeUsingNMS)
- [`int plateSetScore(CPlate& plate)`](#plateSetScore)
- [`int plateJudge(const Mat& plateMat)`](#plateJudge1)
- [`int plateJudge(const std::vector<Mat> &inVec,std::vector<Mat> &resultVec)`](#plateJudge2)
- [`int plateJudge(const std::vector<CPlate> &inVec,std::vector<CPlate> &resultVec)`](#plateJudge3)
- [`void NMS(std::vector<CPlate> &inVec, std::vector<CPlate> &resultVec, double overlap)`](#NMS)
- [`int PlateJudge::plateJudgeUsingNMS(const std::vector<CPlate> &inVec, std::vector<CPlate> &resultVec, int maxPlates)`](#plateJudgeUsingNMS)
- (private:)
- [`PlateJudge()`](#PlateJudge)

***
<a id="instance_"></a>
#### static PlateJudge* instance_
- 静态变量`instance_`,用于单例模式

***
<a id="instance"></a>
#### static PlateJudge* instance()
- 单例模式初始化方法,当`instance_`为`nullptr`时,初始化一个`PlateJudge`
- 返回`instance_`

<a id="PlateJudge"></a>
#### PlateJudge()
- 加载`svm`的模型,在`config.h`中配置模型路径
- 可选择是否使用`LBP`模型,因为暂时没有这个模型,所以使用的是`Hist`

<a id="LoadModel"></a>
#### void LoadModel(std::string path)
- 输入参数为路径`path`
- 如果`path`与默认`kDefaultSvmPath`路径不同,则加载`path`下的模型,如果相同,那么加载的模型和`kDefaultSvmPath`路径下的相同

<a id="plateSetScore"></a>
#### int plateSetScore(CPlate& plate)
- 这个函数通过`SVM`为输入的`CPlate`计算分数,小于0且越小为车牌的可能性越大
- 方法判定`score`大于`0.5`的`CPlate`为不是车牌
- 返回值为`0`表示是车牌,返回值为`-1`表示不是车牌

<a id="plateJudge1"></a>
#### int plateJudge(const Mat& plateMat)
- 调用`plateSetScore`得到`0/-1`并返回,`0`代表是车牌,`1`表示不是车牌

<a id="plateJudge2"></a>
#### int plateJudge(const std::vector<Mat> &inVec,std::vector<Mat> &resultVec)
- 输入为`Mat`的集合`inVec`,代表了需要判断的`Mat`的集合
- 输出为`resultVec`,代表了所有可能是车牌的集合
- `return 0`

<a id="plateJudge3"></a>
#### int plateJudge(const std::vector<CPlate> &inVec,std::vector<CPlate> &resultVec)
- 输入为`CPlate`的集合`inVec`,代表了需要判断的`CPlate`的集合
- 输出为`resultVec`,代表了所有可能是车牌的集合
- 和`int plateJudge(const std::vector<Mat> &inVec,std::vector<Mat> &resultVec)`不同的是,在这个方法中会进行一次矩形的缩小再判断
- `return 0`

<a id="NMS"></a>
#### void NMS(std::vector<CPlate> &inVec, std::vector<CPlate> &resultVec, double overlap)

<a id="plateJudgeUsingNMS"></a>
#### int PlateJudge::plateJudgeUsingNMS(const std::vector<CPlate> &inVec, std::vector<CPlate> &resultVec, int maxPlates)
Loading