From c4cea7de7741394b04ce85b12f0f6ffb3371f06f Mon Sep 17 00:00:00 2001 From: Fenix Date: Sun, 28 Sep 2014 23:48:49 +0800 Subject: [PATCH] add LoadModel --- .gitignore.orig | 215 ++++++++++++++++++++++++++++++++++ src/cpp/chars_identify.cpp | 6 + src/cpp/chars_recognise.cpp | 5 + src/cpp/plate_detect.cpp | 5 + src/cpp/plate_judge.cpp | 6 + src/cpp/plate_recognize.cpp | 24 ++++ src/include/chars_identify.h | 3 + src/include/chars_recognise.h | 3 + src/include/plate_detect.h | 3 + src/include/plate_judge.h | 3 + src/include/plate_recognize.h | 12 ++ 11 files changed, 285 insertions(+) create mode 100644 .gitignore.orig diff --git a/.gitignore.orig b/.gitignore.orig new file mode 100644 index 0000000..1fa47ab --- /dev/null +++ b/.gitignore.orig @@ -0,0 +1,215 @@ +<<<<<<< HEAD + +#ignore thumbnails created by windows +Thumbs.db +#Ignore files build by Visual Studio +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +======= +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# If using the old MSBuild-Integrated Package Restore, uncomment this: +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ +>>>>>>> 9d203677f87c74ec5ed612a8fe7bf0f940e22461 diff --git a/src/cpp/chars_identify.cpp b/src/cpp/chars_identify.cpp index 7342e96..1ab0f75 100644 --- a/src/cpp/chars_identify.cpp +++ b/src/cpp/chars_identify.cpp @@ -66,6 +66,12 @@ void CCharsIdentify::LoadModel() ann.load(m_path.c_str(), "ann"); } +void CCharsIdentify::LoadModel(string s) +{ + ann.clear(); + ann.load(s.c_str(), "ann"); +} + //create the accumulation histograms,img is a binary image, t is 水平或垂直 Mat CCharsIdentify::ProjectedHistogram(Mat img, int t) { diff --git a/src/cpp/chars_recognise.cpp b/src/cpp/chars_recognise.cpp index 226d028..31cce7c 100644 --- a/src/cpp/chars_recognise.cpp +++ b/src/cpp/chars_recognise.cpp @@ -12,6 +12,11 @@ CCharsRecognise::CCharsRecognise() m_charsIdentify = new CCharsIdentify(); } +void CCharsRecognise::LoadModel(string s) +{ + m_charsIdentify->LoadModel(s.c_str()); +} + int CCharsRecognise::charsRecognise(Mat plate, string& plateLicense) { //车牌字符方块集合 diff --git a/src/cpp/plate_detect.cpp b/src/cpp/plate_detect.cpp index 2c0795a..1de4ef8 100644 --- a/src/cpp/plate_detect.cpp +++ b/src/cpp/plate_detect.cpp @@ -12,6 +12,11 @@ CPlateDetect::CPlateDetect() m_plateJudge = new CPlateJudge(); } +void CPlateDetect::LoadModel(string s) +{ + m_plateJudge->LoadModel(s.c_str()); +} + int CPlateDetect::plateDetect(Mat src, vector& resultVec) { //可能是车牌的图块集合 diff --git a/src/cpp/plate_judge.cpp b/src/cpp/plate_judge.cpp index 2c117f9..2d7602e 100644 --- a/src/cpp/plate_judge.cpp +++ b/src/cpp/plate_judge.cpp @@ -18,6 +18,12 @@ void CPlateJudge::LoadModel() svm.load(m_path.c_str(), "svm"); } +void CPlateJudge::LoadModel(string s) +{ + svm.clear(); + svm.load(s.c_str(), "svm"); +} + //! 直方图均衡 Mat CPlateJudge::histeq(Mat in) { diff --git a/src/cpp/plate_recognize.cpp b/src/cpp/plate_recognize.cpp index 8d9e472..a85c245 100644 --- a/src/cpp/plate_recognize.cpp +++ b/src/cpp/plate_recognize.cpp @@ -12,6 +12,30 @@ CPlateRecognize::CPlateRecognize() m_charsRecognise = new CCharsRecognise(); } +//! 装载SVM模型 +void CPlateRecognize::LoadSVM(string strSVM) +{ + m_plateDetect->LoadModel(strSVM.c_str()); +} + +//! 装载ANN模型 +void CPlateRecognize::LoadANN(string strANN) +{ + m_charsRecognise->LoadModel(strANN.c_str()); +} + +int CPlateRecognize::plateDetect(Mat src, vector& resultVec) +{ + int result = m_plateDetect->plateDetect(src, resultVec); + return result; +} + +int CPlateRecognize::charsRecognise(Mat plate, string& plateLicense) +{ + int result = m_charsRecognise->charsRecognise(plate, plateLicense); + return result; +} + int CPlateRecognize::plateRecognize(Mat src, vector& plateVec) { //车牌方块集合 diff --git a/src/include/chars_identify.h b/src/include/chars_identify.h index 9932d5b..8536813 100644 --- a/src/include/chars_identify.h +++ b/src/include/chars_identify.h @@ -39,6 +39,9 @@ public: //! 装载ANN模型 void LoadModel(); + //! 装载ANN模型 + void LoadModel(string s); + //! 设置与读取模型路径 inline void setModelPath(string path){ m_path = path; } inline string getModelPath() const{ return m_path; } diff --git a/src/include/chars_recognise.h b/src/include/chars_recognise.h index 6ef39ab..417c370 100644 --- a/src/include/chars_recognise.h +++ b/src/include/chars_recognise.h @@ -29,6 +29,9 @@ public: //! 字符分割与识别 int charsRecognise(Mat, String&); + //! 装载ANN模型 + void LoadModel(string s); + private: //!字符分割 CCharsSegment* m_charsSegment; diff --git a/src/include/plate_detect.h b/src/include/plate_detect.h index 4ecfd11..c0569ab 100644 --- a/src/include/plate_detect.h +++ b/src/include/plate_detect.h @@ -29,6 +29,9 @@ public: //! 车牌定位与判断 int plateDetect(Mat, vector&); + //! 装载SVM模型 + void LoadModel(string s); + private: //!车牌定位 CPlateLocate* m_plateLocate; diff --git a/src/include/plate_judge.h b/src/include/plate_judge.h index eb84711..8d7e95f 100644 --- a/src/include/plate_judge.h +++ b/src/include/plate_judge.h @@ -33,6 +33,9 @@ public: //! 装载SVM模型 void LoadModel(); + //! 装载SVM模型 + void LoadModel(string s); + //! 设置与读取模型路径 inline void setModelPath(string path){ m_path = path; } inline string getModelPath() const{ return m_path; } diff --git a/src/include/plate_recognize.h b/src/include/plate_recognize.h index e53dedd..a1d05f1 100644 --- a/src/include/plate_recognize.h +++ b/src/include/plate_recognize.h @@ -29,6 +29,18 @@ public: //! 车牌检测与字符识别 int plateRecognize(Mat, vector& ); + //! 车牌定位与判断 + int plateDetect(Mat, vector&); + + //! 字符分割与识别 + int charsRecognise(Mat, String&); + + //! 装载SVM + void LoadSVM(string s); + + //! 装载ANN模型 + void LoadANN(string s); + private: //!车牌检测 CPlateDetect* m_plateDetect;