Add: CMakeLists.txt, support to compile on linux.

Add: headers of linux.
Fix: platform-dependent functions.
1.3
micooz 10 years ago
parent b947d37846
commit e8a958e049

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 2.6)
project (EasyPR)
list(APPEND CMAKE_CXX_FLAGS "-std=c++0x")
find_package(OpenCV REQUIRED)
aux_source_directory(./src SOURCE_FILES)
set(SOURCE_FILES
src/main.cpp
src/core/chars_identify.cpp
src/core/chars_recognise.cpp
src/core/chars_segment.cpp
src/core/features.cpp
src/core/plate_detect.cpp
src/core/plate_judge.cpp
src/core/plate_locate.cpp
src/core/plate_recognize.cpp
src/test/accuracy_test.cpp
src/test/test.cpp
src/train/ann_train.cpp
src/train/svm_train.cpp
src/util/deface.cpp
src/util/general_test_prepare.cpp
src/util/generate_gdts.cpp
src/util/learn_prepare.cpp
src/util/mc_data_prepare.cpp
src/util/util.cpp
)
add_executable(EasyPR ${SOURCE_FILES})
target_link_libraries(EasyPR ${OpenCV_LIBS})

@ -49,6 +49,32 @@ EasyPR是基于opencv2.4.8版本开发的2.4.8以上的版本应该可以兼
“蓝牌苏EUK722”
### 编译(Linux)
#### 依赖
* gcc 4.8 或以上
* cmake 2.6 或以上
* opencv 2.4.8 或以上
##### 编译opencv
此过程需要较长时间,请耐心等待。
```
$ cd opencv/
$ cmake .
$ make
$ make install
```
##### 编译EasyPR
```
$ cd EasyPR/
$ cmake .
$ make
```
### 安装

@ -7,10 +7,19 @@
#include "opencv2/nonfree/features2d.hpp"
#include "opencv/cvaux.h"
#if defined (WIN32) || defined (_WIN32)
#include <objbase.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#if defined (WIN32) || defined (_WIN32)
#include <io.h>
#elif defined (linux) || defined (__linux__)
#include <sys/io.h>
#endif
#include <iostream>
#include <assert.h>
#include <algorithm>
@ -21,4 +30,4 @@ using namespace std;
using namespace cv;
#endif
/* endif __PREP_H__ */
/* endif __PREP_H__ */

@ -5,6 +5,11 @@
//C++的获取文件夹函数
void getFiles(string path, vector<string>& files);
//Linux下的GetTickCount函数
#if defined (linux) || defined (__linux__)
double GetTickCount();
#endif
//C++的spilt函数
void SplitString(const string& s, vector<string>& v, const string& c);
@ -60,4 +65,4 @@ int deface();
int generate_gdts();
#endif
/* endif __UTIL_H__ */
/* endif __UTIL_H__ */

@ -5,11 +5,20 @@
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui.hpp"
#if defined (WIN32) || defined (_WIN32)
#include <windows.h>
#endif
#include <vector>
#include <iostream>
#include <cstdlib>
#if defined (WIN32) || defined (_WIN32)
#include <io.h>
#elif defined (linux) || defined (__linux__)
#include <sys/io.h>
#endif
#include <stdlib.h>
#include <stdio.h>
@ -223,10 +232,10 @@ void saveModel(int _predictsize, int _neurons)
cout << "Begin to saveModelChar predictSize:" << _predictsize
<< " neurons:" << _neurons << endl;
double start = GetTickCount();
annTrain(TrainingData, Classes, _neurons);
double end = GetTickCount();
cout << "GetTickCount:" << (end-start)/1000 << endl;
double start = GetTickCount();
annTrain(TrainingData, Classes, _neurons);
double end = GetTickCount();
cout << "GetTickCount:" << (end-start)/1000 << endl;
cout << "End the saveModelChar" << endl;

@ -5,7 +5,13 @@
#include <iostream>
#include <cstdlib>
#if defined (WIN32) || defined (_WIN32)
#include <io.h>
#elif defined (linux) || defined (__linux__)
#include <sys/io.h>
#endif
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cvaux.h>
@ -273,4 +279,4 @@ void changeFileName()
}
}
}
}

@ -1,40 +1,99 @@
#if defined (WIN32) || defined (_WIN32)
#include <windows.h>
#endif
#include <iostream>
#include <cstdlib>
#if defined (WIN32) || defined (_WIN32)
#include <io.h>
#elif defined (linux) || defined (__linux__)
#include <sys/io.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <time.h>
#include <cstring>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <vector>
using namespace std;
#if defined (WIN32) || defined (_WIN32)
void getFiles(string path, vector<string>& files)
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1)
{
do
{
//如果是目录,迭代之
//如果不是,加入列表
if((fileinfo.attrib & _A_SUBDIR))
{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
getFiles( p.assign(path).append("\\").append(fileinfo.name), files );
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1)
{
do
{
//如果是目录,迭代之
//如果不是,加入列表
if((fileinfo.attrib & _A_SUBDIR))
{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
getFiles( p.assign(path).append("\\").append(fileinfo.name), files );
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
#elif defined (linux) || defined (__linux__)
void getFiles(string path, vector<string>& files) {
DIR *dirp = opendir(path.c_str());
if (dirp) {
struct stat st;
struct dirent *dir;
char fullpath[512];
while ((dir = readdir(dirp)) != NULL) {
if (!strcmp(dir->d_name, ".") ||
!strcmp(dir->d_name, "..")) {
continue;
}
sprintf(fullpath, "%s/%s", path.c_str(), dir->d_name);
if (lstat(fullpath, &st) < 0) {
//perror("lstat");
continue;
}
if (S_ISDIR(st.st_mode)) {
getFiles(fullpath, files);
} else {
files.push_back(fullpath);
}
}
}
closedir(dirp);
}
double GetTickCount() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1e3 + ts.tv_nsec / 1e6);
}
#endif
//C++的spilt函数
void SplitString(const string& s, vector<string>& v, const string& c)
{

Loading…
Cancel
Save