資源簡介
在開源的車牌識別系統EasyPR中,用SVM(支持向量機)模型甄選出候選車牌中真正的車牌。目前EasyPR1.4的SVM模型輸入的是LBP特征,本代碼將EasyPR的svm_train.cpp獨立出來,包含SIFT和SURF結合BOW作為SVM輸入,以及LBP和HOG特征作為SVM的輸入。
代碼片段和文件信息
#include?“opencv2/opencv_modules.hpp“
#include?“opencv2/imgcodecs.hpp“
#include?“opencv2/highgui.hpp“
#include?“opencv2/imgproc.hpp“
#include?“opencv2/features2d.hpp“
#include?“opencv2/xfeatures2d.hpp“
#include?“opencv2/ml.hpp“
#include?“util.h“
#include?“BagOfWords.h“
#include?
#include?
#include?
#include?
#if?defined?WIN32?||?defined?_WIN32
#define?WIN32_LEAN_AND_MEAN
#include?
#undef?min
#undef?max
#include?“sys/types.h“
#endif
#include?
#define?DEBUG_DESC_PROGRESS
using?namespace?cv;
using?namespace?cv::xfeatures2d;
using?namespace?cv::ml;
using?namespace?std;
extern?string?resPath;
const?string?paramsFile?=?“params.xml“;
const?string?vocabularyFile?=?“vocabulary.xml.gz“;
const?string?bowImageDescriptorsDir?=?“/bowImageDescriptors“;
const?string?svmsDir?=?“/svms“;
//const?string?plotsDir?=?“/plots“;
class?ObdImage
{
public:
ObdImage(string?p_id?string?p_path)?:?id(p_id)?path(p_path)?{}
string?id;
string?path;
};
//
//?This?part?of?the?code?was?a?little?refactor
//
struct?DDMParams
{
DDMParams()?:?detectorType(“SURF“)?descriptorType(“SURF“)?matcherType(“BruteForce“)?{}
DDMParams(const?string?_detectorType?const?string?_descriptorType?const?string&?_matcherType)?:
detectorType(_detectorType)?descriptorType(_descriptorType)?matcherType(_matcherType){}
void?read(const?FileNode&?fn)
{
fn[“detectorType“]?>>?detectorType;
fn[“descriptorType“]?>>?descriptorType;
fn[“matcherType“]?>>?matcherType;
}
void?write(FileStorage&?fs)?const
{
fs?<“detectorType“?< fs?<“descriptorType“?<riptorType;
fs?<“matcherType“?< }
void?print()?const
{
cout?<“detectorType:?“?< cout?<“descriptorType:?“?<riptorType?< cout?<“matcherType:?“?< }
string?detectorType;
string?descriptorType;
string?matcherType;
};
struct?VocabTrainParams
{
VocabTrainParams()?:?vocabSize(1000)?memoryUse(200)?descProportion(0.3f)?{}
VocabTrainParams(const?string?_trainObjClass?size_t?_vocabSize?size_t?_memoryUse?float?_descProportion)?:
vocabSize((int)_vocabSize)?memoryUse((int)_memoryUse)?descProportion(_descProportion)?{}
void?read(const?FileNode&?fn)
{
fn[“vocabSize“]?>>?vocabSize;
fn[“memoryUse“]?>>?memoryUse;
fn[“descProportion“]?>>?descProportion;
}
void?write(FileStorage&?fs)?const
{
fs?<“vocabSize“?< fs?<“memoryUse“?< fs?<“descProportion“?< }
void?print()?const
{
cout?<“vocabSize:?“?< cout?<“memoryUse:?“?< cout?<“descProportion:?“?< }
//?It?shouldn‘t?matter?which?object?class?is?specified?here?-?visual?vocab?will?still?be?the?same.
int?vocabSize;?//number?of?visual?words?in?vocabulary?to?train
int?memoryUse;?//?
評論
共有 條評論