* gbk and utf-8 compatiable

* change back to svm_hist model
* refine the code
* add lots of comments
* delete some not usage cpp
v1.6alpha
liuruoze 8 years ago
parent c4808131ea
commit 029e014a51

1
.gitignore vendored

@ -14,6 +14,7 @@ experi
resources/image/native_test/*.jpg
resources/image/native_test/cars
resources/image/native_test/*.py
resources/image/phone_test
*.vsp
*.psess

@ -12,6 +12,13 @@ endif ()
# OpenVC3 required
find_package(OpenCV 3.1.0 REQUIRED)
# optional OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# where to find header files
include_directories(.)
include_directories(include)

@ -1,7 +1,7 @@
make_a_choice 请选择一项操作
input_error 输入错误,请重新输入
original_plate 图片
original_image 图片
empty_plate 无车牌
diff 差距
char 字符

@ -4,9 +4,6 @@
#include "easypr/core/plate_recognize.h"
#include "easypr/train/svm_train.h"
#include "easypr/train/ann_train.h"
#include "easypr/preprocess/mc_data.h"
#include "easypr/preprocess/gdts.h"
#include "easypr/preprocess/deface.h"
#include "easypr/util/util.h"
#include "easypr/util/program_options.h"
#include "easypr/api.hpp"

@ -15,13 +15,12 @@ namespace api {
static bool plate_judge(const char* image, const char* model) {
cv::Mat src = cv::imread(image);
assert(!src.empty());
int result;
PlateJudge::instance()->plateJudge(src, result);
result = PlateJudge::instance()->plateJudge(src);
return result == 1;
return result == 0;
}
static void plate_locate(const char* image, const bool life_mode = true) {

@ -9,6 +9,8 @@ namespace easypr {
enum CharSearchDirection { LEFT, RIGHT };
enum SceneMode { UNCONSTRAINED, CAMERPOHNE, PARKING, HIGHWAY };
enum
{
PR_DETECT_SOBEL = 0x01, /**Sobel detect type, using twice Sobel */
@ -16,8 +18,10 @@ namespace easypr {
PR_DETECT_CMSER = 0x04, /**Character detect type, using mser */
};
static const char* kDefaultSvmPath = "resources/model/svm.xml";
static const char* kLBPSvmPath = "resources/model/svm_lbp_final.xml";
static const char* kDefaultSvmPath = "resources/model/svm_hist.xml";
static const char* kLBPSvmPath = "resources/model/svm_lbp.xml";
static const char* kHistSvmPath = "resources/model/svm_hist.xml";
static const char* kDefaultAnnPath = "resources/model/ann.xml";
static const char* kChineseAnnPath = "resources/model/ann_chinese.xml";
@ -29,8 +33,8 @@ typedef enum {
static const int kPlateResizeWidth = 136;
static const int kPlateResizeHeight = 36;
static const int kShowWindowWidth = 800;
static const int kShowWindowHeight = 600;
static const int kShowWindowWidth = 1000;
static const int kShowWindowHeight = 800;
static const float kSvmPercentage = 0.7f;

@ -108,6 +108,11 @@ Mat rotateImg(Mat source, float angle);
// uniform resize all the image to same size for the next process
Mat uniformResize(const Mat &result);
// show detect results
void showDectectResults(const Mat& img, const std::vector<CPlate> &plateVec, size_t num);
// show the results
Mat showResult(const Mat &result, int img_index = 0);
} /*! \namespace easypr*/
#endif // EASYPR_CORE_COREFUNC_H_

@ -120,15 +120,8 @@ namespace easypr {
inline void addReutCharacter(CCharacter param) { m_reutCharVec.push_back(param); }
inline std::vector<CCharacter> getCopyOfReutCharacters() { return m_reutCharVec; }
bool operator < (const CPlate& plate) const
{
return (m_score < plate.m_score);
}
bool operator < (const CPlate& plate)
{
return (m_score < plate.m_score);
}
bool operator < (const CPlate& plate) const { return (m_score < plate.m_score); }
bool operator < (const CPlate& plate) { return (m_score < plate.m_score); }
private:
//! plate mat

@ -37,8 +37,6 @@ class CPlateDetect {
*/
int plateDetect(Mat src, std::vector<CPlate> &resultVec, int img_index = 0);
Mat showResult(const Mat &result, int img_index = 0);
void LoadSVM(std::string s);
inline void setPDLifemode(bool param) { m_plateLocate->setLifemode(param); }
@ -109,6 +107,8 @@ class CPlateDetect {
int m_maxPlates;
SceneMode m_mode;
CPlateLocate* m_plateLocate;
int m_type;

@ -9,18 +9,19 @@ namespace easypr {
class PlateJudge {
public:
static PlateJudge* instance();
void LoadModel(std::string path);
int plateJudge(const std::vector<CPlate> &, std::vector<CPlate> &);
int plateJudgeUsingNMS(const std::vector<CPlate> &, std::vector<CPlate> &, int maxPlates = 5);
int plateJudge(const std::vector<Mat> &, std::vector<Mat> &);
int plateJudge(const Mat &inMat, int &result);
int plateJudgeUsingNMS(const std::vector<CPlate>&, std::vector<CPlate>&, int maxPlates = 5);
int plateSetScore(CPlate& plate);
int plateJudge(const Mat& plateMat);
int plateJudge(const std::vector<Mat> &inVec,
std::vector<Mat> &resultVec);
int plateJudge(const std::vector<CPlate> &inVec,
std::vector<CPlate> &resultVec);
private:
// singleton
PlateJudge();
static PlateJudge* instance_;

@ -24,15 +24,14 @@ namespace easypr {
public:
CPlateRecognize();
int plateRecognize(Mat src, std::vector<CPlate> &plateVec, int img_index = 0);
int plateRecognize(Mat src, std::vector<std::string> &licenseVec);
int plateRecognize(const Mat& src, std::vector<CPlate> &plateVec, int img_index = 0);
int plateRecognize(const Mat& src, std::vector<std::string> &licenseVec);
inline void setLifemode(bool param) { CPlateDetect::setPDLifemode(param); }
inline void setDetectType(int param) { CPlateDetect::setDetectType(param); }
inline void setResultShow(bool param) { m_showResult = param; }
inline bool getResultShow() const { return m_showResult; }
inline void setDetectShow(bool param) { CPlateDetect::setDetectShow(param); }
inline void setDebug(bool param) { setResultShow(param); }

@ -1,26 +0,0 @@
// 人脸马赛克
//
// Created by zhou shiwei on 15/1/20.
// Copyright (c) 2015年 zhou shiwei. All rights reserved.
// 反人脸识别文件
// 在发布数据到general_test数据集里请先用这里的方法对图像进行处理
// EasyPR开源项目非常注重保护图片中驾驶人的隐私
#ifndef EASYPR_CORE_DEFACE_H_
#define EASYPR_CORE_DEFACE_H_
#include <opencv2/opencv.hpp>
namespace easypr {
namespace preprocess {
int deface();
cv::Mat detectAndMaskFace(cv::Mat& img, cv::CascadeClassifier& cascade,
double scale);
}
}
#endif // EASYPR_CORE_DEFACE_H_

@ -1,23 +0,0 @@
// 生成GDTS的文件
// 在捐赠数据到GDTS数据集里请先用这里的方法对图像进行预处理
// EasyPR开源项目非常注重保护原始图片的版权
// 所有的捐赠数据通过GDSL协议进行约定保证使用人仅用于非商业性目的
#ifndef EASYPR_CORE_GDTS_H_
#define EASYPR_CORE_GDTS_H_
#include <opencv2/opencv.hpp>
namespace easypr {
namespace preprocess {
// EasyPR的图像预处理函数进行模糊化与裁剪化处理
cv::Mat imageProcess(cv::Mat src);
int generate_gdts();
}
}
#endif // EASYPR_CORE_GDTS_H_

@ -1,34 +0,0 @@
// learn data_prepare :
// 生成learn data的cpplearn data指的是train dataverify data test
// data的总和这个名字是我起的。
// learn
// data应该是贴好标签的数据因此即便通过EasyPR自动化处理以后也要人为的修正一下.
// 你应该按照如下的步骤和顺序组织learn data
// 1.用EasyPR对not label
// data进行处理通过EasyPR辅助来对车牌图片进行标签放到不同文件夹下
// 2.标签分两种,一种是有车牌的,一种是无车牌的;
// 2.EasyPR生成标签以后你还得需要肉眼确认下将被不正确标签的数据转移到它们该去的文件夹下
// 3.通过上面的步骤正确的车牌图片和非车牌图片已经被分别放到两个文件下假设是hasplate和noplate
// 4.将这两个文件夹放到EasyPR目录train/data/plate_detect_svm/learn下面
// 5.运行EasyPR选择“训练”目录下的“车牌检测not
// divide这个程序会自动把learn data分块训练测试
#ifndef EASYPR_CORE_MCDATA_H_
#define EASYPR_CORE_MCDATA_H_
#include <string>
namespace easypr {
namespace preprocess {
void create_learn_data(const char* raw_data_folder, const char* out_data_folder,
const int how_many = 5000);
void tag_data(const char* source_folder, const char* has_plate_folder,
const char* no_plate_folder, const char* svm_model);
}
}
#endif // EASYPR_CORE_MCDATA_H_

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save