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
/
src
/
util
/
util.cpp
EasyPR
/
src
/
util
/
util.cpp
util.cpp 7.13 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
#include "easypr/util/util.h"
#include <string>
#ifdef OS_WINDOWS
#include <windows.h>
#include <direct.h>
#include <io.h>
#define PATH_DELIMITER '\\'
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#elif defined(OS_LINUX) || defined(OS_UNIX)
#include <cstring>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#define PATH_DELIMITER '/'
#endif
#ifdef OS_UNIX
#include <sys/timeb.h>
#endif
#include <list>
#include <opencv2/highgui/highgui.hpp>
namespace easypr {
long Utils::getTimestamp() {
#ifdef OS_WINDOWS
return static_cast<long>(cv::getTickCount());
#endif
#ifdef OS_LINUX
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1e3 + ts.tv_nsec / 1e6);
#endif
#ifdef OS_UNIX
// there is no function provided by osx to get system tick count.
// but considering the purpose by using this function,
// we can simply return a millisecond since 1970年1月1日 to calc the time elapse.
struct timeb tb;
ftime(&tb);
return long(tb.time * 1e3 + tb.millitm);
#endif
}
std::string Utils::getFileName(const std::string &path,
const bool postfix /* = false */) {
if (!path.empty()) {
size_t last_slash = utils::get_last_slash(path);
size_t last_dot = path.find_last_of('.');
if (last_dot < last_slash || last_dot == std::string::npos) {
// not found the right dot of the postfix,
// return the file name directly
return path.substr(last_slash + 1);
} else {
// the path has a postfix
if (postfix) {
// return the file name including postfix
return path.substr(last_slash + 1);
}
// without postfix
return path.substr(last_slash + 1, last_dot - last_slash - 1);
}
}
return "";
}
std::vector<std::string> Utils::splitString(const std::string &str,
const char delimiter) {
std::vector<std::string> splited;
std::string s(str);
size_t pos;
while ((pos = s.find(delimiter)) != std::string::npos) {
std::string sec = s.substr(0, pos);
if (!sec.empty()) {
splited.push_back(s.substr(0, pos));
}
s = s.substr(pos + 1);
}
splited.push_back(s);
return splited;
}
std::vector<std::string> Utils::getFiles(const std::string &folder,
const bool all /* = true */) {
std::vector<std::string> files;
std::list<std::string> subfolders;
subfolders.push_back(folder);
#ifdef OS_WINDOWS
while (!subfolders.empty()) {
std::string current_folder(subfolders.back());
if (*(current_folder.end() - 1) != '/') {
current_folder.append("/*");
} else {
current_folder.append("*");
}
subfolders.pop_back();
struct _finddata_t file_info;
auto file_handler = _findfirst(current_folder.c_str(), &file_info);
while (file_handler != -1) {
if (all &&
(!strcmp(file_info.name, ".") || !strcmp(file_info.name, ".."))) {
if (_findnext(file_handler, &file_info) != 0) break;
continue;
}
if (file_info.attrib & _A_SUBDIR) {
// it's a sub folder
if (all) {
// will search sub folder
std::string folder(current_folder);
folder.pop_back();
folder.append(file_info.name);
subfolders.push_back(folder.c_str());
}
} else {
// it's a file
std::string file_path;
// current_folder.pop_back();
file_path.assign(current_folder.c_str()).pop_back();
file_path.append(file_info.name);
files.push_back(file_path);
}
if (_findnext(file_handler, &file_info) != 0) break;
} // while
_findclose(file_handler);
}
#elif defined(OS_LINUX) || defined(OS_UNIX)
while (!subfolders.empty()) {
std::string current_folder(subfolders.back());
if (*(current_folder.end() - 1) != '/') {
current_folder.push_back('/');
}
DIR* pdir = opendir(current_folder.c_str());
subfolders.pop_back();
if (!pdir) {
continue;
}
dirent* dir = NULL;
while ((dir = readdir(pdir)) != NULL) {
// iterates the current folder, search file & sub folder
struct stat st;
if (all && (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))) {
// must ignore . & ..
continue;
}
if (!strcmp(dir->d_name, ".DS_Store")) {
// in OSX, 'finder' will create .DS_Store
continue;
}
std::string file_path;
file_path.append(current_folder.c_str());
file_path.append(dir->d_name);
if (lstat(file_path.c_str(), &st) < 0) {
// perror("lstat");
continue;
}
if (S_ISDIR(st.st_mode)) {
// it's a sub folder
if (all) {
// will search sub folder
std::string subfolder(current_folder);
subfolder.append(dir->d_name);
subfolders.push_back(subfolder.c_str());
}
} else {
// it's a file
files.push_back(file_path);
}
} // while
closedir(pdir);
}
#endif
return files;
}
bool Utils::mkdir(const std::string folder) {
std::string folder_builder;
std::string sub;
sub.reserve(folder.size());
for (auto it = folder.begin(); it != folder.end(); ++it) {
const char c = *it;
sub.push_back(c);
if (c == PATH_DELIMITER || it == folder.end() - 1) {
folder_builder.append(sub);
#ifdef OS_WINDOWS
if (0 != ::_access(folder_builder.c_str(), 0)) {
#else
if (0 != ::access(folder_builder.c_str(), 0)) {
#endif
// this folder not exist
#ifdef OS_WINDOWS
if (0 != ::_mkdir(folder_builder.c_str())) {
#else
if (0 != ::mkdir(folder_builder.c_str(), S_IRWXU)) {
#endif
// create failed
return false;
}
}
sub.clear();
}
}
return true;
}
bool Utils::imwrite(const std::string &file, const cv::Mat &image) {
auto folder = file.substr(0, utils::get_last_slash(file));
Utils::mkdir(folder);
return cv::imwrite(file, image);
}
#ifdef OS_WINDOWS
std::string Utils::utf8_to_gbk(const char* utf8) {
int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
wchar_t* wszGBK = new wchar_t[len + 1];
memset(wszGBK, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wszGBK, len);
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
char* szGBK = new char[len + 1];
memset(szGBK, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
std::string strTemp(szGBK);
if (wszGBK)
delete[] wszGBK;
if (szGBK)
delete[] szGBK;
return strTemp;
}
#endif
std::size_t Utils::get_last_slash(const std::string &path) {
#ifdef OS_WINDOWS
size_t last_slash_1 = path.find_last_of("\\");
size_t last_slash_2 = path.find_last_of("/");
size_t last_slash;
if (last_slash_1 != std::string::npos && last_slash_2 != std::string::npos) {
// C:/path\\to/file.postfix
last_slash = std::max(last_slash_1, last_slash_2);
} else {
// C:\\path\\to\\file.postfix
// C:/path/to/file.postfix
last_slash =
(last_slash_1 == std::string::npos) ? last_slash_2 : last_slash_1;
}
#else
size_t last_slash = path.find_last_of('/');
#endif
return last_slash;
}
} // namespace easypr
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 によって変換されたページ (->オリジナル) /