Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
forked from liuruoze/EasyPR
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (3)
Tags (13)
master
v1.6alpha
1.3
v1.6
v1.6alpha
v1.5
v1.5beta
v1.4
v1.4beta
v1.3
v1.3beta
v1.2
v1.1.1
v1.1.0
v1.1
v1.0
master
Branches (3)
Tags (13)
master
v1.6alpha
1.3
v1.6
v1.6alpha
v1.5
v1.5beta
v1.4
v1.4beta
v1.3
v1.3beta
v1.2
v1.1.1
v1.1.0
v1.1
v1.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (3)
Tags (13)
master
v1.6alpha
1.3
v1.6
v1.6alpha
v1.5
v1.5beta
v1.4
v1.4beta
v1.3
v1.3beta
v1.2
v1.1.1
v1.1.0
v1.1
v1.0
EasyPR
/
test
/
main.cpp
EasyPR
/
test
/
main.cpp
main.cpp 13.73 KB
Copy Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
#include "easypr.h"
#include "easypr/util/switch.hpp"
#include "accuracy.hpp"
#include "chars.hpp"
#include "plate.hpp"
// %OPENCV%\x86\vc12\lib opencv_world300d.lib;
namespace easypr {
namespace demo {
// interactions
int accuracyTestMain() {
std::shared_ptr<easypr::Kv> kv(new easypr::Kv);
kv->load("resources/text/chinese_mapping");
bool isExit = false;
while (!isExit) {
easypr::Utils::print_file_lines("resources/text/batch_test_menu");
std::cout << kv->get("make_a_choice") << ":";
int select = -1;
bool isRepeat = true;
Result result;
while (isRepeat) {
std::cin >> select;
isRepeat = false;
switch (select) {
case 1:
accuracyTest("resources/image/general_test", result);
break;
case 2:
accuracyTest("resources/image/native_test", result);
break;
case 3:
gridSearchTest("resources/image/general_test");
break;
case 4:
isExit = true;
break;
default:
std::cout << kv->get("input_error") << ":";
isRepeat = true;
break;
}
}
}
return 0;
}
int trainChineseMain() {
std::shared_ptr<easypr::Kv> kv(new easypr::Kv);
kv->load("resources/text/chinese_mapping");
bool isExit = false;
while (!isExit) {
easypr::Utils::print_file_lines("resources/text/train_menu");
std::cout << kv->get("make_a_choice") << ":";
int select = -1;
bool isRepeat = true;
while (isRepeat) {
std::cin >> select;
isRepeat = false;
switch (select) {
case 1:
{
easypr::AnnChTrain ann("tmp/annCh", "tmp/annCh.xml");
ann.setNumberForCount(100);
ann.train();
}
break;
case 2:
{
easypr::AnnChTrain ann("tmp/annCh", "tmp/annCh.xml");
ann.setNumberForCount(350);
ann.train();
}
break;
case 3:
{
easypr::AnnChTrain ann("tmp/annCh", "tmp/annCh.xml");
ann.setNumberForCount(700);
ann.train();
}
break;
case 4:
{
easypr::AnnChTrain ann("tmp/annCh", "tmp/annCh.xml");
ann.setNumberForCount(1000);
ann.train();
}
break;
case 5:
{
easypr::AnnChTrain ann("tmp/annCh", "tmp/annCh.xml");
ann.setNumberForCount(1500);
ann.train();
}
break;
case 6:
isExit = true;
break;
default:
std::cout << kv->get("input_error") << ":";
isRepeat = true;
break;
}
}
}
return 0;
}
int testMain() {
std::shared_ptr<easypr::Kv> kv(new easypr::Kv);
kv->load("resources/text/chinese_mapping");
bool isExit = false;
while (!isExit) {
Utils::print_file_lines("resources/text/test_menu");
std::cout << kv->get("make_a_choice") << ":";
int select = -1;
bool isRepeat = true;
while (isRepeat) {
std::cin >> select;
isRepeat = false;
switch (select) {
case 1:
assert(test_plate_locate() == 0);
break;
case 2:
assert(test_plate_judge() == 0);
break;
case 3:
assert(test_plate_detect() == 0);
break;
case 4:
assert(test_chars_segment() == 0);
break;
case 5:
assert(test_chars_identify() == 0);
break;
case 6:
assert(test_chars_recognise() == 0);
break;
case 7:
assert(test_plate_recognize() == 0);
break;
case 8:
assert(test_plate_locate() == 0);
assert(test_plate_judge() == 0);
assert(test_plate_detect() == 0);
assert(test_chars_segment() == 0);
assert(test_chars_identify() == 0);
assert(test_chars_recognise() == 0);
assert(test_plate_recognize() == 0);
break;
case 9:
isExit = true;
break;
default:
std::cout << kv->get("input_error") << ":";
isRepeat = true;
break;
}
}
}
return 0;
}
} // namespace demo
} // namespace easypr
void command_line_handler(int argc, const char* argv[]) {
program_options::Generator options;
options.add_subroutine("svm", "svm operations").make_usage("Usage:");
{
/* ------------------------------------------
| SVM Training operations
| ------------------------------------------
|
| $ demo svm --plates=path/to/plates/ [--test] --svm=save/to/svm.xml
|
| ------------------------------------------
*/
options("h,help", "show help information");
options(",plates", "",
"a folder contains both forward data and inverse data in the "
"separated subfolders");
options(",svm", easypr::kDefaultSvmPath, "the svm model file");
options("t,test", "run tests in --plates");
}
options.add_subroutine("ann", "ann operation").make_usage("Usages:");
{
/* ------------------------------------------
| ANN_MLP Training operations
| ------------------------------------------
|
| $ demo ann --zh-chars=zhchars/ --en-chars=enchars/ --ann=save/to/ann.xml
|
| ------------------------------------------
*/
options("h,help", "show help information");
options(",chars", "",
"the folder contains character sub-folders, with each folder"
"named by label defined in include/easypr/config.h");
options(",ann", easypr::kDefaultAnnPath,
"the ann model file you want to save");
options("t,test", "run test in --chars");
}
options.add_subroutine("locate", "locate plates in an image")
.make_usage("Usage:");
{
/* ------------------------------------------
| Plate locating operations
| ------------------------------------------
|
| $ demo locate -f file
|
| ------------------------------------------
*/
options("h,help", "show help information");
options("f,file", "",
"the target picture which contains one or more plates");
}
options.add_subroutine(
"judge", "determine whether an image block is the license plate")
.make_usage("Usage:");
{
/* ------------------------------------------
| Plate judge operations
| ------------------------------------------
|
| $ demo judge -f file --svm model/svm.xml
|
| ------------------------------------------
*/
options("h,help", "show help information");
options("f,file", "the target image block");
options(",svm", easypr::kDefaultSvmPath, "the svm model file");
}
options.add_subroutine("recognize", "plate recognition").make_usage("Usage:");
{
/* ------------------------------------------
| Plate recognize operations
| ------------------------------------------
|
| $ demo recognize -p file --svm model/svm.xml
| --ann model/ann.xml
| $ demo recognize -pb dir/ --svm model/svm.xml
| --ann model/ann.xml
|
| ------------------------------------------
*/
options("h,help", "show help information");
options("p,path", "", "where is the target picture or target folder");
options("b,batch", "do batch recognition, if set, --path means a folder");
options("c,color", "returns the plate color, blue or yellow");
options(",svm", easypr::kDefaultSvmPath, "the svm model file");
options(",ann", easypr::kDefaultAnnPath, "the ann model file");
}
auto parser = options.make_parser();
try {
parser->parse(argc, argv);
} catch (const std::exception &err) {
std::cout << err.what() << std::endl;
return;
}
auto subname = parser->get_subroutine_name();
program_options::select(subname)
.found("svm",
[&]() {
if (parser->has("help") || argc <= 2) {
std::cout << options("svm");
return;
}
easypr::SvmTrain svm(parser->get("plates")->c_str(),
parser->get("svm")->c_str());
if (parser->has("test")) {
svm.test();
} else {
svm.train();
}
})
.found("ann",
[&]() {
if (parser->has("help") || argc <= 2) {
std::cout << options("ann");
return;
}
assert(parser->has("chars"));
assert(parser->has("ann"));
easypr::AnnTrain ann(parser->get("chars")->c_str(),
parser->get("ann")->c_str());
if (parser->has("test")) {
ann.test();
} else {
ann.train();
}
})
.found("locate",
[&]() {
if (parser->has("help") || argc <= 2) {
std::cout << options("locate");
return;
}
if (parser->has("file")) {
easypr::api::plate_locate(parser->get("file")->val().c_str());
std::cout << "finished, results can be found in tmp/"
<< std::endl;
}
})
.found("judge",
[&]() {
if (parser->has("help") || argc <= 2) {
std::cout << options("judge");
std::cout << "Note that the input image's size should "
<< "be the same as the one you gived to svm train."
<< std::endl;
return;
}
if (parser->has("file")) {
assert(parser->has("file"));
assert(parser->has("svm"));
auto image = parser->get("file")->val();
auto svm = parser->get("svm")->val();
const char* true_or_false[2] = {"false", "true"};
std::cout << true_or_false[easypr::api::plate_judge(
image.c_str(), svm.c_str())]
<< std::endl;
}
})
.found("recognize",
[&]() {
if (parser->has("help") || argc <= 2) {
std::cout << options("recognize");
return;
}
if (parser->has("path")) {
if (parser->has("batch")) {
// batch testing
auto folder = parser->get("path")->val();
easypr::demo::Result result;
easypr::demo::accuracyTest(folder.c_str(), result);
} else {
// single testing
auto image = parser->get("path")->val();
if (parser->has("color")) {
// return plate color
const char* colors[2] = {"blue", "yellow"};
std::cout
<< colors[easypr::api::get_plate_color(image.c_str())]
<< std::endl;
} else {
// return strings
auto svm = parser->get("svm")->val();
auto ann = parser->get("ann")->val();
auto results = easypr::api::plate_recognize(
image.c_str(), svm.c_str(), ann.c_str());
for (auto s : results) {
std::cout << s << std::endl;
}
}
}
} else {
std::cout << "option 'file' cannot be empty." << std::endl;
}
})
.others([&]() {
// no case matched, print all commands.
std::cout << "There are several sub commands listed below, "
<< "choose one by typing:\n\n"
<< " " << easypr::utils::getFileName(argv[0])
<< " command [options]\n\n"
<< "The commands are:\n" << std::endl;
auto subs = options.get_subroutine_list();
for (auto sub : subs) {
fprintf(stdout, "%s %s\n", sub.first.c_str(), sub.second.c_str());
}
std::cout << std::endl;
});
}
int main(int argc, const char* argv[]) {
std::shared_ptr<easypr::Kv> kv(new easypr::Kv);
kv->load("resources/text/chinese_mapping");
if (argc > 1) {
// handle command line execution.
command_line_handler(argc, argv);
return 0;
}
bool isExit = false;
while (!isExit) {
easypr::Utils::print_file_lines("resources/text/main_menu");
std::cout << kv->get("make_a_choice") << ":";
int select = -1;
bool isRepeat = true;
while (isRepeat) {
std::cin >> select;
isRepeat = false;
switch (select) {
case 1:
easypr::demo::testMain();
break;
case 2:
easypr::demo::accuracyTestMain();
break;
case 3:
std::cout << "Run \"demo svm\" for more usage." << std::endl;
{
easypr::SvmTrain svm("tmp/svm", "tmp/svm.xml");
svm.train();
}
break;
case 4:
std::cout << "Run \"demo ann\" for more usage." << std::endl;
{
easypr::AnnTrain ann("tmp/ann", "tmp/ann.xml");
ann.train();
}
break;
case 5:
easypr::demo::trainChineseMain();
break;
case 6: {
//TODO: genenrate gray characters
easypr::demo::accuracyCharRecognizeTest("resources/image/tmp/plates_200k");
break;
}
case 7: {
easypr::Utils::print_file_lines("resources/text/thanks");
break;
}
case 8:
isExit = true;
break;
default:
std::cout << kv->get("input_error") << ":";
isRepeat = true;
break;
}
}
}
return 0;
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

EasyPR是一个中文的开源车牌识别系统,其目标是成为一个简单、高效、准确的车牌识别引擎。相比于其他的车牌识别系统,EasyPR有如下特点:* 它基于openCV这个开源库。这意味着你可以获取全部源代码,并且移植到java等平台。* 它能够识别中文。例如车牌为苏EUK722的图片,它可以准确地输出std:string类型的"苏EUK722"的结果。* 它的识别率较高。图片清晰情况下,车牌检测与字符识别可以达到80%以上的精度。
No labels
Apache-2.0
Use Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/java-ecosystem/EasyPR.git
git@gitee.com:java-ecosystem/EasyPR.git
java-ecosystem
EasyPR
EasyPR
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /