Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
2fd02963ee | 2 weeks ago |
@ -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_
|
||||
@ -0,0 +1,39 @@
|
||||
**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,44 @@
|
||||
.idea/
|
||||
_build/
|
||||
resources/image/tmp/
|
||||
*.lib
|
||||
*.suo
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.exe
|
||||
*.dll
|
||||
*.ilk
|
||||
*.pdb
|
||||
experi
|
||||
/tmp
|
||||
resources/image/native_test/*.jpg
|
||||
resources/image/native_test/cars
|
||||
resources/image/native_test/*.py
|
||||
resources/image/phone_test
|
||||
*.vsp
|
||||
*.psess
|
||||
*.DS_Store
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
[Dd]ebug*/
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
|
||||
*.obj
|
||||
*.cache
|
||||
*.log
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(easypr)
|
||||
|
||||
# c++11 required
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/opencv-3.2.0")
|
||||
endif ()
|
||||
|
||||
# OpenVC3 required
|
||||
find_package(OpenCV 3.2.0 REQUIRED)
|
||||
|
||||
# where to find header files
|
||||
include_directories(.)
|
||||
include_directories(include)
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
# sub directories
|
||||
add_subdirectory(thirdparty)
|
||||
|
||||
# sources to be compiled
|
||||
set(SOURCE_FILES
|
||||
src/core/core_func.cpp
|
||||
src/core/chars_identify.cpp
|
||||
src/core/chars_recognise.cpp
|
||||
src/core/chars_segment.cpp
|
||||
src/core/feature.cpp
|
||||
src/core/plate_detect.cpp
|
||||
src/core/plate_judge.cpp
|
||||
src/core/plate_locate.cpp
|
||||
src/core/plate_recognize.cpp
|
||||
src/core/params.cpp
|
||||
|
||||
src/train/ann_train.cpp
|
||||
src/train/annCh_train.cpp
|
||||
src/train/svm_train.cpp
|
||||
src/train/train.cpp
|
||||
src/train/create_data.cpp
|
||||
|
||||
src/util/util.cpp
|
||||
src/util/program_options.cpp
|
||||
src/util/kv.cpp
|
||||
)
|
||||
|
||||
# pack objects to static library
|
||||
add_library(easypr STATIC ${SOURCE_FILES})
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(EXECUTABLE_NAME "demo")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(EXECUTABLE_NAME "demo")
|
||||
endif ()
|
||||
|
||||
# set to be releas mode
|
||||
# set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
# test cases
|
||||
add_executable(${EXECUTABLE_NAME} test/main.cpp)
|
||||
# link opencv libs
|
||||
target_link_libraries(${EXECUTABLE_NAME} easypr thirdparty ${OpenCV_LIBS})
|
||||
# MESSAGE(${CMAKE_BINARY_DIR}/../)
|
||||
SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../")
|
||||
@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j8
|
||||
@ -0,0 +1,158 @@
|
||||
# -*- 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,58 +1,83 @@
|
||||
#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"
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: chars_recognise 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 CCharsRecognise
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef EASYPR_CORE_CHARSRECOGNISE_H_
|
||||
#define EASYPR_CORE_CHARSRECOGNISE_H_
|
||||
|
||||
#include "easypr/core/chars_segment.h"
|
||||
#include "easypr/core/chars_identify.h"
|
||||
#include "easypr/core/core_func.h"
|
||||
#include "easypr/util/util.h"
|
||||
#include "easypr/core/plate.hpp"
|
||||
#include "easypr/config.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_;
|
||||
class CCharsRecognise {
|
||||
public:
|
||||
CCharsRecognise();
|
||||
|
||||
~CCharsRecognise();
|
||||
|
||||
int charsRecognise(cv::Mat plate, std::string& plateLicense);
|
||||
int charsRecognise(CPlate& plate, std::string& plateLicense);
|
||||
|
||||
inline std::string getPlateColor(cv::Mat input) const {
|
||||
std::string color = "未知";
|
||||
Color result = getPlateType(input, true);
|
||||
if (BLUE == result) color = "蓝牌";
|
||||
if (YELLOW == result) color = "黄牌";
|
||||
if (WHITE == result) color = "白牌";
|
||||
#ifdef OS_WINDOWS
|
||||
color = utils::utf8_to_gbk(color.c_str());
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
|
||||
inline std::string getPlateColor(Color in) const {
|
||||
std::string color = "未知";
|
||||
if (BLUE == in) color = "蓝牌";
|
||||
if (YELLOW == in) color = "黄牌";
|
||||
if (WHITE == in) color = "白牌";
|
||||
#ifdef OS_WINDOWS
|
||||
color = utils::utf8_to_gbk(color.c_str());
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
|
||||
inline void setLiuDingSize(int param) {
|
||||
m_charsSegment->setLiuDingSize(param);
|
||||
}
|
||||
inline void setColorThreshold(int param) {
|
||||
m_charsSegment->setColorThreshold(param);
|
||||
}
|
||||
inline void setBluePercent(float param) {
|
||||
m_charsSegment->setBluePercent(param);
|
||||
}
|
||||
inline float getBluePercent() const {
|
||||
return m_charsSegment->getBluePercent();
|
||||
}
|
||||
inline void setWhitePercent(float param) {
|
||||
m_charsSegment->setWhitePercent(param);
|
||||
}
|
||||
inline float getWhitePercent() const {
|
||||
return m_charsSegment->getWhitePercent();
|
||||
}
|
||||
|
||||
private:
|
||||
//!字符分割
|
||||
|
||||
CCharsSegment* m_charsSegment;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EASYPR_CORE_CHARSIDENTIFY_H_
|
||||
} /* \namespace easypr */
|
||||
|
||||
#endif // EASYPR_CORE_CHARSRECOGNISE_H_
|
||||
@ -0,0 +1,31 @@
|
||||
zh_cuan 川
|
||||
zh_gan1 甘
|
||||
zh_hei 黑
|
||||
zh_jin 津
|
||||
zh_liao 辽
|
||||
zh_min 闽
|
||||
zh_qiong 琼
|
||||
zh_sx 晋
|
||||
zh_xin 新
|
||||
zh_yue 粤
|
||||
zh_zhe 浙
|
||||
zh_e 鄂
|
||||
zh_gui 贵
|
||||
zh_hu 沪
|
||||
zh_jing 京
|
||||
zh_lu 鲁
|
||||
zh_ning 宁
|
||||
zh_shan 陕
|
||||
zh_wan 皖
|
||||
zh_yu 豫
|
||||
zh_yun 云
|
||||
zh_gan 赣
|
||||
zh_gui1 桂
|
||||
zh_ji 冀
|
||||
zh_jl 吉
|
||||
zh_meng 蒙
|
||||
zh_qing 青
|
||||
zh_su 苏
|
||||
zh_xiang 湘
|
||||
zh_yu1 渝
|
||||
zh_zang 藏
|
||||
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 359 KiB |
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 330 KiB |
|
After Width: | Height: | Size: 453 B |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 323 KiB |
|
After Width: | Height: | Size: 461 KiB |
|
After Width: | Height: | Size: 207 KiB |
|
After Width: | Height: | Size: 237 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 200 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 397 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 308 KiB |
|
After Width: | Height: | Size: 355 KiB |
|
After Width: | Height: | Size: 411 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 293 KiB |
|
After Width: | Height: | Size: 52 KiB |