Compare commits
4 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
4c49f89ed1 | 10 years ago |
|
|
200607bae6 | 10 years ago |
|
|
eb83fa2ede | 10 years ago |
|
|
61b0710882 | 10 years ago |
@ -1,39 +0,0 @@
|
||||
**I'm submitting a ...** (check one with "x")
|
||||
|
||||
```
|
||||
[ ] bug report
|
||||
[ ] help wanted
|
||||
[ ] feature request
|
||||
```
|
||||
|
||||
**Current behavior**
|
||||
|
||||
|
||||
|
||||
**Expected/desired behavior**
|
||||
|
||||
|
||||
|
||||
**Reproduction of the problem**
|
||||
|
||||
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce.
|
||||
|
||||
|
||||
|
||||
**What is the expected behavior?**
|
||||
|
||||
|
||||
|
||||
**What is the motivation / use case for changing the behavior?**
|
||||
|
||||
|
||||
|
||||
**Please tell us about your environment:**
|
||||
|
||||
* **System:** CentOS
|
||||
|
||||
* **Compiler version/IDE:** gcc4.8
|
||||
|
||||
* **CMake version:** 3.5.1
|
||||
|
||||
* **OpenCV version:** [2.4.9 | 2.4.10 | 2.4.11 | 2.4.12 | 2.4.13 | 3.0 ALPHA | 3.0 BETA | 3.0 RC1 | 3.0 | 3.1 ]
|
||||
@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件\easypr">
|
||||
<UniqueIdentifier>{9bb276ae-c7dc-4518-9674-bad84e57b9ac}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="头文件\easypr\preprocess">
|
||||
<UniqueIdentifier>{6d263c48-a60a-4d68-8c2d-be376356168a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\core">
|
||||
<UniqueIdentifier>{bab97015-644d-43a0-a50a-a10567a88dbe}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\preprocess">
|
||||
<UniqueIdentifier>{9a417cf1-7356-4acc-8b03-2b23009aa1ff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\train">
|
||||
<UniqueIdentifier>{46477ca6-b57a-48af-b8a7-49b05c42319f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\util">
|
||||
<UniqueIdentifier>{53a5d227-5ea7-45e4-9533-ed69bff250fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\easypr.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\api.hpp">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\chars_identify.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\chars_recognise.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\chars_segment.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\core_func.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\feature.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\plate.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\plate_detect.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\plate_judge.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\plate_locate.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\plate_recognize.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\program_options.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\svm_train.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\util.h">
|
||||
<Filter>头文件\easypr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\preprocess\deface.h">
|
||||
<Filter>头文件\easypr\preprocess</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\preprocess\gdts.h">
|
||||
<Filter>头文件\easypr\preprocess</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\easypr\preprocess\mc_data.h">
|
||||
<Filter>头文件\easypr\preprocess</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\core\chars_identify.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\chars_recognise.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\chars_segment.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\core_func.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\train\ann_train.cpp">
|
||||
<Filter>源文件\train</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\train\svm_train.cpp">
|
||||
<Filter>源文件\train</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\util\util.cpp">
|
||||
<Filter>源文件\util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\util\program_options.cpp">
|
||||
<Filter>源文件\util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\feature.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\plate.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\plate_detect.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\plate_judge.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\plate_locate.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\core\plate_recognize.cpp">
|
||||
<Filter>源文件\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\preprocess\deface.cpp">
|
||||
<Filter>源文件\preprocess</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\preprocess\gdts.cpp">
|
||||
<Filter>源文件\preprocess</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\preprocess\mc_data.cpp">
|
||||
<Filter>源文件\preprocess</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="resources\model\ann.xml">
|
||||
<Filter>资源文件</Filter>
|
||||
</Xml>
|
||||
<Xml Include="resources\model\svm.xml">
|
||||
<Filter>资源文件</Filter>
|
||||
</Xml>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="关于版权.txt" />
|
||||
<Text Include="resources\image\使用说明.txt" />
|
||||
<Text Include="resources\image\GDSL.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j8
|
||||
@ -1,158 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# EasyPR auto configure script
|
||||
# --------------------------------------------------------------------
|
||||
#
|
||||
# This script configures OpenCV3.1 for Visual Studio
|
||||
# on Windows.
|
||||
#
|
||||
# You are required to have Python3.* installed, and python.exe must
|
||||
# be added to your PATH (C:\Python34 for example).
|
||||
#
|
||||
# You can use it by executing:
|
||||
#
|
||||
# C:\> cd path\to\EasyPR
|
||||
# C:\> python configure.py
|
||||
#
|
||||
# Note: compatible with python3, haven't been tested on python2.
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
kProjectDir = "vcprojs"
|
||||
|
||||
kProjects = ["libeasypr.vcxproj", "demo.vcxproj"]
|
||||
|
||||
kProjectTemplates = ["libeasypr.vcxproj.template", "demo.vcxproj.template"]
|
||||
|
||||
kOpenCVConfig = "OpenCVConfig-version.cmake"
|
||||
|
||||
kConfig = {
|
||||
"build": "",
|
||||
"include": "",
|
||||
"library": "",
|
||||
"link": ["opencv_world310"],
|
||||
"bit": "",
|
||||
"vs": ""
|
||||
}
|
||||
|
||||
kPatterns = {
|
||||
"include": "(<AdditionalIncludeDirectories>)(.*?)(</AdditionalIncludeDirectories>)",
|
||||
"library": "(<AdditionalLibraryDirectories>)(.*?)(</AdditionalLibraryDirectories>)",
|
||||
"link": "(<AdditionalDependencies>)(.*?)(</AdditionalDependencies>)"
|
||||
}
|
||||
|
||||
kReplacements = {
|
||||
"include": r"\1%s;\2\3",
|
||||
"library": r'\1%s\3',
|
||||
"link": r'\1%s;\2\3'
|
||||
}
|
||||
|
||||
|
||||
def configure():
|
||||
for i in range(2):
|
||||
print(">> creating %s" % kProjects[i])
|
||||
tpath = os.path.join(kProjectDir, kProjectTemplates[i])
|
||||
fp = open(tpath, encoding="utf-8")
|
||||
try:
|
||||
# read from disk
|
||||
original = fp.read()
|
||||
nstring = ""
|
||||
if 0 == i:
|
||||
nstring = configure_libeasypr(original)
|
||||
elif 1 == i:
|
||||
nstring = configure_demo(original)
|
||||
|
||||
# write to disk
|
||||
wpath = os.path.join(kProjectDir, kProjects[i])
|
||||
writer = open(wpath, mode="wb")
|
||||
try:
|
||||
writer.write(nstring.encode())
|
||||
finally:
|
||||
writer.close()
|
||||
finally:
|
||||
fp.close()
|
||||
print(">> all done! Open EasyPR.sln and have fun!")
|
||||
|
||||
|
||||
def configure_libeasypr(buffer):
|
||||
# additional include dir
|
||||
pattern = re.compile(kPatterns["include"])
|
||||
return pattern.sub(kReplacements["include"] %
|
||||
(kConfig["include"][:2] + re.escape(kConfig["include"][2:])),
|
||||
buffer)
|
||||
|
||||
|
||||
def configure_demo(buffer):
|
||||
# additional include dir
|
||||
pattern = re.compile(kPatterns["include"])
|
||||
nstring = pattern.sub(kReplacements["include"] %
|
||||
(kConfig["include"][:2] + re.escape(kConfig["include"][2:])),
|
||||
buffer)
|
||||
# additional library dir
|
||||
pattern = re.compile(kPatterns["library"])
|
||||
nstring = pattern.sub(kReplacements["library"] %
|
||||
(kConfig["library"][:2] + re.escape(kConfig["library"][2:])),
|
||||
nstring)
|
||||
# additional dependencies
|
||||
#lib_string = ""
|
||||
#for lib in kConfig["link"]:
|
||||
# lib_string += (lib + "d.lib")
|
||||
|
||||
#pattern = re.compile(kPatterns["link"])
|
||||
#return pattern.sub(kReplacements["link"] % lib_string, nstring)
|
||||
|
||||
return nstring
|
||||
|
||||
|
||||
def check_opencv_version():
|
||||
file = os.path.join(kConfig["build"], kOpenCVConfig)
|
||||
print(">> Checking ", file)
|
||||
fp = open(file)
|
||||
opencv_version = 0
|
||||
try:
|
||||
fline = fp.readline()
|
||||
match = re.search(r"OpenCV_VERSION (\d)\.(\d)\.(\d{,2})", fline)
|
||||
if match is not None:
|
||||
opencv_version = match.group(1) + "." + match.group(2)
|
||||
finally:
|
||||
fp.close()
|
||||
return opencv_version
|
||||
|
||||
|
||||
def cli():
|
||||
while True:
|
||||
root_ = input(r"Where is your opencv root path? (e.g, C:\path\to\opencv3): ")
|
||||
if os.path.exists(root_):
|
||||
kConfig["build"] = os.path.join(root_, "build")
|
||||
kConfig["include"] = os.path.join(kConfig["build"], "include")
|
||||
break
|
||||
else:
|
||||
print("Invalid path")
|
||||
|
||||
if check_opencv_version() != "3.1":
|
||||
print("requires opencv 3.1")
|
||||
exit()
|
||||
|
||||
kConfig["bit"] = "x64"
|
||||
|
||||
while True:
|
||||
vc = input("Which Visual Studio you are using? (vs2013 or vs2015): ")
|
||||
if vc == "vs2013":
|
||||
kConfig["vs"] = "vc12"
|
||||
break
|
||||
elif vc == "vs2015":
|
||||
kConfig["vs"] = "vc14"
|
||||
break
|
||||
else:
|
||||
print("Please type vs2013 or vs2015")
|
||||
|
||||
kConfig["library"] = os.path.normpath("%s/%s/%s/lib/" % (kConfig["build"], kConfig["bit"], kConfig["vs"]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
configure()
|
||||
@ -1,13 +1,12 @@
|
||||
#ifndef EASYPR_EASYPR_H
|
||||
#define EASYPR_EASYPR_H
|
||||
|
||||
#include "easypr/core/plate_recognize.h"
|
||||
#include "easypr/train/svm_train.h"
|
||||
#include "easypr/train/ann_train.h"
|
||||
#include "easypr/train/annCh_train.h"
|
||||
#include "easypr/util/util.h"
|
||||
#include "easypr/util/program_options.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"
|
||||
#include "easypr/config.h"
|
||||
|
||||
#endif //EASYPR_EASYPR_H
|
||||
|
||||
@ -1,148 +0,0 @@
|
||||
#ifndef EASYPR_CONFIG_H_
|
||||
#define EASYPR_CONFIG_H_
|
||||
|
||||
#define CV_VERSION_THREE_ZERO
|
||||
|
||||
namespace easypr {
|
||||
|
||||
enum Color { BLUE, YELLOW, WHITE, UNKNOWN };
|
||||
|
||||
enum LocateType { SOBEL, COLOR, CMSER, OTHER };
|
||||
|
||||
enum CharSearchDirection { LEFT, RIGHT };
|
||||
|
||||
enum
|
||||
{
|
||||
PR_MODE_UNCONSTRAINED,
|
||||
PR_MODE_CAMERPOHNE,
|
||||
PR_MODE_PARKING,
|
||||
PR_MODE_HIGHWAY
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PR_DETECT_SOBEL = 0x01, /**Sobel detect type, using twice Sobel */
|
||||
PR_DETECT_COLOR = 0x02, /**Color detect type */
|
||||
PR_DETECT_CMSER = 0x04, /**Character detect type, using mser */
|
||||
};
|
||||
|
||||
static const char* kDefaultSvmPath = "model/svm_hist.xml";
|
||||
static const char* kLBPSvmPath = "model/svm_lbp.xml";
|
||||
static const char* kHistSvmPath = "model/svm_hist.xml";
|
||||
|
||||
static const char* kDefaultAnnPath = "model/ann.xml";
|
||||
static const char* kChineseAnnPath = "model/ann_chinese.xml";
|
||||
static const char* kGrayAnnPath = "model/annCh.xml";
|
||||
|
||||
//This is important to for key transform to chinese
|
||||
static const char* kChineseMappingPath = "model/province_mapping";
|
||||
|
||||
typedef enum {
|
||||
kForward = 1, // correspond to "has plate"
|
||||
kInverse = 0 // correspond to "no plate"
|
||||
} SvmLabel;
|
||||
|
||||
static const int kPlateResizeWidth = 136;
|
||||
static const int kPlateResizeHeight = 36;
|
||||
|
||||
static const int kShowWindowWidth = 1000;
|
||||
static const int kShowWindowHeight = 800;
|
||||
|
||||
static const float kSvmPercentage = 0.7f;
|
||||
|
||||
static const int kCharacterInput = 120;
|
||||
static const int kChineseInput = 440;
|
||||
static const int kAnnInput = kCharacterInput;
|
||||
|
||||
static const int kCharacterSize = 10;
|
||||
static const int kChineseSize = 20;
|
||||
static const int kPredictSize = kCharacterSize;
|
||||
|
||||
static const int kNeurons = 40;
|
||||
|
||||
static const char *kChars[] = {
|
||||
"0", "1", "2",
|
||||
"3", "4", "5",
|
||||
"6", "7", "8",
|
||||
"9",
|
||||
/* 10 */
|
||||
"A", "B", "C",
|
||||
"D", "E", "F",
|
||||
"G", "H", /* {"I", "I"} */
|
||||
"J", "K", "L",
|
||||
"M", "N", /* {"O", "O"} */
|
||||
"P", "Q", "R",
|
||||
"S", "T", "U",
|
||||
"V", "W", "X",
|
||||
"Y", "Z",
|
||||
/* 24 */
|
||||
"zh_cuan" , "zh_e" , "zh_gan" ,
|
||||
"zh_gan1" , "zh_gui" , "zh_gui1" ,
|
||||
"zh_hei" , "zh_hu" , "zh_ji" ,
|
||||
"zh_jin" , "zh_jing" , "zh_jl" ,
|
||||
"zh_liao" , "zh_lu" , "zh_meng" ,
|
||||
"zh_min" , "zh_ning" , "zh_qing" ,
|
||||
"zh_qiong", "zh_shan" , "zh_su" ,
|
||||
"zh_sx" , "zh_wan" , "zh_xiang",
|
||||
"zh_xin" , "zh_yu" , "zh_yu1" ,
|
||||
"zh_yue" , "zh_yun" , "zh_zang" ,
|
||||
"zh_zhe"
|
||||
/* 31 */
|
||||
};
|
||||
|
||||
static const int kCharactersNumber = 34;
|
||||
static const int kChineseNumber = 31;
|
||||
static const int kCharsTotalNumber = 65;
|
||||
|
||||
static bool kDebug = false;
|
||||
|
||||
static const int kGrayCharWidth = 20;
|
||||
static const int kGrayCharHeight = 32;
|
||||
static const int kCharLBPGridX = 4;
|
||||
static const int kCharLBPGridY = 4;
|
||||
static const int kCharLBPPatterns = 16;
|
||||
|
||||
static const int kCharHiddenNeurans = 64;
|
||||
|
||||
static const int kCharsCountInOnePlate = 7;
|
||||
static const int kSymbolsCountInChinesePlate = 6;
|
||||
|
||||
static const float kPlateMaxSymbolCount = 7.5f;
|
||||
static const int kSymbolIndex = 2;
|
||||
|
||||
// Disable the copy and assignment operator for this class.
|
||||
#define DISABLE_ASSIGN_AND_COPY(className) \
|
||||
private:\
|
||||
className& operator=(const className&); \
|
||||
className(const className&)
|
||||
|
||||
// Display the image.
|
||||
#define SET_DEBUG(param) \
|
||||
kDebug = param
|
||||
|
||||
// Display the image.
|
||||
#define SHOW_IMAGE(imgName, debug) \
|
||||
if (debug) { \
|
||||
namedWindow("imgName", WINDOW_AUTOSIZE); \
|
||||
moveWindow("imgName", 500, 500); \
|
||||
imshow("imgName", imgName); \
|
||||
waitKey(0); \
|
||||
destroyWindow("imgName"); \
|
||||
}
|
||||
|
||||
// Load model. compatitable withe 3.0, 3.1 and 3.2
|
||||
#ifdef CV_VERSION_THREE_TWO
|
||||
#define LOAD_SVM_MODEL(model, path) \
|
||||
model = ml::SVM::load(path);
|
||||
#define LOAD_ANN_MODEL(model, path) \
|
||||
model = ml::ANN_MLP::load(path);
|
||||
#else
|
||||
#define LOAD_SVM_MODEL(model, path) \
|
||||
model = ml::SVM::load<ml::SVM>(path);
|
||||
#define LOAD_ANN_MODEL(model, path) \
|
||||
model = ml::ANN_MLP::load<ml::ANN_MLP>(path);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // EASYPR_CONFIG_H_
|
||||
@ -1,131 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: CHARACTER Header
|
||||
// Version: 1.0
|
||||
// Date: 2016-06-14
|
||||
// Author: liuruoze
|
||||
// Copyright: liuruoze
|
||||
// Desciption:
|
||||
// An abstract class for car character in plate.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef EASYPR_CORE_CHARACTER_H_
|
||||
#define EASYPR_CORE_CHARACTER_H_
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
class CCharacter {
|
||||
public:
|
||||
CCharacter()
|
||||
{
|
||||
m_characterMat = Mat();
|
||||
m_characterGrayMat = Mat();
|
||||
m_characterPos = Rect();
|
||||
m_characterStr = "";
|
||||
m_score = 0;
|
||||
m_isChinese = false;
|
||||
m_ostuLevel = 125;
|
||||
m_center = Point(0, 0);
|
||||
m_index = 0;
|
||||
}
|
||||
|
||||
CCharacter(const CCharacter& other)
|
||||
{
|
||||
m_characterMat = other.m_characterMat;
|
||||
m_characterGrayMat = other.m_characterGrayMat;
|
||||
m_characterPos = other.m_characterPos;
|
||||
m_characterStr = other.m_characterStr;
|
||||
m_score = other.m_score;
|
||||
m_isChinese = other.m_isChinese;
|
||||
m_ostuLevel = other.m_ostuLevel;
|
||||
m_center = other.m_center;
|
||||
m_index = other.m_index;
|
||||
}
|
||||
|
||||
inline void setCharacterMat(Mat param) { m_characterMat = param; }
|
||||
inline Mat getCharacterMat() const { return m_characterMat; }
|
||||
|
||||
inline void setCharacterGrayMat(Mat param) { m_characterGrayMat = param; }
|
||||
inline Mat getCharacterGrayMat() const { return m_characterGrayMat; }
|
||||
|
||||
inline void setCharacterPos(Rect param) { m_characterPos = param; }
|
||||
inline Rect getCharacterPos() const { return m_characterPos; }
|
||||
|
||||
inline void setCharacterStr(String param) { m_characterStr = param; }
|
||||
inline String getCharacterStr() const { return m_characterStr; }
|
||||
|
||||
inline void setCharacterScore(double param) { m_score = param; }
|
||||
inline double getCharacterScore() const { return m_score; }
|
||||
|
||||
inline void setIsChinese(bool param) { m_isChinese = param; }
|
||||
inline bool getIsChinese() const { return m_isChinese; }
|
||||
|
||||
inline void setOstuLevel(double param) { m_ostuLevel = param; }
|
||||
inline double getOstuLevel() const { return m_ostuLevel; }
|
||||
|
||||
inline void setCenterPoint(Point param) { m_center = param; }
|
||||
inline Point getCenterPoint() const { return m_center; }
|
||||
|
||||
inline void setIndex(int param) { m_index = param; }
|
||||
inline int getIndex() const { return m_index; }
|
||||
|
||||
inline bool getIsStrong() const { return m_score >= 0.9; }
|
||||
inline bool getIsWeak() const { return m_score < 0.9 && m_score >= 0.5; }
|
||||
inline bool getIsLittle() const { return m_score < 0.5; }
|
||||
|
||||
bool operator < (const CCharacter& other) const
|
||||
{
|
||||
return (m_score > other.m_score);
|
||||
}
|
||||
|
||||
bool operator < (const CCharacter& other)
|
||||
{
|
||||
return (m_score > other.m_score);
|
||||
}
|
||||
|
||||
private:
|
||||
//! character mat
|
||||
Mat m_characterMat;
|
||||
|
||||
//! character gray mat
|
||||
Mat m_characterGrayMat;
|
||||
|
||||
//! character rect
|
||||
Rect m_characterPos;
|
||||
|
||||
//! character str
|
||||
String m_characterStr;
|
||||
|
||||
//! character likely
|
||||
double m_score;
|
||||
|
||||
//! weather is chinese
|
||||
bool m_isChinese;
|
||||
|
||||
//! ostu level
|
||||
double m_ostuLevel;
|
||||
|
||||
//! center point
|
||||
Point m_center;
|
||||
|
||||
//! the postion in the plate, from 1 to 7 normal
|
||||
int m_index;
|
||||
|
||||
////! m_score >= 0.9
|
||||
//bool isStrong;
|
||||
|
||||
////! m_score < 0.9 && m_score >= 0.5
|
||||
//bool isWeak;
|
||||
|
||||
////! m_score < 0.5
|
||||
//bool isLittle;
|
||||
};
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif // EASYPR_CORE_PLATE_H_
|
||||
@ -1,58 +0,0 @@
|
||||
#ifndef EASYPR_CORE_CHARSIDENTIFY_H_
|
||||
#define EASYPR_CORE_CHARSIDENTIFY_H_
|
||||
|
||||
#include <memory>
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
#include "easypr/util/kv.h"
|
||||
#include "easypr/core/character.hpp"
|
||||
#include "easypr/core/feature.h"
|
||||
|
||||
namespace easypr {
|
||||
|
||||
class CharsIdentify {
|
||||
public:
|
||||
static CharsIdentify* instance();
|
||||
|
||||
int classify(cv::Mat f, float& maxVal, bool isChinses = false, bool isAlphabet = false);
|
||||
void classify(cv::Mat featureRows, std::vector<int>& out_maxIndexs,
|
||||
std::vector<float>& out_maxVals, std::vector<bool> isChineseVec);
|
||||
void classify(std::vector<CCharacter>& charVec);
|
||||
|
||||
void classifyChinese(std::vector<CCharacter>& charVec);
|
||||
void classifyChineseGray(std::vector<CCharacter>& charVec);
|
||||
|
||||
std::pair<std::string, std::string> identify(cv::Mat input, bool isChinese = false, bool isAlphabet = false);
|
||||
int identify(std::vector<cv::Mat> inputs, std::vector<std::pair<std::string, std::string>>& outputs,
|
||||
std::vector<bool> isChineseVec);
|
||||
|
||||
std::pair<std::string, std::string> identifyChinese(cv::Mat input, float& result, bool& isChinese);
|
||||
std::pair<std::string, std::string> identifyChineseGray(cv::Mat input, float& result, bool& isChinese);
|
||||
|
||||
bool isCharacter(cv::Mat input, std::string& label, float& maxVal, bool isChinese = false);
|
||||
|
||||
void LoadModel(std::string path);
|
||||
void LoadChineseModel(std::string path);
|
||||
void LoadGrayChANN(std::string path);
|
||||
void LoadChineseMapping(std::string path);
|
||||
|
||||
private:
|
||||
CharsIdentify();
|
||||
annCallback extractFeature;
|
||||
static CharsIdentify* instance_;
|
||||
|
||||
// binary character classifer
|
||||
cv::Ptr<cv::ml::ANN_MLP> ann_;
|
||||
|
||||
// binary character classifer, only for chinese
|
||||
cv::Ptr<cv::ml::ANN_MLP> annChinese_;
|
||||
|
||||
// gray classifer, only for chinese
|
||||
cv::Ptr<cv::ml::ANN_MLP> annGray_;
|
||||
|
||||
// used for chinese mapping
|
||||
std::shared_ptr<Kv> kv_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EASYPR_CORE_CHARSIDENTIFY_H_
|
||||
@ -1,84 +0,0 @@
|
||||
#ifndef EASYPR_CORE_CHARSSEGMENT_H_
|
||||
#define EASYPR_CORE_CHARSSEGMENT_H_
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
#include "easypr/config.h"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
namespace easypr {
|
||||
|
||||
class CCharsSegment {
|
||||
public:
|
||||
CCharsSegment();
|
||||
//! using ostu algotithm the segment chars in plate
|
||||
int charsSegment(Mat input, std::vector<Mat>& resultVec, Color color = BLUE);
|
||||
|
||||
//! using methods to segment chars in plate
|
||||
int charsSegmentUsingOSTU(Mat input, std::vector<Mat>& resultVec, std::vector<Mat>& grayChars, Color color = BLUE);
|
||||
int charsSegmentUsingMSER(Mat input, vector<Mat>& resultVec, vector<Mat>& grayChars, Color color = BLUE);
|
||||
|
||||
//! using project
|
||||
int projectSegment(const Mat& input, Color color, vector<int>& out_indexs);
|
||||
|
||||
bool verifyCharSizes(Mat r);
|
||||
|
||||
// find the best chinese binaranzation method
|
||||
void judgeChinese(Mat in, Mat& out, Color plateType);
|
||||
void judgeChineseGray(Mat in, Mat& out, Color plateType);
|
||||
|
||||
Mat preprocessChar(Mat in);
|
||||
|
||||
//! to find the position of chinese
|
||||
Rect GetChineseRect(const Rect rectSpe);
|
||||
|
||||
//! find the character refer to city, like "suA" A
|
||||
int GetSpecificRect(const std::vector<Rect>& vecRect);
|
||||
|
||||
//! Do two things
|
||||
// 1.remove rect in the left of city character
|
||||
// 2.from the city rect, to the right, choose 6 rects
|
||||
int RebuildRect(const std::vector<Rect>& vecRect, std::vector<Rect>& outRect,
|
||||
int specIndex);
|
||||
|
||||
int SortRect(const std::vector<Rect>& vecRect, std::vector<Rect>& out);
|
||||
|
||||
inline void setLiuDingSize(int param) { m_LiuDingSize = param; }
|
||||
inline void setColorThreshold(int param) { m_ColorThreshold = param; }
|
||||
|
||||
inline void setBluePercent(float param) { m_BluePercent = param; }
|
||||
inline float getBluePercent() const { return m_BluePercent; }
|
||||
inline void setWhitePercent(float param) { m_WhitePercent = param; }
|
||||
inline float getWhitePercent() const { return m_WhitePercent; }
|
||||
|
||||
static const int DEFAULT_DEBUG = 1;
|
||||
|
||||
static const int CHAR_SIZE = 20;
|
||||
static const int HORIZONTAL = 1;
|
||||
static const int VERTICAL = 0;
|
||||
|
||||
static const int DEFAULT_LIUDING_SIZE = 7;
|
||||
static const int DEFAULT_MAT_WIDTH = 136;
|
||||
static const int DEFAULT_COLORTHRESHOLD = 150;
|
||||
|
||||
inline void setDebug(int param) { m_debug = param; }
|
||||
|
||||
inline int getDebug() { return m_debug; }
|
||||
|
||||
private:
|
||||
|
||||
int m_LiuDingSize;
|
||||
|
||||
int m_theMatWidth;
|
||||
|
||||
int m_ColorThreshold;
|
||||
float m_BluePercent;
|
||||
float m_WhitePercent;
|
||||
|
||||
int m_debug;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // EASYPR_CORE_CHARSSEGMENT_H_
|
||||
@ -1,159 +0,0 @@
|
||||
#ifndef EASYPR_CORE_COREFUNC_H_
|
||||
#define EASYPR_CORE_COREFUNC_H_
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
#include "easypr/core/plate.hpp"
|
||||
#include "easypr/core/character.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
//! find binary image match to color
|
||||
//! input rgb, want match color ( blue or yellow)
|
||||
//! out grey, 255 is match, 0 is not match
|
||||
|
||||
Mat colorMatch(const Mat& src, Mat& match, const Color r,
|
||||
const bool adaptive_minsv);
|
||||
|
||||
//Mat mserMatch(const Mat& src, Mat& match, const Color r,
|
||||
// std::vector<RotatedRect>& plateRect, std::vector<Rect>& out_charRect);
|
||||
|
||||
bool plateColorJudge(const Mat& src, const Color r, const bool adaptive_minsv,
|
||||
float& percent);
|
||||
|
||||
bool bFindLeftRightBound(Mat& bound_threshold, int& posLeft, int& posRight);
|
||||
bool bFindLeftRightBound1(Mat& bound_threshold, int& posLeft, int& posRight);
|
||||
bool bFindLeftRightBound2(Mat& bound_threshold, int& posLeft, int& posRight);
|
||||
|
||||
bool clearLiuDing(Mat& img);
|
||||
void clearLiuDingOnly(Mat& img);
|
||||
void clearLiuDing(Mat mask, int& top, int& bottom);
|
||||
|
||||
Color getPlateType(const Mat& src, const bool adaptive_minsv);
|
||||
|
||||
Mat histeq(Mat in);
|
||||
Rect GetCenterRect(Mat& in);
|
||||
Mat CutTheRect(Mat& in, Rect& rect);
|
||||
int ThresholdOtsu(Mat mat);
|
||||
|
||||
// project histogram
|
||||
Mat ProjectedHistogram(Mat img, int t, int threshold = 20);
|
||||
|
||||
Mat showHistogram(const Mat& hist);
|
||||
|
||||
Mat preprocessChar(Mat in, int char_size);
|
||||
|
||||
Rect GetChineseRect(const Rect rectSpe);
|
||||
|
||||
bool verifyCharSizes(Rect r);
|
||||
bool verifyPlateSize(Rect mr);
|
||||
bool verifyRotatedPlateSizes(RotatedRect mr, bool showDebug = false);
|
||||
|
||||
// non-maximum suppression
|
||||
void NMStoCharacter(std::vector<CCharacter> &inVec, double overlap);
|
||||
|
||||
// draw rotatedRectangle
|
||||
void rotatedRectangle(InputOutputArray img, RotatedRect rect,
|
||||
const Scalar& color, int thickness = 1,
|
||||
int lineType = LINE_8, int shift = 0);
|
||||
|
||||
// ostu region
|
||||
void spatial_ostu(InputArray _src, int grid_x, int grid_y, Color type = BLUE);
|
||||
|
||||
// Scale to small image (for the purpose of comput mser in large image)
|
||||
Mat scaleImage(const Mat& image, const Size& maxSize, double& scale_ratio);
|
||||
|
||||
// Scale back RotatedRect
|
||||
RotatedRect scaleBackRRect(const RotatedRect& rr, const float scale_ratio);
|
||||
|
||||
//! use verify size to first generate char candidates
|
||||
void mserCharMatch(const Mat &src, std::vector<Mat> &match, std::vector<CPlate>& out_plateVec_blue, std::vector<CPlate>& out_plateVec_yellow,
|
||||
bool usePlateMser, std::vector<RotatedRect>& out_plateRRect_blue, std::vector<RotatedRect>& out_plateRRect_yellow, int index = 0, bool showDebug = false);
|
||||
|
||||
// computer the insert over union about two rrect
|
||||
bool computeIOU(const RotatedRect& rrect1, const RotatedRect& rrect2, const int width, const int height, const float thresh, float& result);
|
||||
float computeIOU(const RotatedRect& rrect1, const RotatedRect& rrect2, const int width, const int height);
|
||||
|
||||
bool computeIOU(const Rect& rect1, const Rect& rect2, const float thresh, float& result);
|
||||
float computeIOU(const Rect& rect1, const Rect& rect2);
|
||||
|
||||
/** @brief convert form mser point to image.
|
||||
|
||||
The function created first by Hailiang Xu.
|
||||
Modified by Ruoze Liu.
|
||||
|
||||
@param
|
||||
*/
|
||||
Mat adaptive_image_from_points(const std::vector<Point>& points,
|
||||
const Rect& rect, const Size& size, const Scalar& backgroundColor = Scalar(0, 0, 0),
|
||||
const Scalar& forgroundColor = Scalar(255, 255, 255), bool gray = true);
|
||||
|
||||
// Calculate a rect have same length and width and remains the center
|
||||
Rect adaptive_charrect_from_rect(const Rect& rect, int maxwidth, int maxheight, bool useExtendHeight = false);
|
||||
|
||||
// calc safe rect
|
||||
bool calcSafeRect(const RotatedRect& roi_rect, const Mat& src,
|
||||
Rect_<float>& safeBoundRect);
|
||||
bool calcSafeRect(const RotatedRect &roi_rect, const int width, const int height,
|
||||
Rect_<float> &safeBoundRect);
|
||||
|
||||
// uniform resize all the image to same size for the next process
|
||||
Mat uniformResize(const Mat &result, float& scale);
|
||||
|
||||
// uniform resize all the plates to same size for the next process
|
||||
Mat uniformResizePlates(const Mat &result, float& scale);
|
||||
|
||||
// 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);
|
||||
|
||||
// enlarge the char rect
|
||||
Rect rectEnlarge(const Rect& src, const int mat_width, const int mat_height);
|
||||
Rect rectFit(const Rect &src, const int mat_width, const int mat_height);
|
||||
|
||||
// write images to temp folder
|
||||
void writeTempImage(const Mat& outImg, const string path, int index = 0);
|
||||
|
||||
// remove small hor lines in the plate
|
||||
bool judegMDOratio2(const Mat &image, const Rect &rect, std::vector<Point> &contour, Mat &result, const float thresh = 1.f,
|
||||
bool useExtendHeight = false);
|
||||
|
||||
// clear top and bottom borders
|
||||
void clearBorder(const Mat &img, Rect& cropRect);
|
||||
|
||||
//! non-maximum surpresion for 1d array
|
||||
template<typename T>
|
||||
void NMSfor1D(const vector<T>& arr, vector<int>& index) {
|
||||
// prepare
|
||||
int size = (int)arr.size();
|
||||
index.resize(size);
|
||||
for (int j = 0; j < size; j++)
|
||||
index.at(j) = 0;
|
||||
|
||||
// nms
|
||||
int i = 1;
|
||||
while (i < size - 1) {
|
||||
if (arr.at(i) > arr.at(i + 1)) {
|
||||
if (arr.at(i) >= arr.at(i - 1))
|
||||
index.at(i) = 1;
|
||||
}
|
||||
else {
|
||||
while (i < size - 1 && arr.at(i) <= arr.at(i + 1))
|
||||
i = i + 1;
|
||||
if (i < size - 1)
|
||||
index.at(i) = 1;
|
||||
}
|
||||
i = i + 2;
|
||||
}
|
||||
}
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif // EASYPR_CORE_COREFUNC_H_
|
||||
@ -1,59 +0,0 @@
|
||||
#ifndef EASYPR_CORE_FEATURE_H_
|
||||
#define EASYPR_CORE_FEATURE_H_
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
namespace easypr {
|
||||
|
||||
//! 获得车牌的特征数
|
||||
cv::Mat getHistogram(cv::Mat in);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 用于从车牌的image生成svm的训练特征features
|
||||
typedef void (*svmCallback)(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! convert from images to features used by gray char ann
|
||||
typedef void (*annCallback)(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! gray and project feature
|
||||
void getGrayPlusProject(const cv::Mat& grayChar, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取垂直和水平的直方图图值
|
||||
void getHistogramFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取SIFT特征子
|
||||
void getSIFTFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HOG特征子
|
||||
void getHOGFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HSV空间量化的直方图特征子
|
||||
void getHSVHistFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! LBP feature
|
||||
void getLBPFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! color feature
|
||||
void getColorFeatures(const cv::Mat& src, cv::Mat& features);
|
||||
|
||||
//! color feature and histom
|
||||
void getHistomPlusColoFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! get character feature
|
||||
cv::Mat charFeatures(cv::Mat in, int sizeData);
|
||||
cv::Mat charFeatures2(cv::Mat in, int sizeData);
|
||||
|
||||
//! LBP feature + Histom feature
|
||||
void getLBPplusHistFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! grayChar feauter
|
||||
void getGrayCharFeatures(const cv::Mat& grayChar, cv::Mat& features);
|
||||
|
||||
void getGrayPlusLBP(const Mat& grayChar, Mat& features);
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif // EASYPR_CORE_FEATURE_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue