笔迹鉴别程序

考试的笔迹鉴别程序,分辨出不同人写的笔迹
This commit is contained in:
yanshui177
2017-05-17 16:50:37 +08:00
parent abe00d2e02
commit 962de04ffb
205 changed files with 17672 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
/* 程序名getFiles.c
功能:返回一个文件夹下的所有文件名
*/
#include<io.h>
#include <stdio.h>
#include<vector>
#include<iostream>
using namespace std;
#include <string.h>
void getFiles(string path, vector<string>& files ){
using namespace std;//引入整个名空间
//文件句柄
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);
}
}

View File

@@ -0,0 +1,38 @@
/* 程序名getFolders.c
功能:返回一个文件夹下的所有文件夹的名称
*/
#include<io.h>
#include <stdio.h>
#include<vector>
#include<iostream>
using namespace std;
#include <string.h>
int getFolders(string path, vector<string>& files )
{
using namespace std;//引入整个名空间
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
int i=0;
if((hFile = _findfirst(p.assign(path).append("/*").c_str(),&fileinfo)) != -1)
{
do
{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
{
files.push_back(p.assign(path).append("/").append(fileinfo.name) );
printf("文件夹:%s\n",files[i].c_str());
i++;
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
return 0;
}

View File

@@ -0,0 +1,65 @@
/* 程序名getFolders.c
功能:返回一个文件夹下的所有文件夹的名称
*/
#include<io.h>
#include <stdio.h>
#include<vector>
#include<iostream>
using namespace std;
#include <string.h>
int getFolders(string path, vector<string>& files )
{
using namespace std;//引入整个名空间
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
/*
hFile=_findfirst(p.assign(path).append("\\*").c_str(),&fileinfo); //第一次查找 to_search???
files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
if(-1==hFile)return -1; //当前文件夹下没有子文件
printf("%s\n",fileinfo.name); //打印出找到的文件的文件名
int i=0;
while(!_findnext(hFile,&fileinfo)) //循环查找其他符合的文件,知道找不到其他的为止
{
printf("%s\n",files[i].c_str());
i++;
}
_findclose(hFile); //别忘了关闭句柄
system("pause");
return 0;
*/
int i=0;
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
//{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
printf("文件夹:%s\n",files[i].c_str());
i++;
}
//}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
return 0;
}

View File

@@ -0,0 +1,114 @@
# Microsoft Developer Studio Project File - Name="handwriting" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=handwriting - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "handwriting.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "handwriting.mak" CFG="handwriting - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "handwriting - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "handwriting - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "handwriting - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "handwriting - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "handwriting - Win32 Release"
# Name "handwriting - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\getFiles.cpp
# End Source File
# Begin Source File
SOURCE=.\getFloders.cpp
# End Source File
# Begin Source File
SOURCE=.\searchDir.cpp
# End Source File
# Begin Source File
SOURCE=.\segmentation.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# 警告: 不能编辑或删除该工作区文件!
###############################################################################
Project: "handwriting"=.\handwriting.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Binary file not shown.

View File

@@ -0,0 +1,38 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: handwriting - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Users\闫帅帅\AppData\Local\Temp\RSP9995.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/handwriting.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"D:\CODE\HWCV\测试\获取图像文件\segmentation.cpp"
]
Creating command line "cl.exe @"C:\Users\闫帅帅\AppData\Local\Temp\RSP9995.tmp""
Creating temporary file "C:\Users\闫帅帅\AppData\Local\Temp\RSP9996.tmp" with contents
[
FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/handwriting.pdb" /debug /machine:I386 /out:"Debug/handwriting.exe" /pdbtype:sept
".\Debug\getFiles.obj"
".\Debug\getFloders.obj"
".\Debug\searchDir.obj"
".\Debug\segmentation.obj"
]
Creating command line "link.exe @"C:\Users\闫帅帅\AppData\Local\Temp\RSP9996.tmp""
<h3>Output Window</h3>
Compiling...
segmentation.cpp
D:\CODE\HWCV\测试\获取图像文件\segmentation.cpp(63) : warning C4508: 'main' : function should return a value; 'void' return type assumed
c:\program files\vc\vc98\include\vector(39) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
c:\program files\vc\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
Linking...
<h3>Results</h3>
handwriting.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@@ -0,0 +1,44 @@
/* 程序名getFiles.c
功能:返回一个文件夹下的所有文件名
*/
#include<io.h>
#include <stdio.h>
#include<vector>
#include<iostream>
#include <string.h>
#include <string>
using namespace std;
int searchDir( char *path, vector<string> &dir)
{
using namespace std;
struct _finddata_t fa;//创建找到的结构体
long handle;
int flag=0;
char temp[100]={0};
string path_temp=path;
// path_temp=path_temp.substr(0,path_temp.length()-1);
if((handle = _findfirst(strcat(path,"*"),&fa)) == -1L)//如果不是目录的话
return 0;
do//是目录,先执行循环
{
if( fa.attrib == _A_SUBDIR && ~strcmp(fa.name,".")&& ~strcmp(fa.name,".."))
{
strcat( temp, path_temp.c_str());
strcat( temp, fa.name);
if(flag++)
dir.push_back(temp);
else;
memset(temp,0,100);
}
}while(_findnext(handle,&fa) == 0); /* 成功找到时返回0*/
_findclose(handle);
return 0;
}

View File

@@ -0,0 +1,63 @@
/* 程序名segmentation.c
功能:总程序:读入图像文件,分析特征,输出效果
*/
//#include "stdafx.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
#include<io.h> //下面的5个用于读取文件夹下的所有文件名
#include<vector>
#include<iostream>
#include <string.h>
#include<windows.h>
#include<string.h>
using namespace std;
#ifdef WIN32 //屏蔽VC6对STL的一些不完全支持造成
#pragma warning (disable: 4514 4786)
#endif
/*-----------各种声明-----------------------*/
void getFiles(string path, vector<string>& files );//9、读取文件名下所有文件名
int getFolders(string path, vector<string>& files );//11、读取文件名下所有文件夹的名称
int searchDir(char* path, vector<string> &dir);//获取目录下一层的所有文件夹
int main()
{
char path[100] = "E:/xiangmu/Img/imgjiaobiao/";
vector<string> dir; //存储目录
int size_dir,num_dir;
char* fpname= "C:/Users/闫帅帅/Desktop/result2.txt";
char record[2400]={0};
FILE* fpzz=NULL;//需要注意
searchDir(path, dir);//获取filePath下的所有一级目录并存储到dir中
size_dir=dir.size(); //dir的大小就是学生的数量
//开始检测
//-------------------------------------------------------------//
for(num_dir=0;num_dir<size_dir;num_dir++)//对每一个学生目录进行循环
{
int i=0;
vector<string> files; //存储文件路径
getFiles(dir[num_dir].c_str(), files ); //遍历当前文件夹下的所有文件
int size=files.size();
cout<<"numdir: "<<num_dir<<" size: "<<size<<endl;
//开始对每一张图片进行处理
//------------------------------------------------------//
for (i = 0;i < size;i++) cout<<"\t"<<files[i].c_str()<<endl;
cout<<endl;
}
}