Command Line Shell enhancement. Support compiling to static library(libeasypr). Provide frequently used apis(api.hpp) for quick access to functions what users want. SVM train without changing source files. Fix OpenCV roi out of range bug. The language layer fix and optimization, type matching, loop simplified using C++11.1.3
parent
4a379d265c
commit
c888179d81
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
||||
#ifndef EASYPR_EASYPR_H
|
||||
#define EASYPR_EASYPR_H
|
||||
|
||||
#include "easypr/plate_recognize.h"
|
||||
#include "easypr/svm_train.h"
|
||||
#include "easypr/preprocess/mc_data.h"
|
||||
#include "easypr/preprocess/gdts.h"
|
||||
#include "easypr/preprocess/deface.h"
|
||||
#include "easypr/util.h"
|
||||
#include "easypr/api.hpp"
|
||||
|
||||
#endif //EASYPR_EASYPR_H
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file provides some of the most commonly used application interfaces.
|
||||
*/
|
||||
#ifndef EASYPR_API_HPP
|
||||
#define EASYPR_API_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
namespace easypr {
|
||||
|
||||
namespace api {
|
||||
|
||||
const char* kDefaultSVMModel = "resources/model/svm.xml";
|
||||
const char* kDefaultANNModel = "resourecs/model/ann.xml";
|
||||
|
||||
static bool plate_judge(const char* image,const char *model) {
|
||||
Mat src = imread(image);
|
||||
|
||||
assert(!src.empty());
|
||||
|
||||
CPlateJudge judger;
|
||||
judger.LoadModel(model);
|
||||
|
||||
int result;
|
||||
judger.plateJudge(src, result);
|
||||
|
||||
return result == 1;
|
||||
}
|
||||
|
||||
static void plate_locate(const char* image, const bool life_mode = true) {
|
||||
Mat src = imread(image);
|
||||
|
||||
assert(!src.empty());
|
||||
|
||||
CPlateLocate plate;
|
||||
plate.setDebug(1);
|
||||
plate.setLifemode(life_mode);
|
||||
|
||||
std::vector<cv::Mat> results;
|
||||
|
||||
plate.plateLocate(src, results);
|
||||
}
|
||||
|
||||
static std::vector<std::string> plate_recognize(const char* image,
|
||||
const char* model_svm,
|
||||
const char* model_ann,
|
||||
const bool life_mode = true) {
|
||||
cv::Mat img = cv::imread(image);
|
||||
|
||||
assert(!img.empty());
|
||||
|
||||
CPlateRecognize pr;
|
||||
pr.LoadSVM(model_svm);
|
||||
pr.LoadANN(model_ann);
|
||||
pr.setLifemode(life_mode);
|
||||
pr.setDebug(false);
|
||||
|
||||
std::vector<std::string> results;
|
||||
pr.plateRecognize(img, results);
|
||||
|
||||
return std::move(results);
|
||||
}
|
||||
|
||||
static Color get_plate_color(const char* image) {
|
||||
cv::Mat img = cv::imread(image);
|
||||
|
||||
assert(!img.empty());
|
||||
|
||||
return getPlateType(img, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //EASYPR_API_HPP
|
@ -0,0 +1,47 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: plate_recognize Header
|
||||
// Version: 1.0
|
||||
// Date: 2014-09-28
|
||||
// Author: liuruoze
|
||||
// Copyright: liuruoze
|
||||
// Reference: Mastering OpenCV with Practical Computer Vision Projects
|
||||
// Reference: CSDN Bloger taotao1233
|
||||
// Desciption:
|
||||
// Defines CPlateRecognize
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __PLATE_RECOGNIZE_H__
|
||||
#define __PLATE_RECOGNIZE_H__
|
||||
|
||||
#include "prep.h"
|
||||
|
||||
#include "plate_detect.h"
|
||||
#include "chars_recognise.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
class CPlateRecognize : public CPlateDetect, public CCharsRecognise {
|
||||
public:
|
||||
CPlateRecognize();
|
||||
|
||||
//! 车牌检测与字符识别
|
||||
int plateRecognize(Mat src, vector<string>& licenseVec);
|
||||
|
||||
//! 生活模式与工业模式切换
|
||||
inline void setLifemode(bool param) {
|
||||
CPlateDetect::setPDLifemode(param);
|
||||
}
|
||||
|
||||
//! 是否开启调试模式
|
||||
inline void setDebug(int param) {
|
||||
CPlateDetect::setPDDebug(param);
|
||||
CCharsRecognise::setCRDebug(param);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} /* \namespace easypr */
|
||||
|
||||
#endif /* endif __PLATE_RECOGNITION_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by Micooz on 15/5/21.
|
||||
//
|
||||
|
||||
#ifndef EASYPR_SVM_TRAIN_H
|
||||
#define EASYPR_SVM_TRAIN_H
|
||||
|
||||
#include <vector>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "easypr/feature.h"
|
||||
|
||||
namespace easypr {
|
||||
|
||||
class Svm {
|
||||
public:
|
||||
|
||||
int train(bool dividePrepared = true, bool trainPrepared = true,
|
||||
svmCallback getFeatures = getHistogramFeatures);
|
||||
|
||||
void accuracy(cv::Mat& testingclasses_preditc, cv::Mat& testingclasses_real);
|
||||
|
||||
void getNoPlateTest(std::vector<cv::Mat>& testingImages,
|
||||
std::vector<int>& testingLabels);
|
||||
|
||||
void getHasPlateTest(std::vector<cv::Mat>& testingImages,
|
||||
std::vector<int>& testingLabels);
|
||||
|
||||
void getNoPlateTrain(cv::Mat& trainingImages,
|
||||
std::vector<int>& trainingLabels,
|
||||
svmCallback getFeatures = getHisteqFeatures);
|
||||
|
||||
void getHasPlateTrain(cv::Mat& trainingImages,
|
||||
std::vector<int>& trainingLabels,
|
||||
svmCallback getFeatures = getHisteqFeatures);
|
||||
|
||||
void learn2NoPlate(float bound = 0.7);
|
||||
|
||||
void learn2HasPlate(float bound = 0.7);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //EASYPR_SVM_TRAIN_H
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue