笔迹鉴别程序
考试的笔迹鉴别程序,分辨出不同人写的笔迹
This commit is contained in:
216
.gitignore
vendored
Normal file
216
.gitignore
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
|
||||
#################
|
||||
## Visual Studio
|
||||
#################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
#############
|
||||
## Windows detritus
|
||||
#############
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
|
||||
|
||||
#############
|
||||
## Python
|
||||
#############
|
||||
|
||||
*.py[cod]
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist/
|
||||
build/
|
||||
eggs/
|
||||
parts/
|
||||
var/
|
||||
sdist/
|
||||
develop-eggs/
|
||||
.installed.cfg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
|
||||
#Translations
|
||||
*.mo
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
||||
11
README.md
Normal file
11
README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# HWCV
|
||||
手写体笔迹鉴别程序,包含几个不同的部分
|
||||
|
||||
首先,是C语言vs2013写的主程序,生成名为HWCV-exe.exe的可执行文件(无界面运行),
|
||||
其次,是C语言VC6.0写成的服务程序,常驻内存,名为:serve.exe
|
||||
最后,是一个测试程序,all-test.exe,测试所有的笔迹图像是否为同一个人写的,并输出鉴定日志到文件log.csv
|
||||
|
||||
注:这是个商业化应用的0.1版本,程序需要使用到的环境为:
|
||||
windows server 2008R2
|
||||
oracle client32
|
||||
opencv2.4.13
|
||||
65
测试/服务器测试/wei服务-监控文件夹/Check.cpp
Normal file
65
测试/服务器测试/wei服务-监控文件夹/Check.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "Check.h"
|
||||
|
||||
char* GetTime();
|
||||
|
||||
/*功能:检查当前木有有无文件,若有,提取文件名,并删除此文件
|
||||
@变量 path 检查文件位置
|
||||
@返回值 返回检测到的变量向量
|
||||
*/
|
||||
int CheckFile(char* 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))
|
||||
{
|
||||
}
|
||||
else //如果不是,加入列表
|
||||
{
|
||||
//files.push_back(p.assign(path).append("/").append(fileinfo.name));
|
||||
files.push_back(fileinfo.name);
|
||||
//remove(p.assign(path).append("\\").append(fileinfo.name).c_str());
|
||||
remove(p.assign(path).append(fileinfo.name).c_str());
|
||||
}
|
||||
} while (_findnext(hFile, &fileinfo) == 0);
|
||||
|
||||
_findclose(hFile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
功能:泻入文件日志
|
||||
*/
|
||||
int WriteToLog(char* str)
|
||||
{
|
||||
FILE* log;
|
||||
log = fopen(LOGFILE, "a+");
|
||||
if (log == NULL) return -1;
|
||||
fprintf(log, "%s ", str);
|
||||
fclose(log);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime()
|
||||
{
|
||||
time( <ime );
|
||||
srcTime = ctime( <ime );
|
||||
strncpy(timeNow, srcTime, strlen(srcTime)-1); //不拷贝换行
|
||||
timeNow[strlen(srcTime)-1] = '\0'; //加结束符'\0'
|
||||
|
||||
return timeNow;
|
||||
}
|
||||
41
测试/服务器测试/wei服务-监控文件夹/Check.h
Normal file
41
测试/服务器测试/wei服务-监控文件夹/Check.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
/*时间获取函数u*/
|
||||
#define LOGFILE "D:\\HWCV\\memstatus.txt" //日志存储位置
|
||||
|
||||
extern time_t ltime;
|
||||
extern char *srcTime;
|
||||
extern char timeNow[22];
|
||||
extern char msg[100];
|
||||
|
||||
/*功能:写入日志
|
||||
@变量 str 写入内容
|
||||
@返回值 固定
|
||||
*/
|
||||
int WriteToLog(char* str);
|
||||
|
||||
|
||||
/**
|
||||
功能:获取并返回当前时间
|
||||
*/
|
||||
char* GetTime();
|
||||
|
||||
|
||||
/*功能:检查当前木有有无文件,若有,提取文件名,并删除此文件
|
||||
@变量 path 检查文件位置
|
||||
@变量 files 获取到的文件名称
|
||||
@返回值 返回检测到的变量向量
|
||||
*/
|
||||
int CheckFile(char* path, vector<string>& files);
|
||||
|
||||
|
||||
BIN
测试/服务器测试/wei服务-监控文件夹/HWCV-exe.exe
Normal file
BIN
测试/服务器测试/wei服务-监控文件夹/HWCV-exe.exe
Normal file
Binary file not shown.
112
测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsp
Normal file
112
测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsp
Normal file
@@ -0,0 +1,112 @@
|
||||
# Microsoft Developer Studio Project File - Name="HWCVServe" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=HWCVServe - 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 "HWCVServe.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 "HWCVServe.mak" CFG="HWCVServe - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "HWCVServe - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "HWCVServe - 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)" == "HWCVServe - 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 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 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
|
||||
|
||||
!ELSEIF "$(CFG)" == "HWCVServe - 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 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 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
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "HWCVServe - Win32 Release"
|
||||
# Name "HWCVServe - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Check.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Check.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.h
|
||||
# End Source File
|
||||
# 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
|
||||
29
测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsw
Normal file
29
测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# 警告: 不能编辑或删除该工作区文件!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "HWCVServe"=".\HWCVServe.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
测试/服务器测试/wei服务-监控文件夹/HWCVServe.opt
Normal file
BIN
测试/服务器测试/wei服务-监控文件夹/HWCVServe.opt
Normal file
Binary file not shown.
29
测试/服务器测试/wei服务-监控文件夹/HWCVServe.plg
Normal file
29
测试/服务器测试/wei服务-监控文件夹/HWCVServe.plg
Normal file
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: HWCVServe - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\Users\闫帅帅\AppData\Local\Temp\RSP19.tmp" with contents
|
||||
[
|
||||
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/HWCVServe.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
|
||||
"E:\闫帅帅\GitHub\HWCV\测试\服务器测试\wei服务-监控文件夹\Main.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @"C:\Users\闫帅帅\AppData\Local\Temp\RSP19.tmp""
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
Main.cpp
|
||||
e:\闫帅帅\github\hwcv\测试\服务器测试\wei服务-监控文件夹\main.cpp(63) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
|
||||
e:\闫帅帅\github\hwcv\测试\服务器测试\wei服务-监控文件夹\main.cpp(63) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
|
||||
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
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
Main.obj - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
63
测试/服务器测试/wei服务-监控文件夹/Main.cpp
Normal file
63
测试/服务器测试/wei服务-监控文件夹/Main.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "Main.h"
|
||||
#include "Check.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define SLEEP_TIME 1000 //2000毫秒刷新一次
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
//监控..\Check\路径下有没有新文件
|
||||
char * path = "D:\\HWCV\\Check\\";
|
||||
// char * path = "D:\\2017.2.28\\BJJB0702\\BJJB0702\\check\\";
|
||||
vector<string> files;
|
||||
WriteToLog(GetTime());
|
||||
WriteToLog("--开始运行服务--\n");
|
||||
|
||||
while(true)
|
||||
{
|
||||
|
||||
//检查有没有新的文件,若有,则都在vector files中存储
|
||||
CheckFile(path, files);
|
||||
|
||||
|
||||
for (int iter = 0; iter < files.size();iter++)
|
||||
{
|
||||
// string cmd="D:/HWCV/config/HWCV-exe ";
|
||||
// cmd += files[iter];
|
||||
|
||||
// WinExec((char*)cmd.c_str(),SW_HIDE);
|
||||
string EE = files[iter];
|
||||
|
||||
try
|
||||
{
|
||||
ShellExecute(NULL,"open",
|
||||
"HWCV-exe.exe",
|
||||
(char*)files[iter].c_str(),
|
||||
NULL,
|
||||
SW_SHOWNORMAL);
|
||||
// EE += " 可以正常运行\n";
|
||||
// WriteToLog((char*)EE.c_str());
|
||||
|
||||
Sleep(SLEEP_TIME);
|
||||
}
|
||||
catch(void)
|
||||
{
|
||||
EE += " 错误\n";
|
||||
WriteToLog((char*)EE.c_str());
|
||||
Sleep(SLEEP_TIME);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
files.clear();
|
||||
|
||||
Sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
WriteToLog(GetTime());
|
||||
WriteToLog("--结束服务--\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
20
测试/服务器测试/wei服务-监控文件夹/Main.h
Normal file
20
测试/服务器测试/wei服务-监控文件夹/Main.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#pragma comment(lib, "Advapi32")
|
||||
|
||||
#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//没有界面运行
|
||||
|
||||
using namespace std;
|
||||
/*定义全局变量*/
|
||||
|
||||
|
||||
/*时间获取函数u*/
|
||||
time_t ltime;
|
||||
char *srcTime=NULL;
|
||||
char timeNow[22]={0};
|
||||
char msg[100]={0};
|
||||
1
测试/服务器测试/输出文件/readme.txt
Normal file
1
测试/服务器测试/输出文件/readme.txt
Normal file
@@ -0,0 +1 @@
|
||||
查询数据库,并向文件夹“D:/HWCV/Check/”写入文件,文件名称为待检测考生的考号
|
||||
123
测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.cpp
Normal file
123
测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
实现文件:DBop.cpp 数据库操作实现文件
|
||||
*/
|
||||
#include "DBop.h"
|
||||
|
||||
/*本地的全局变量*/
|
||||
|
||||
_ConnectionPtr p_conn; /*全局变量 连接对象*/
|
||||
_RecordsetPtr p_recordset; /*全局变量 记录集对象*/
|
||||
_CommandPtr p_cmd; /*全局变量 操作集对象*/
|
||||
string str_conn; /*全局变量 连接字符串设置*/
|
||||
|
||||
|
||||
/**
|
||||
功能: 查询所有学生的学号,将所有的指定位置的数据库信息(学号)全部存储在名为stu的vector<string>型的变量中
|
||||
|
||||
@变量 stu 学生学号存储
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbStu(vector<string>& stu)
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
//连接字串设置 //因为strConn是全局变量,因此仅仅初始化一次
|
||||
str_conn = "Provider=OraOLEDB.Oracle";
|
||||
str_conn += ";Persist Security Info = true";
|
||||
str_conn += ";User ID = "; //==================//
|
||||
str_conn += userName; //===仅初始化一次===//
|
||||
str_conn += ";Password="; //==================//
|
||||
str_conn += password;
|
||||
str_conn += ";Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)";
|
||||
str_conn += "(HOST=";
|
||||
str_conn += hostName;
|
||||
str_conn += ")(PORT=1521))(CONNECT_DATA=";
|
||||
str_conn += "(SERVICE_NAME=";
|
||||
str_conn += dBName;
|
||||
str_conn += ")))";
|
||||
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
//连接数据库,并执行sql查询语句 【必须要用try catch捕获异常】
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
p_cmd.CreateInstance("ADODB.Command");
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
|
||||
p_cmd->ActiveConnection = p_conn;
|
||||
|
||||
//SELECT KS_ZKZ FROM ZK.V_BYSQ_BJSH_JQ_KS
|
||||
//SELECT DISTINCT(KS_ZKZ2) FROM ZK.T_BYSQ_KS_KC WHERE KSSJ BETWEEN '200907' AND '201510'
|
||||
//SELECT * FROM ZK.T_BYSQ_KS_KC WHERE (SUBSTR(KS_ZKZ2,1,2) = '02' OR SUBSTR(KS_ZKZ2,1,2) = '03')
|
||||
//SELECT KS_ZKZ2 FROM ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' AND (SUBSTR(KS_ZKZ2,1,2) = '02') AND BJSH_JG_JQ IS NULL GROUP BY KS_ZKZ2 HAVING COUNT(KS_ZKZ2)>1
|
||||
/*HRESULT hr1 = pRecordset->Open("SELECT KS_ZKZ FROM ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' AND (SUBSTR(KS_ZKZ2,1,2) = '02') AND BJSH_JG_JQ IS NULL GROUP BY KS_ZKZ HAVING COUNT(KS_ZKZ)>1",*/
|
||||
|
||||
|
||||
/*构造查询语句*/
|
||||
int zong_flag = g_db_qurry_zone.length();
|
||||
int num_flag = g_db_qurry_stu_num.length();
|
||||
int date_flag = g_db_qurry_start.length();
|
||||
|
||||
string str_qurry = "SELECT KS_ZKZ FROM YANNSY.T_BYSQ_KS_KC WHERE KSSJ between ";
|
||||
str_qurry += g_db_qurry_start;
|
||||
str_qurry += " and ";
|
||||
str_qurry += g_db_qurry_end;
|
||||
|
||||
// cout<<str_qurry.c_str()<<endl;
|
||||
if (num_flag - 1)//长度大于1,就是需要查询学号
|
||||
{
|
||||
str_qurry += "AND KS_ZKZ = ";
|
||||
str_qurry += g_db_qurry_stu_num;
|
||||
}
|
||||
else//不需要查询单个学号才会有区域的作用范围
|
||||
{
|
||||
if ((zong_flag - 1))//长度大于1,就是需要查询区域,且查询时间
|
||||
{
|
||||
str_qurry += " AND(SUBSTR(KS_ZKZ2, 1, 2) = ";
|
||||
str_qurry += g_db_qurry_zone;
|
||||
str_qurry += ")";
|
||||
}
|
||||
}
|
||||
if (g_db_qurry_all)
|
||||
{
|
||||
str_qurry += " AND BJSH_JG_JQ IS NULL";
|
||||
}
|
||||
str_qurry += " GROUP BY KS_ZKZ HAVING COUNT(KS_ZKZ)>1";
|
||||
_variant_t _vstr_qurry(str_qurry.c_str());/* 转换string为_variant_t */
|
||||
|
||||
|
||||
|
||||
/*查询*/
|
||||
HRESULT hr1 = p_recordset->Open(_vstr_qurry,
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
if (!(SUCCEEDED(hr1))){ exit(-1); }//读取不成功,直接退出程序
|
||||
|
||||
int count_exit = 10;
|
||||
do
|
||||
{//读取成功,将每一行存到vector的stu末尾
|
||||
stu.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ"))->GetValue()));
|
||||
p_recordset->MoveNext();//移到下一条
|
||||
} while (!p_recordset->EndOfFile && count_exit--);//条件是没有到所有记录的末尾
|
||||
}
|
||||
catch (_com_error e){
|
||||
cout << "<提取学号(数据库):>查询失败--" << endl;
|
||||
cout<<e.Error()<<" "<<e.ErrorMessage()<<" "<<e.ErrorInfo()<<endl;
|
||||
}
|
||||
/*=================================================================================================*/
|
||||
|
||||
//3、关闭查询====//执行读取完毕后要关闭连接
|
||||
try { ::CoUninitialize(); }
|
||||
catch (_com_error e){ /*cout << "<提取学号:关闭失败-->" << e.ErrorInfo() << endl;*/ }
|
||||
|
||||
cout<<"查询完毕"<<endl;
|
||||
return 1;
|
||||
}
|
||||
58
测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.h
Normal file
58
测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
头文件:DBop.h 数据库操作头文件
|
||||
*/
|
||||
#pragma once
|
||||
#import "msado15.dll" no_namespace rename("EOF","EndOfFile")
|
||||
|
||||
//#import "C:/Program Files/Common Files/System/ado/msado15.dll" no_namespace rename("EOF","EndOfFile")
|
||||
/*#if defined(ADO2_OLD)
|
||||
#pragma message( "Using ADO2 TLB" )
|
||||
#import <msado20.tlb> no_namespace rename("EOF", "adoEOF")
|
||||
#else #pragma message( "Using Latest ADO" )
|
||||
#import <msado15.dll> no_namespace rename("EOF", "adoEOF")
|
||||
#endif
|
||||
*/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
|
||||
/*全局变量*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
extern FILE *g_log_fpzz; /*全局变量 程序日志专用文件句柄*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
/*****************************************函数原型*************************************/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
功能: 查询所有学生的学号,将所有的指定位置的数
|
||||
据库信息(学号)全部存储在名为stu的vector<string>型
|
||||
的变量中
|
||||
|
||||
@变量 stu 学生学号存储
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbStu(vector<string>& stu);
|
||||
|
||||
|
||||
|
||||
int WriteToLog(char* str);
|
||||
8
测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.cpp
Normal file
8
测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// HWCV.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
24
测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.h
Normal file
24
测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
#define AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
// Insert your headers here
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
54
测试/服务器测试/输出文件/输出待检测检测文件 source/main.cpp
Normal file
54
测试/服务器测试/输出文件/输出待检测检测文件 source/main.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
主函数文件:segmentation.cpp 主函数的实现文件
|
||||
*/
|
||||
#include "main.h"
|
||||
//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//没有界面运行
|
||||
|
||||
/*主函数*/
|
||||
char *adr="D:/process.csv";
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
|
||||
// cout<<"开始鉴定"<<fpname1<<endl;
|
||||
//char *fpname1 = "010209400748";
|
||||
/*变量定义*/
|
||||
cout<<"1"<<endl;
|
||||
vector<string> stuNum;
|
||||
|
||||
//读取配置文件,并配置各项参数
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
strcat(g_log_rec, GetTime());
|
||||
if (!ReadConfig("D:/HWCV/config/configure.cfg"))
|
||||
{
|
||||
cout<<"!ReadConfig"<<endl;
|
||||
strcat(g_log_rec, ",config failed!\n");
|
||||
SaveLog(g_log_rec, adr, "a");
|
||||
|
||||
return 0;
|
||||
}
|
||||
cout<<"ReadConfig success"<<endl;
|
||||
|
||||
//查询数据库
|
||||
cout<<"2"<<endl;
|
||||
DbStu(stuNum);
|
||||
|
||||
//生成路径();
|
||||
FILE *fp;
|
||||
string name="D:/HWCV/Check/";
|
||||
cout<<"搜索到的数量:"<<stuNum.size()<<endl;
|
||||
for(int i=0; i<stuNum.size();i++)
|
||||
{
|
||||
string temp=name;
|
||||
temp+=stuNum[i];
|
||||
fp=fopen((char*)temp.c_str(),"w+");
|
||||
fclose(fp);
|
||||
fp=NULL;
|
||||
|
||||
system("pause");
|
||||
}
|
||||
|
||||
/*返回值*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
62
测试/服务器测试/输出文件/输出待检测检测文件 source/main.h
Normal file
62
测试/服务器测试/输出文件/输出待检测检测文件 source/main.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
头文件:segmentation.h 主函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#ifdef WIN32 //屏蔽VC6对STL的一些不完全支持造成
|
||||
#pragma warning (disable: 4514 4786)
|
||||
#endif
|
||||
#include "StdAfx.h"
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*定义全局变量*/
|
||||
|
||||
int g_bi_threshold = 230; /* 全局变量 二值化阈值*/
|
||||
double g_std_kesa[50][50]; /* 全局变量 标准差数组*/
|
||||
float g_doubt_threshold = 0.12; /* 全局变量 作弊嫌疑阈值*/
|
||||
string g_dir = "Y:/"; /* 全局变量 总路径的目录*/
|
||||
int g_cheat_num_threshold = 0; /* 全局变量 默认作弊阈值*/
|
||||
int g_conti = 1; /* 全局变量 默认作弊比较的图片*/
|
||||
|
||||
int g_all_img_num = 0; /* 全局变量 已鉴定的全部图片数量*/
|
||||
int g_doubt_img_num = 0; /* 全局变量 已鉴定怀疑的图片数量*/
|
||||
int g_all_stu_num = 0; /* 全局变量 已鉴定的全部学生数量*/
|
||||
int g_doubt_stu_num = 0; /* 全局变量 已鉴定怀疑的学生数量*/
|
||||
|
||||
/*
|
||||
string g_db_hostName = "192.168.200.97"; //全局变量 服务器ip或名称
|
||||
string g_db_dBName = "purple"; //全局变量 服务器ODBC数据源
|
||||
string g_db_userName = "BJSH"; //全局变量 服务器用户名
|
||||
string g_db_password = "bjshadmin"; //全局变量 服务器密码
|
||||
*/
|
||||
|
||||
string g_db_hostName = "localhost"; //全局变量 服务器ip或名称
|
||||
string g_db_dBName = "orcl123"; //全局变量 服务器ODBC数据源
|
||||
string g_db_userName = "yannsy"; //全局变量 服务器用户名
|
||||
string g_db_password = "123456"; //全局变量 服务器密码
|
||||
|
||||
|
||||
string g_db_qurry_start = "200906"; /*全局变量 数据库查询_开始日期*/
|
||||
string g_db_qurry_end = "201610"; /*全局变量 数据库查询_结束日期*/
|
||||
string g_db_qurry_zone = "0"; /*全局变量 数据库查询_特定区域*/
|
||||
string g_db_qurry_stu_num = "0"; /*全局变量 数据库查询_特定考号*/
|
||||
bool g_db_qurry_all = true; /*全局变量 数据库查询_查询全部标记*/
|
||||
string g_db_hoster_zk = "ZK"; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
|
||||
|
||||
bool g_output_cmd_config = false; /*全局变量 输出参数控制*/
|
||||
bool g_output_txt_config = false; /*全局变量 输出中间文件选项*/
|
||||
char g_log_adr[50] = "D:/HWCV/log_ori.txt"; /*全局变量 程序日志存储地址*/
|
||||
char g_log_rec[500] = { 0 }; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 输出txt结果文件*/
|
||||
/*全局变量 输出txt结果文件地址*/
|
||||
|
||||
|
||||
|
||||
time_t g_ltime;
|
||||
char *g_srcTime=NULL;
|
||||
char g_timeNow[32]={0};
|
||||
char g_msg[100]={0};
|
||||
int g_stu_sus;
|
||||
177
测试/服务器测试/输出文件/输出待检测检测文件 source/path.cpp
Normal file
177
测试/服务器测试/输出文件/输出待检测检测文件 source/path.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
实现文件:path.cpp 路径操作实现文件
|
||||
*/
|
||||
#include "path.h"
|
||||
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime()
|
||||
{
|
||||
time(&g_ltime);
|
||||
g_srcTime = ctime(&g_ltime);
|
||||
strncpy(g_timeNow, g_srcTime, strlen(g_srcTime) - 1); //不拷贝换行
|
||||
g_timeNow[strlen(g_srcTime) - 1] = '\0'; //加结束符'\0'
|
||||
|
||||
return g_timeNow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename)
|
||||
{
|
||||
ifstream file(filename);
|
||||
|
||||
if (!file)/*"配置文件不存在!"*/
|
||||
{
|
||||
/*写入时间*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// cout<<"read"<<endl;
|
||||
|
||||
strcat(g_log_rec, "--ERR:配置文件不存在!");
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout<<"1.1"<<endl;
|
||||
/*步骤:开始读取信息*/
|
||||
/*仅用作过滤字符*/
|
||||
string temp;
|
||||
file >> temp >> temp;
|
||||
/*---此行6个,参考配置信息:图片对比参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >>temp;
|
||||
file >> g_dir >> temp >> temp >> temp;
|
||||
string g_log_adr_t;
|
||||
file >> g_log_adr_t >> temp;
|
||||
|
||||
memset(g_log_adr, 0, sizeof(g_log_adr));
|
||||
strcpy(g_log_adr, (char*)g_log_adr_t.c_str());
|
||||
cout<<"1.2"<<endl;
|
||||
|
||||
//if (g_bi_threshold < 0 || g_bi_threshold >255)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// strcat(g_log_rec, "--MSG:配置参数有误-笔迹图像对比参数!");
|
||||
// strcat(g_log_rec, g_dir.c_str());
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
/*---此行6个,参考配置信息:网络配置参数*/
|
||||
file >> temp >> temp >> g_db_hostName >> temp >> g_db_dBName >> temp >> g_db_userName >> temp >> g_db_password >> temp >> g_db_hoster_zk >> temp;
|
||||
|
||||
cout<<"1.3"<<endl;
|
||||
///*检验参数*/
|
||||
////if (strcmp(g_db_hostName.c_str(), "") || g_bi_threshold >255 || g_bi_threshold < 1)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--MSG:-网络配置参数!");
|
||||
// strcat(g_log_rec, g_db_password.c_str());
|
||||
// strcat(g_log_rec, "\n");
|
||||
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
/*---此行5个,参考配置信息:控制参数*/
|
||||
//备用
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-控制参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/*---此行5个,参考配置信息:数据库查询参数*/
|
||||
file >> temp >> temp >> g_db_qurry_start >> temp >> g_db_qurry_end >> temp >> g_db_qurry_zone >> temp >> g_db_qurry_stu_num >> temp >> g_db_qurry_all >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-数据库查询参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//if (g_doubt_threshold < 0.01)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//if (g_conti < 0 || g_conti > 10 || g_conti == NULL)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!\n\n");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
file.close();/*关闭文件句柄*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *txt, string txt_file_path, char *type)
|
||||
{
|
||||
FILE* fpzz = fopen(txt_file_path.c_str(), type); //创建文件
|
||||
if (!fpzz) return 0;
|
||||
//要返回错误代码
|
||||
fprintf(fpzz, txt); //从控制台中读入并在文本输出
|
||||
fclose(fpzz);
|
||||
fpzz = NULL;//需要指向空,否则会指向原打开文件地址
|
||||
|
||||
return 1;
|
||||
}
|
||||
69
测试/服务器测试/输出文件/输出待检测检测文件 source/path.h
Normal file
69
测试/服务器测试/输出文件/输出待检测检测文件 source/path.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
头文件:path.h 与路径相关操作的函数头文件以及函数原型
|
||||
*/
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cv.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
extern int g_bi_threshold; /*全局变量 二值化阈值*/
|
||||
extern double g_std_kesa[50][50]; /*全局变量 标准差数组*/
|
||||
extern float g_doubt_threshold; /*全局变量 作弊嫌疑阈值*/
|
||||
extern string g_dir; /*全局变量 总路径的目录*/
|
||||
extern int g_conti; /*全局变量 比较标准*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 待定*/
|
||||
/*全局变量 待定*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk;
|
||||
|
||||
|
||||
|
||||
extern time_t g_ltime;
|
||||
extern char *g_srcTime;
|
||||
extern char g_timeNow[32];
|
||||
extern char g_msg[100];
|
||||
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime();
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename);
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *record, string txt_file_path, char *type);
|
||||
128
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsp
Normal file
128
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsp
Normal file
@@ -0,0 +1,128 @@
|
||||
# Microsoft Developer Studio Project File - Name="test_all" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=test_all - 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 "test_all.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 "test_all.mak" CFG="test_all - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "test_all - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "test_all - 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)" == "test_all - 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 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 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
|
||||
|
||||
!ELSEIF "$(CFG)" == "test_all - 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 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 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
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "test_all - Win32 Release"
|
||||
# Name "test_all - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DBop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\path.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DBop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\path.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# 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
|
||||
29
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsw
Normal file
29
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# 警告: 不能编辑或删除该工作区文件!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "test_all"=".\test_all.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.opt
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.opt
Normal file
Binary file not shown.
16
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.plg
Normal file
16
测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.plg
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: test_all - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
test_all.exe - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
119
测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.cpp
Normal file
119
测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
实现文件:DBop.cpp 数据库操作实现文件
|
||||
*/
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
|
||||
/*本地的全局变量*/
|
||||
|
||||
_ConnectionPtr p_conn; /*全局变量 连接对象*/
|
||||
_RecordsetPtr p_recordset; /*全局变量 记录集对象*/
|
||||
_CommandPtr p_cmd; /*全局变量 操作集对象*/
|
||||
string str_conn; /*全局变量 连接字符串设置*/
|
||||
|
||||
|
||||
/**
|
||||
功能: 查询所有学生的学号,将所有的指定位置的数据库信息(学号)全部存储在名为stu的vector<string>型的变量中
|
||||
|
||||
@变量 stu 学生学号存储
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbStu(vector<string>& stu)
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
cout<<g_db_userName.c_str()<<endl;
|
||||
cout<<g_db_password.c_str()<<endl;
|
||||
cout<<g_db_hostName.c_str()<<endl;
|
||||
cout<<g_db_dBName.c_str()<<endl;
|
||||
|
||||
|
||||
//连接字串设置 //因为strConn是全局变量,因此仅仅初始化一次
|
||||
str_conn = "Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = ";
|
||||
str_conn += userName; //===仅初始化一次===//
|
||||
str_conn += ";Password="; //==================//
|
||||
str_conn += password;
|
||||
str_conn += ";Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=";
|
||||
str_conn += hostName;
|
||||
str_conn += ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=";
|
||||
str_conn += dBName;
|
||||
str_conn += ")))";
|
||||
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
//连接数据库,并执行sql查询语句 【必须要用try catch捕获异常】
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
p_cmd.CreateInstance("ADODB.Command");
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
|
||||
p_cmd->ActiveConnection = p_conn;
|
||||
|
||||
//SELECT KS_ZKZ FROM ZK.V_BYSQ_BJSH_JQ_KS
|
||||
//SELECT DISTINCT(KS_ZKZ2) FROM ZK.T_BYSQ_KS_KC WHERE KSSJ BETWEEN '200907' AND '201510'
|
||||
//SELECT * FROM ZK.T_BYSQ_KS_KC WHERE (SUBSTR(KS_ZKZ2,1,2) = '02' OR SUBSTR(KS_ZKZ2,1,2) = '03')
|
||||
//SELECT KS_ZKZ2 FROM ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' AND (SUBSTR(KS_ZKZ2,1,2) = '02') AND BJSH_JG_JQ IS NULL GROUP BY KS_ZKZ2 HAVING COUNT(KS_ZKZ2)>1
|
||||
/*HRESULT hr1 = pRecordset->Open("SELECT KS_ZKZ FROM ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' AND (SUBSTR(KS_ZKZ2,1,2) = '02') AND BJSH_JG_JQ IS NULL GROUP BY KS_ZKZ HAVING COUNT(KS_ZKZ)>1",*/
|
||||
|
||||
|
||||
/*构造查询语句*/
|
||||
int zong_flag = g_db_qurry_zone.length();
|
||||
int num_flag = g_db_qurry_stu_num.length();
|
||||
int date_flag = g_db_qurry_start.length();
|
||||
|
||||
string str_qurry = "SELECT KS_ZKZ FROM YANNSY.T_BYSQ_KS_KC WHERE KSSJ between ";
|
||||
str_qurry += g_db_qurry_start;
|
||||
str_qurry += " and ";
|
||||
str_qurry += g_db_qurry_end;
|
||||
|
||||
if (num_flag - 1)//长度大于1,就是需要查询学号
|
||||
{
|
||||
str_qurry += "AND KS_ZKZ = ";
|
||||
str_qurry += g_db_qurry_stu_num;
|
||||
}
|
||||
else//不需要查询单个学号才会有区域的作用范围
|
||||
{
|
||||
if ((zong_flag - 1))//长度大于1,就是需要查询区域,且查询时间
|
||||
{
|
||||
str_qurry += " AND(SUBSTR(KS_ZKZ2, 1, 2) = ";
|
||||
str_qurry += g_db_qurry_zone;
|
||||
str_qurry += ")";
|
||||
}
|
||||
}
|
||||
if (g_db_qurry_all)
|
||||
{
|
||||
str_qurry += " AND BJSH_JG_JQ IS NULL";
|
||||
}
|
||||
str_qurry += " GROUP BY KS_ZKZ HAVING COUNT(KS_ZKZ)>1";
|
||||
_variant_t _vstr_qurry(str_qurry.c_str());/* 转换string为_variant_t */
|
||||
|
||||
|
||||
|
||||
/*查询*/
|
||||
HRESULT hr1 = p_recordset->Open(_vstr_qurry,
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
if (!(SUCCEEDED(hr1))){exit(-1); }//读取不成功,直接退出程序
|
||||
do
|
||||
{//读取成功,将每一行存到vector的stu末尾
|
||||
stu.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ"))->GetValue()));
|
||||
p_recordset->MoveNext();//移到下一条
|
||||
} while (!p_recordset->EndOfFile);//条件是没有到所有记录的末尾
|
||||
}
|
||||
catch (_com_error e){ cout << "<提取学号(数据库):>查询失败--" << endl; }
|
||||
/*=================================================================================================*/
|
||||
|
||||
//3、关闭查询====//执行读取完毕后要关闭连接
|
||||
try {::CoUninitialize();}
|
||||
catch (_com_error e){ cout /*<< "<提取学号:关闭失败-->" */<< e.ErrorInfo() << endl; }
|
||||
|
||||
return 1;
|
||||
}
|
||||
41
测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.h
Normal file
41
测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
头文件:DBop.h 数据库操作头文件
|
||||
*/
|
||||
#pragma once
|
||||
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile")
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
extern FILE *g_log_fpzz; /*全局变量 程序日志专用文件句柄*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
/*****************************************函数原型*************************************/
|
||||
|
||||
|
||||
/**
|
||||
功能: 查询所有学生的学号,将所有的指定位置的数据库信息(学号)全部存储在名为stu的vector<string>型的变量中
|
||||
|
||||
@变量 stu 学生学号存储
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbStu(vector<string>& stu);
|
||||
129
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsp
Normal file
129
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsp
Normal file
@@ -0,0 +1,129 @@
|
||||
# Microsoft Developer Studio Project File - Name="HWCV_exe" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=HWCV_exe - 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 "HWCV_exe.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 "HWCV_exe.mak" CFG="HWCV_exe - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "HWCV_exe - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "HWCV_exe - 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)" == "HWCV_exe - 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 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 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
|
||||
|
||||
!ELSEIF "$(CFG)" == "HWCV_exe - 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 /I "C:\Program Files (x86)\OpenCV\otherlibs\highgui" /I "C:\Program Files (x86)\OpenCV\ml\include" /I "C:\Program Files (x86)\OpenCV\cv\include" /I "C:\Program Files (x86)\OpenCV\cvaux\include" /I "C:\Program Files (x86)\OpenCV\cxcore\include" /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 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 cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"C:\Program Files (x86)\OpenCV\lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "HWCV_exe - Win32 Release"
|
||||
# Name "HWCV_exe - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DBop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\path.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\segmentation.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DBop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\path.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\segmentation.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# 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
|
||||
29
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsw
Normal file
29
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# 警告: 不能编辑或删除该工作区文件!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "HWCV_exe"=.\HWCV_exe.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.opt
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.opt
Normal file
Binary file not shown.
16
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.plg
Normal file
16
测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.plg
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: HWCV_exe - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
HWCV_exe.exe - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
13
测试/服务器测试/输出文件/输出待检测检测文件try catch/Point.h
Normal file
13
测试/服务器测试/输出文件/输出待检测检测文件try catch/Point.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
头文件:Point.h 图像中的像素点定义
|
||||
*/
|
||||
#pragma once
|
||||
class Point{
|
||||
private:
|
||||
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
void setpoint(int a,int b){x=a;y=b;}
|
||||
};
|
||||
8
测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.cpp
Normal file
8
测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// HWCV.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
24
测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.h
Normal file
24
测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
#define AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
// Insert your headers here
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/calibfilter.ax
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/calibfilter.ax
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/createsamples.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/createsamples.exe
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cv100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cv100.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvaux100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvaux100.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvcam100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvcam100.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvinfo.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvinfo.exe
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvtest.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cvtest.exe
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcore100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcore100.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcoretest.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcoretest.exe
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxts001.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/cxts001.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/haartraining.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/haartraining.exe
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/highgui100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/highgui100.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/libguide40.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/libguide40.dll
Normal file
Binary file not shown.
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/ml100.dll
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/ml100.dll
Normal file
Binary file not shown.
267
测试/服务器测试/输出文件/输出待检测检测文件try catch/path.cpp
Normal file
267
测试/服务器测试/输出文件/输出待检测检测文件try catch/path.cpp
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
实现文件:path.cpp 路径操作实现文件
|
||||
*/
|
||||
#include "path.h"
|
||||
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime()
|
||||
{
|
||||
time( <ime );
|
||||
srcTime = ctime( <ime );
|
||||
strncpy(timeNow, srcTime, strlen(srcTime)-1); //不拷贝换行
|
||||
timeNow[strlen(srcTime)-1] = '\0'; //加结束符'\0'
|
||||
|
||||
return timeNow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum)
|
||||
{
|
||||
string temp = g_dir; temp += date; temp += "/";
|
||||
temp += subject.substr(0, 4); temp += "/";
|
||||
temp += stuNum; temp += ".jpg";
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector)
|
||||
{
|
||||
// 功能:将filename 中的数据(共cols列)读取到_vector中,_vector可视为二维数组
|
||||
FILE *fp = fopen(filename.c_str(), "r");//打开并读取文件
|
||||
bool flag = true;
|
||||
int i = 0;
|
||||
|
||||
// printf("--read_scanf--");
|
||||
if (!fp){ return 0; }
|
||||
while (flag){
|
||||
double *point = new double[cols];
|
||||
for (i = 0; i<cols; i++){ //读取数据,存在_vector[cols]中
|
||||
if (EOF == fscanf(fp, "%lf", &point[i])) {
|
||||
flag = false; break;
|
||||
}
|
||||
if (EOF == fgetc(fp)) {
|
||||
flag = false; i++; break;
|
||||
}
|
||||
}
|
||||
if (cols == i)
|
||||
_vector.push_back(point);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename)
|
||||
{
|
||||
ifstream file(filename);
|
||||
|
||||
if (!file)/*"配置文件不存在!"*/
|
||||
{
|
||||
/*写入时间*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
cout<<"read"<<endl;
|
||||
|
||||
strcat(g_log_rec, "--ERR:配置文件不存在!");
|
||||
SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*步骤:开始读取信息*/
|
||||
|
||||
string temp;/*仅用作过滤字符*/
|
||||
file >> temp >> temp;
|
||||
/*---此行6个,参考配置信息:图片对比参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >>temp;
|
||||
file >> g_dir >> temp >> temp >> temp;
|
||||
string g_log_adr_t;
|
||||
file >> g_log_adr_t >> temp;
|
||||
|
||||
memset(g_log_adr, 0, sizeof(g_log_adr));
|
||||
strcpy(g_log_adr, (char*)g_log_adr_t.c_str());
|
||||
|
||||
//if (g_bi_threshold < 0 || g_bi_threshold >255)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// strcat(g_log_rec, "--MSG:配置参数有误-笔迹图像对比参数!");
|
||||
// strcat(g_log_rec, g_dir.c_str());
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
/*---此行6个,参考配置信息:网络配置参数*/
|
||||
file >> temp >> temp >> g_db_hostName >> temp >> g_db_dBName >> temp >> g_db_userName >> temp >> g_db_password >> temp >> g_db_hoster_zk >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
////if (strcmp(g_db_hostName.c_str(), "") || g_bi_threshold >255 || g_bi_threshold < 1)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--MSG:-网络配置参数!");
|
||||
// strcat(g_log_rec, g_db_password.c_str());
|
||||
// strcat(g_log_rec, "\n");
|
||||
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
/*---此行5个,参考配置信息:控制参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-控制参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/*---此行5个,参考配置信息:数据库查询参数*/
|
||||
file >> temp >> temp >> g_db_qurry_start >> temp >> g_db_qurry_end >> temp >> g_db_qurry_zone >> temp >> g_db_qurry_stu_num >> temp >> g_db_qurry_all >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-数据库查询参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//if (g_doubt_threshold < 0.01)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//if (g_conti < 0 || g_conti > 10 || g_conti == NULL)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!\n\n");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
file.close();/*关闭文件句柄*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *txt, string txt_file_path, char *type)
|
||||
{
|
||||
FILE* fpzz = fopen(txt_file_path.c_str(), type); //创建文件
|
||||
if (NULL == fpzz)
|
||||
{
|
||||
return 0;
|
||||
}//要返回错误代码
|
||||
fprintf(fpzz, txt); //从控制台中读入并在文本输出
|
||||
fclose(fpzz);
|
||||
fpzz = NULL;//需要指向空,否则会指向原打开文件地址
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像(不实现,没有必要)
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr){
|
||||
/*char processPic[100] = "E:/imggj/";
|
||||
char *namePic = new char[20];
|
||||
bool flag = false;
|
||||
string xuehao = path, kaoshihao = path;
|
||||
int num_iter = sizeof(path);
|
||||
for (int iter = 0; iter < num_iter; iter++)
|
||||
{
|
||||
if (path[iter] == 'x')
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
xuehao = xuehao.substr(27, 13);
|
||||
kaoshihao = kaoshihao.substr(40, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
xuehao = xuehao.substr(27, 12);
|
||||
kaoshihao = kaoshihao.substr(39, 5);
|
||||
}
|
||||
strcat(processPic, xuehao.c_str());
|
||||
_mkdir(processPic);
|
||||
strcat(processPic, kaoshihao.c_str());
|
||||
strcat(processPic, ".jpg");
|
||||
cvSaveImage(processPic, imggj);*/
|
||||
return 1;
|
||||
}
|
||||
98
测试/服务器测试/输出文件/输出待检测检测文件try catch/path.h
Normal file
98
测试/服务器测试/输出文件/输出待检测检测文件try catch/path.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
头文件:path.h 与路径相关操作的函数头文件以及函数原型
|
||||
*/
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cv.h>
|
||||
#include <io.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
extern int g_bi_threshold; /*全局变量 二值化阈值*/
|
||||
extern double g_std_kesa[50][50]; /*全局变量 标准差数组*/
|
||||
extern float g_doubt_threshold; /*全局变量 作弊嫌疑阈值*/
|
||||
extern string g_dir; /*全局变量 总路径的目录*/
|
||||
extern int g_conti; /*全局变量 比较标准*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_err_adr[50]; /*全局变量 错误日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 待定*/
|
||||
/*全局变量 待定*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk;
|
||||
|
||||
|
||||
|
||||
extern time_t ltime;
|
||||
extern char *srcTime;
|
||||
extern char timeNow[22];
|
||||
extern char msg[100];
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime();
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum);
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector);
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename);
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *record, string txt_file_path, char *type);
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr);
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/performance.exe
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/performance.exe
Normal file
Binary file not shown.
667
测试/服务器测试/输出文件/输出待检测检测文件try catch/process.cpp
Normal file
667
测试/服务器测试/输出文件/输出待检测检测文件try catch/process.cpp
Normal file
@@ -0,0 +1,667 @@
|
||||
/*
|
||||
实现文件:process.cpp 图像处理过程的实现文件
|
||||
*/
|
||||
#include "process.h"
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int g_bi_threshold)
|
||||
{
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int i, j;
|
||||
static int black[1000]; //C语言不提倡返回一个局部变量的地址以外的功能,所以你必须定义的局部变量,如静态变量。
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*二值化,并统计黑像素的个数*/
|
||||
for (i = 0; i<height; i++)
|
||||
{
|
||||
for (j = 0; j<width; j++)//对图像每个点进行二值化,原值为128
|
||||
data[i*step + j*channels] = (data[i*step + j*channels]>g_bi_threshold) ? 255 : 0;
|
||||
}
|
||||
|
||||
/*计算每一行的黑像素个数*/
|
||||
int tempBlackPixel = 0;
|
||||
|
||||
memset(black, 0, 1000); //##初始化内存,这里用做清零black数组
|
||||
for (i = height - 1; i>0; i--)
|
||||
{
|
||||
for (int j = 0; j<width; j++)
|
||||
{
|
||||
if (data[i*step + j*channels] == 0) //计算黑色的像素数
|
||||
tempBlackPixel += 1;
|
||||
}
|
||||
black[height - i] = tempBlackPixel; //black记录黑色像素数
|
||||
tempBlackPixel = 0;
|
||||
}
|
||||
//二值化,并统计黑像素的个数**********
|
||||
return black;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j, jbi = 0, jbj = 0;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int brklab = 0;
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
// IplImage* imgjbsb = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
|
||||
cvCopy(img, imgjbsb, NULL);
|
||||
uchar *imgjbsbdata = (uchar *)imgjbsb->imageData;
|
||||
|
||||
//以角标为起点进行裁剪与画框
|
||||
CvSize jbcjsize = cvSize(835, 165); //角标裁剪框的大小,宽为835象素,高为165象素
|
||||
IplImage* imgjbcj = cvCreateImage(jbcjsize, img->depth, img->nChannels);
|
||||
uchar *imgjbcjdata = (uchar *)imgjbcj->imageData;
|
||||
int jbcjstep = imgjbcj->widthStep;
|
||||
int jbcjchannels = imgjbcj->nChannels;
|
||||
for (i = 0; i<165; i++)
|
||||
for (j = 0; j<835; j++)
|
||||
imgjbcjdata[i*jbcjstep + j*jbcjchannels] = data[(i + jbi)*step + (j + jbj)*channels];
|
||||
for (i = 0; i<165; i = i + 2)
|
||||
{
|
||||
imgjbsbdata[(i + jbi)*step + jbj*channels] = 0;
|
||||
imgjbsbdata[(i + jbi)*step + (jbj + 835)*channels] = 0;
|
||||
}
|
||||
for (j = 0; j<835; j = j + 2)
|
||||
{
|
||||
imgjbsbdata[jbi*step + (j + jbj)*channels] = 0;
|
||||
imgjbsbdata[(jbi + 165)*step + (j + jbj)*channels] = 0;
|
||||
}
|
||||
|
||||
return imgjbcj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
/*定义新的图像*/
|
||||
IplImage* imglk = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels);
|
||||
|
||||
/* 获取图像信息*/
|
||||
height = imgbj->height;
|
||||
width = imgbj->width;
|
||||
step = imgbj->widthStep;
|
||||
channels = imgbj->nChannels;
|
||||
data = (uchar *)imgbj->imageData;
|
||||
|
||||
// printf("--outline--");
|
||||
for (j = 0; j<height; j++){
|
||||
for (i = 0; i<width; i++){
|
||||
imglk->imageData[j*step + i*channels] = 255;
|
||||
}
|
||||
for (i = 0; i<width - 1; i++){
|
||||
if (data[j*step + (i + 1)*channels] - data[j*step + i*channels] == 255) //竖线右侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
else if (data[j*step + i*channels] - data[j*step + (i + 1)*channels] == 255) //竖线左侧框
|
||||
imglk->imageData[j*step + (i + 1)*channels] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<width; i++){
|
||||
for (j = 0; j<height - 1; j++){
|
||||
if (data[j*step + i*channels] - data[(j + 1)*step + i*channels] == 255) //横线下侧框
|
||||
imglk->imageData[(j + 1)*step + i*channels] = 0;
|
||||
else if (data[(j + 1)*step + i*channels] - data[j*step + i*channels] == 255) //横线上侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
}
|
||||
}
|
||||
return imglk;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int feat[50][50] = { 0 }; //特征值初始化
|
||||
Point featblk[32]; //标记相同H的黑点坐标
|
||||
int featk; //标记相同H的黑点数目
|
||||
int m; //for 里面的变量
|
||||
// printf("--outlinefeature--");
|
||||
// 获取图像信息
|
||||
height = imglk->height;
|
||||
width = imglk->width;
|
||||
step = imglk->widthStep;
|
||||
channels = imglk->nChannels;
|
||||
data = (uchar *)imglk->imageData;
|
||||
|
||||
//初始化特征矩阵 最大值为47 ,非空的特征字有1081个
|
||||
int outllab[9][9] = { \
|
||||
{3, 37, 10, 36, 2, 35, 9, 34, 1}, { 38, 3, 21, 20, 2, 19, 18, 1, 33 }, \
|
||||
{11, 22, 3, 10, 2, 9, 1, 17, 8}, { 39, 23, 11, 3, 2, 1, 8, 16, 32 }, \
|
||||
{4, 4, 4, 4, 0, 0, 0, 0, 0}, { 40, 24, 12, 5, 6, 7, 15, 31, 47 }, \
|
||||
{12, 25, 5, 13, 6, 14, 7, 30, 15}, { 41, 5, 26, 27, 6, 28, 29, 7, 46 }, \
|
||||
{5, 42, 13, 43, 6, 44, 14, 45, 7} };
|
||||
|
||||
|
||||
for (i = 4; i <= width - 5; i++){
|
||||
for (j = 4; j <= height - 5; j++){
|
||||
if (data[j*step + i*channels] == 0){
|
||||
//**************H=1
|
||||
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
if (data[j*step + (i + 1)*channels] == 0){ //右侧点
|
||||
featblk[featk].x = i + 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i + 1; m >= i - 1; m--){ //上排点
|
||||
if (data[(j - 1)*step + m*channels] == 0) {
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
if (data[j*step + (i - 1)*channels] == 0){ //左侧点
|
||||
featblk[featk].x = i - 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i - 1; m <= i + 1; m++) { //下排点
|
||||
if (data[(j + 1)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=1*******************
|
||||
|
||||
|
||||
//*********************H=2
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 1; m >= j - 2; m--){
|
||||
if (data[m*step + (i + 2)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 1; m >= i - 2; m--){ //上排点
|
||||
if (data[(j - 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 1; m <= j + 2; m++){ //左侧点
|
||||
if (data[m*step + (i - 2)*channels] == 0){
|
||||
featblk[featk].x = i - 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 1; m <= i + 2; m++){ //下排点
|
||||
if (data[(j + 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=2********************
|
||||
|
||||
//*********************H=3
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 2; m >= j - 3; m--){
|
||||
if (data[m*step + (i + 3)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 2; m >= i - 3; m--){ //上排点
|
||||
if (data[(j - 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 2; m <= j + 3; m++){ //左侧点
|
||||
if (data[m*step + (i - 3)*channels] == 0){
|
||||
featblk[featk].x = i - 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 2; m <= i + 3; m++){ //下排点
|
||||
if (data[(j + 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=3********************
|
||||
|
||||
//*********************H=4
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 3; m >= j - 4; m--){
|
||||
if (data[m*step + (i + 4)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 3; m >= i - 4; m--) { //上排点
|
||||
if (data[(j - 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 3; m <= j + 4; m++){ //左侧点
|
||||
if (data[m*step + (i - 4)*channels] == 0){
|
||||
featblk[featk].x = i - 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 3; m <= i + 4; m++){ //下排点
|
||||
if (data[(j + 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=4***********************
|
||||
}// if
|
||||
} //for j
|
||||
} //for i
|
||||
|
||||
//****注:最终特征值为feat(x,y)+feat(y,x),放入feat(x,y)中,x<y
|
||||
for (i = 1; i<50; i++)
|
||||
for (j = 0; j<i; j++){
|
||||
feat[j][i] = feat[i][j] + feat[j][i];
|
||||
feat[i][j] = 0;
|
||||
}
|
||||
memcpy(feature, feat, 2500 * 4); //int有四个字节
|
||||
// printf("轮廓特征值计算完成\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
//原图
|
||||
IplImage* imglk = 0; //轮廓图
|
||||
IplImage* imggj = 0; //骨架图
|
||||
IplImage* imgjbsb = 0; //角标识别图
|
||||
IplImage* imgbj = 0; //只提取笔记部分的图像
|
||||
IplImage* imgbjhf = 0; //为文字区域画上方格
|
||||
IplImage* imgwzbj = 0; //为文字区域标出是否为文字(文字标记)
|
||||
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int i, j; //用于返回图像每行黑像素的个数
|
||||
//int feature[50][50]={0}; //特征值初始化
|
||||
|
||||
IplImage* img = cvLoadImage(path, 0);
|
||||
|
||||
/* 获取图像信息*/
|
||||
SaveLog("s\n", g_log_adr, "a");
|
||||
height = img->height;
|
||||
SaveLog("d\n", g_log_adr, "a");
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*开始处理*/
|
||||
|
||||
/*图像放大*/
|
||||
IplImage* imgbig = 0; //原图的放大图
|
||||
CvSize dst_cvsize; //目标图像的大小
|
||||
float scale = 1;
|
||||
if (width<840){
|
||||
scale = (float)840 / width;
|
||||
dst_cvsize.width = 840;
|
||||
dst_cvsize.height = (int)(height*scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_cvsize.width = width;
|
||||
dst_cvsize.height = height;
|
||||
}
|
||||
|
||||
imgbig = cvCreateImage(dst_cvsize, img->depth, img->nChannels);
|
||||
cvResize(img, imgbig, CV_INTER_LINEAR); // CV_INTER_NN - 最近邻插值,
|
||||
//CV_INTER_LINEAR - 双线性插值 (缺省使用),
|
||||
//CV_INTER_AREA - 使用象素关系重采样。当图像缩小时候,该方法可以避免波纹出现。
|
||||
//CV_INTER_CUBIC - 立方插值.
|
||||
|
||||
/*二值化*/
|
||||
binary(imgbig, g_bi_threshold);
|
||||
//SaveLog("singlefeature_binary\n", "D:\\HWCV\\numtxt.txt", "a");
|
||||
|
||||
|
||||
|
||||
/*裁剪识别*/
|
||||
int jbwhite = 5, jbblack = 4;
|
||||
imgjbsb = cvCreateImage(cvGetSize(imgbig), imgbig->depth, imgbig->nChannels);
|
||||
imgbj = Cjbsb(imgbig, imgjbsb, jbwhite, jbblack); //返回文字的笔迹部分
|
||||
|
||||
|
||||
/*计算骨架图*/
|
||||
imggj = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels); //复制
|
||||
cvCopy(imgbj, imggj, NULL);
|
||||
uchar *gjdata = (uchar *)imggj->imageData;
|
||||
|
||||
beforethin(gjdata, gjdata, imggj->width, imggj->height);
|
||||
|
||||
/*笔迹图像颜色范围转换,以进行细化*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--1
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 255)
|
||||
gjdata[j*imggj->widthStep + i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*细化*/
|
||||
ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width);
|
||||
SaveLog("singlefeature_xihua\n", "D:\\HWCV\\numtxt.txt", "a");
|
||||
|
||||
/*笔记图像颜色范围转化回正常水平*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--255,反转过来
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 1)
|
||||
gjdata[j*imggj->widthStep + i] = 0;
|
||||
else
|
||||
gjdata[j*imggj->widthStep + i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
/*计算骨架特征徝*/
|
||||
outlinefeature(imggj, feature); //特征值占48*48的右上三角形,feature调用返回
|
||||
|
||||
/*释放内存*/
|
||||
cvReleaseImage(&imgbig);
|
||||
cvReleaseImage(&img);
|
||||
cvReleaseImage(&imgbj);
|
||||
cvReleaseImage(&imglk);
|
||||
cvReleaseImage(&imgjbsb);
|
||||
cvReleaseImage(&imgbjhf);
|
||||
cvReleaseImage(&imgwzbj);
|
||||
cvDestroyAllWindows();
|
||||
|
||||
return imggj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
unsigned long i, j;
|
||||
|
||||
for (i = 0; i<ly; i++){
|
||||
for (j = 0; j<lx; j++){
|
||||
//这里要视前景是白点还是黑点而定,可以改动
|
||||
//如果前景是白点,就是这样;反之反过来
|
||||
//jp[i*lx+j]=ip[i*lx+j];
|
||||
/* jp[i*lx+j]=255;*/
|
||||
if (ip[i*lx + j]>0)
|
||||
jp[i*lx + j] = 0;
|
||||
else
|
||||
jp[i*lx + j] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
char *f, *g;
|
||||
char n[10];
|
||||
char a[5] = { 0, -1, 1, 0, 0 };
|
||||
char b[5] = { 0, 0, 0, 1, -1 };
|
||||
char nrnd, cond, n48, n26, n24, n46, n68, n82, n123, n345, n567, n781;
|
||||
short k, shori;
|
||||
unsigned long i, j;
|
||||
long ii, jj, kk, kk1, kk2, kk3, size;
|
||||
|
||||
// printf("--Thinner_Rosenfeld--");
|
||||
size = (long)lx * (long)ly;
|
||||
|
||||
g = (char *)malloc(size);
|
||||
if (g == NULL){
|
||||
printf("error in alocating mmeory!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
f = (char *)image;
|
||||
for (kk = 0l; kk<size; kk++){
|
||||
g[kk] = f[kk];
|
||||
}
|
||||
|
||||
do{
|
||||
shori = 0;
|
||||
for (k = 1; k <= 4; k++){
|
||||
for (i = 1; i<lx - 1; i++){
|
||||
ii = i + a[k];
|
||||
|
||||
for (j = 1; j<ly - 1; j++){
|
||||
kk = i*ly + j;
|
||||
|
||||
if (!f[kk])
|
||||
continue;
|
||||
|
||||
jj = j + b[k];
|
||||
kk1 = ii*ly + jj;
|
||||
|
||||
if (f[kk1])
|
||||
continue;
|
||||
|
||||
kk1 = kk - ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk3 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[8] = f[kk3];
|
||||
kk1 = kk + ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
|
||||
nrnd = n[1] + n[2] + n[3] + n[4]
|
||||
+ n[5] + n[6] + n[7] + n[8];
|
||||
if (nrnd <= 1)
|
||||
continue;
|
||||
|
||||
cond = 0;
|
||||
n48 = n[4] + n[8];
|
||||
n26 = n[2] + n[6];
|
||||
n24 = n[2] + n[4];
|
||||
n46 = n[4] + n[6];
|
||||
n68 = n[6] + n[8];
|
||||
n82 = n[8] + n[2];
|
||||
n123 = n[1] + n[2] + n[3];
|
||||
n345 = n[3] + n[4] + n[5];
|
||||
n567 = n[5] + n[6] + n[7];
|
||||
n781 = n[7] + n[8] + n[1];
|
||||
|
||||
if (n[2] == 1 && n48 == 0 && n567>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[6] == 1 && n48 == 0 && n123>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[8] == 1 && n26 == 0 && n345>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[4] == 1 && n26 == 0 && n781>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[5] == 1 && n46 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[7] == 1 && n68 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[1] == 1 && n82 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[3] == 1 && n24 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
cond = 1;
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<lx; i++){
|
||||
for (j = 0; j<ly; j++){
|
||||
kk = i*ly + j;
|
||||
f[kk] = g[kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (shori);
|
||||
free(g);
|
||||
}
|
||||
97
测试/服务器测试/输出文件/输出待检测检测文件try catch/process.h
Normal file
97
测试/服务器测试/输出文件/输出待检测检测文件try catch/process.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
头文件:process.h 图像处理函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#include "Point.h"
|
||||
#include "path.h"
|
||||
#include "process.h"
|
||||
#include <cv.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <highgui.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
extern IplImage* src;
|
||||
|
||||
/***************************************函数原型****************************************/
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int bithro);
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack);
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj);
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly);
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly);
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/proxytrans.ax
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/proxytrans.ax
Normal file
Binary file not shown.
3
测试/服务器测试/输出文件/输出待检测检测文件try catch/registerall.bat
Normal file
3
测试/服务器测试/输出文件/输出待检测检测文件try catch/registerall.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
regsvr32 /S %1 calibfilter.ax
|
||||
regsvr32 /S %1 proxytrans.ax
|
||||
regsvr32 /S %1 syncfilter.ax
|
||||
46
测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.cpp
Normal file
46
测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
主函数文件:segmentation.cpp 主函数的实现文件
|
||||
*/
|
||||
#include "segmentation.h"
|
||||
|
||||
/*主函数*/
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
FILE *file = NULL;
|
||||
string checkpath="D:/HWCV/Check/";
|
||||
|
||||
//读取配置文件,并配置各项参数
|
||||
ReadConfig("D:/HWCV/config/configure.cfg");
|
||||
cout<<"ReadConfig success"<<endl;
|
||||
|
||||
//初始化log文件
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
strcat(g_log_rec, "\n");
|
||||
strcat(g_log_rec, GetTime());
|
||||
strcat(g_log_rec, " 配置文件读取完毕 ");
|
||||
|
||||
vector<string> stuNum;
|
||||
|
||||
while(true)
|
||||
{
|
||||
//查询数据库
|
||||
stuNum.clear();
|
||||
DbStu(stuNum);
|
||||
for(int i=0;i<stuNum.size();i++)
|
||||
{
|
||||
//首先合成地址
|
||||
string temp = checkpath;
|
||||
temp +=stuNum[i];
|
||||
file = fopen((char*)temp.c_str(),"w");
|
||||
fclose(file);
|
||||
SaveLog(".", g_log_adr, "a");
|
||||
}
|
||||
|
||||
Sleep(SLEEP_TIME);
|
||||
|
||||
}
|
||||
/*返回值*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
50
测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.h
Normal file
50
测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
头文件:segmentation.h 主函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#ifdef WIN32 //屏蔽VC6对STL的一些不完全支持造成
|
||||
#pragma warning (disable: 4514 4786)
|
||||
#endif
|
||||
#include "StdAfx.h"
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define SLEEP_TIME 1000
|
||||
|
||||
/*定义全局变量*/
|
||||
|
||||
string g_dir = "Y:/"; /* 全局变量 总路径的目录*/
|
||||
|
||||
string g_db_hostName = "192.168.200.97"; /*全局变量 服务器ip或名称*/
|
||||
string g_db_dBName = "purple"; /*全局变量 服务器ODBC数据源*/
|
||||
string g_db_userName = "BJSH"; /*全局变量 服务器用户名*/
|
||||
string g_db_password = "bjshadmin"; /*全局变量 服务器密码*/
|
||||
//string g_db_hostName = "localhost"; /*全局变量 服务器ip或名称*/
|
||||
//string g_db_dBName = "orcl123"; /*全局变量 服务器ODBC数据源*/
|
||||
//string g_db_userName = "yannsy"; /*全局变量 服务器用户名*/
|
||||
//string g_db_password = "123456"; /*全局变量 服务器密码*/
|
||||
|
||||
string g_db_qurry_start = "200906"; /*全局变量 数据库查询_开始日期*/
|
||||
string g_db_qurry_end = "201610"; /*全局变量 数据库查询_结束日期*/
|
||||
string g_db_qurry_zone = "0"; /*全局变量 数据库查询_特定区域*/
|
||||
string g_db_qurry_stu_num = "0"; /*全局变量 数据库查询_特定考号*/
|
||||
bool g_db_qurry_all = true; /*全局变量 数据库查询_查询全部标记*/
|
||||
string g_db_hoster_zk = "ZK"; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
|
||||
|
||||
bool g_output_cmd_config = false; /*全局变量 输出参数控制*/
|
||||
bool g_output_txt_config = false; /*全局变量 输出中间文件选项*/
|
||||
char g_log_adr[50] = "D:/HWCV/log_ori.txt"; /*全局变量 程序日志存储地址*/
|
||||
char g_log_rec[500] = { 0 }; /*全局变量 程序日志专用变量*/
|
||||
char g_err_adr[50]= "D:/HWCV/err_ori.txt"; /*错误日志路径*/
|
||||
/*全局变量 输出txt结果文件*/
|
||||
/*全局变量 输出txt结果文件地址*/
|
||||
|
||||
|
||||
|
||||
time_t ltime;
|
||||
char *srcTime=NULL;
|
||||
char timeNow[22]={0};
|
||||
char msg[100]={0};
|
||||
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/syncfilter.ax
Normal file
BIN
测试/服务器测试/输出文件/输出待检测检测文件try catch/syncfilter.ax
Normal file
Binary file not shown.
22
测试/服务器测试/鉴定主程序/HWCV-exe.sln
Normal file
22
测试/服务器测试/鉴定主程序/HWCV-exe.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HWCV-exe", "HWCV-exe\HWCV-exe.vcxproj", "{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
191
测试/服务器测试/鉴定主程序/HWCV-exe/DBop.cpp
Normal file
191
测试/服务器测试/鉴定主程序/HWCV-exe/DBop.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
实现文件:DBop.cpp 数据库操作实现文件
|
||||
*/
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
|
||||
/*本地的全局变量*/
|
||||
|
||||
_ConnectionPtr p_conn; /*全局变量 连接对象*/
|
||||
_RecordsetPtr p_recordset; /*全局变量 记录集对象*/
|
||||
_CommandPtr p_cmd; /*全局变量 操作集对象*/
|
||||
string str_conn; /*全局变量 连接字符串设置*/
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 根据string类的stu【存储学号】,搜索出所有此人的考试信息,并分别存储在不同的变量中
|
||||
|
||||
@变量 stuNum 学号
|
||||
@变量 date<vector> 考试时间
|
||||
@变量 subject<vector> 考试科目
|
||||
@变量 stuNum<vector> 考号
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2)//搜寻图片
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
// cout<<g_db_userName.c_str()<<endl;
|
||||
// cout<<g_db_password.c_str()<<endl;
|
||||
// cout<<g_db_hostName.c_str()<<endl;
|
||||
// cout<<g_db_dBName.c_str()<<endl;
|
||||
|
||||
/*创建链接描述符*/
|
||||
//Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = BJSH;Password=bjshadmin;Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.200.97)(PORT=1521))
|
||||
//(CONNECT_DATA=(SERVICE_NAME=purple)))",
|
||||
str_conn = "Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = ";
|
||||
str_conn += userName; //===仅初始化一次===//
|
||||
str_conn += ";Password="; //==================//
|
||||
str_conn += password;
|
||||
str_conn += ";Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=";
|
||||
str_conn += hostName;
|
||||
str_conn += ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=";
|
||||
str_conn += dBName;
|
||||
str_conn += ")))";
|
||||
|
||||
//构造查询语句 下句注释是sql语句,需要构造成这种类型
|
||||
/*select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010207203867*/
|
||||
/*string sql = "select KS_ZKZ2, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201504' AND KS_ZKZ = ";*/
|
||||
// select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225
|
||||
//"select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225",
|
||||
string sql = "select KS_ZKZ2, KSSJ, TJ_KC_DM from ";
|
||||
sql += g_db_hoster_zk;
|
||||
sql += ".T_BYSQ_KS_KC WHERE KSSJ between ";
|
||||
sql += g_db_qurry_start;
|
||||
sql += " and ";
|
||||
sql += g_db_qurry_end;
|
||||
sql += " AND KS_ZKZ =";
|
||||
sql += stuNum.c_str();
|
||||
|
||||
_bstr_t _vstr_sql(sql.c_str());/* 转换string为_variant_t */
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
/*创建、打开连接*/
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()),
|
||||
//p_conn->Open("Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = BJSH;Password=bjshadmin;Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.200.97)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=purple)))",
|
||||
_bstr_t(userName.c_str()),
|
||||
_bstr_t(password.c_str()),
|
||||
adConnectUnspecified);
|
||||
|
||||
|
||||
|
||||
cout << _vstr_sql << endl;
|
||||
SaveLog(_vstr_sql, "D:/HWCV/1/txt", "a");
|
||||
// SaveLog((char*)str_conn.c_str(), g_log_adr, "a");
|
||||
HRESULT hr = p_recordset->Open(_bstr_t(_vstr_sql),//执行sq语句,查询一个学生的所有考试信息
|
||||
//HRESULT hr = p_recordset->Open("select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225",
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
// cout<<"count:"<<p_recordset->RecordCount <<endl;
|
||||
//将结果集输出到三个vector变量中
|
||||
if (p_recordset->RecordCount < 1)//结果集为空
|
||||
{
|
||||
return 0;//没有信息,直接跳过这个人
|
||||
}
|
||||
do{ //将结果集输出到三个vector变量中
|
||||
string comp = (string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ2"))->GetValue());
|
||||
if (!strcmp(comp.substr(0, 1).c_str(), "4") || !strcmp(comp.substr(0, 1).c_str(), "9")) //将4,9 开头的考号(无图像)直接处理掉
|
||||
continue;
|
||||
dateVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KSSJ"))->GetValue()));
|
||||
subjectVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("TJ_KC_DM"))->GetValue()));
|
||||
stuNum2.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ2"))->GetValue()));
|
||||
p_recordset->MoveNext();
|
||||
} while (!p_recordset->EndOfFile);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
return 0;
|
||||
// printf("%x", e.Error());
|
||||
cout<<"Failed"<<endl;
|
||||
}
|
||||
|
||||
/*关闭查询*/
|
||||
::CoUninitialize();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
|
||||
|
||||
@变量 stuNum:学号
|
||||
@变量 subject:考试科目
|
||||
@变量 flagCheat:作弊标记
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec)
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
/*更新字串设置*/
|
||||
int count = subjectVec.size();
|
||||
vector<string> sqlKC; //课程表:作弊第一字段
|
||||
int ci = 0; //循环
|
||||
|
||||
|
||||
/*构造更新语句*/
|
||||
for (ci = 0; ci < count; ++ci)
|
||||
{
|
||||
/*作弊的*/
|
||||
string sqlKC1 = "UPDATE ";
|
||||
sqlKC1 += g_db_hoster_zk;
|
||||
sqlKC1 += ".T_BYSQ_KS_KC SET BJSH_JG_JQ =";//天津_课程_代码
|
||||
sqlKC1 += flagVec[ci].c_str();
|
||||
sqlKC1 += " WHERE KS_ZKZ2=";
|
||||
sqlKC1 += stuNum2[ci].c_str();
|
||||
sqlKC1 += " AND TJ_KC_DM=";
|
||||
sqlKC1 += subjectVec[ci].c_str();
|
||||
sqlKC1 += " AND KSSJ=";
|
||||
sqlKC1 += dateVec[ci].c_str();
|
||||
sqlKC1 += " AND KS_ZKZ=";
|
||||
sqlKC1 += stuNum.c_str();
|
||||
|
||||
sqlKC.push_back(sqlKC1);
|
||||
}
|
||||
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
/*更新数据库表*/
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
p_cmd.CreateInstance("ADODB.Command");
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
|
||||
p_cmd->ActiveConnection = p_conn;
|
||||
|
||||
for (ci = 0; ci < count; ++ci)
|
||||
{
|
||||
p_recordset->Open(_bstr_t(sqlKC[ci].c_str()),//更新第二条
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
}
|
||||
}
|
||||
catch (_com_error e){ return 0; cerr << "Err:"; }
|
||||
|
||||
/*关闭查询*/
|
||||
::CoUninitialize();
|
||||
|
||||
return 1;
|
||||
}
|
||||
55
测试/服务器测试/鉴定主程序/HWCV-exe/DBop.h
Normal file
55
测试/服务器测试/鉴定主程序/HWCV-exe/DBop.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
头文件:DBop.h 数据库操作头文件
|
||||
*/
|
||||
#pragma once
|
||||
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile")
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
extern FILE *g_log_fpzz; /*全局变量 程序日志专用文件句柄*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
/*****************************************函数原型*************************************/
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 根据string类的stu【存储学号】,搜索出所有此人的考试信息,并分别存储在不同的变量中
|
||||
|
||||
@变量 stuNum 学号
|
||||
@变量 date<vector> 考试时间
|
||||
@变量 subject<vector> 考试科目
|
||||
@变量 stuNum<vector> 考号
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2);
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
|
||||
|
||||
@变量 stuNum:学号
|
||||
@变量 subject:考试科目
|
||||
@变量 flagCheat:作弊标记
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec);
|
||||
104
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj
Normal file
104
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj
Normal file
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>HWCVexe</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<LibraryPath>E:\program files\opencv\build\x86\vc12\staticlib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.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;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>IlmImf.lib;libjasper.lib;libjpeg.lib;libpng.lib;libtiff.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;comctl32.lib;libpngd.lib;libtiffd.lib;zlibd.lib;IlmImfd.lib;libjasperd.lib;libjpegd.lib;vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DBop.h" />
|
||||
<ClInclude Include="path.h" />
|
||||
<ClInclude Include="Point.h" />
|
||||
<ClInclude Include="process.h" />
|
||||
<ClInclude Include="segmentation.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DBop.cpp" />
|
||||
<ClCompile Include="path.cpp" />
|
||||
<ClCompile Include="process.cpp" />
|
||||
<ClCompile Include="segmentation.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
54
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj.filters
Normal file
54
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj.filters
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DBop.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="path.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Point.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="process.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="segmentation.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DBop.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="path.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="process.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="segmentation.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe更改前bck.rar
Normal file
BIN
测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe更改前bck.rar
Normal file
Binary file not shown.
13
测试/服务器测试/鉴定主程序/HWCV-exe/Point.h
Normal file
13
测试/服务器测试/鉴定主程序/HWCV-exe/Point.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
头文件:Point.h 图像中的像素点定义
|
||||
*/
|
||||
#pragma once
|
||||
class Point{
|
||||
private:
|
||||
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
void setpoint(int a,int b){x=a;y=b;}
|
||||
};
|
||||
8
测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.cpp
Normal file
8
测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// HWCV.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
24
测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.h
Normal file
24
测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
#define AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
// Insert your headers here
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
266
测试/服务器测试/鉴定主程序/HWCV-exe/path.cpp
Normal file
266
测试/服务器测试/鉴定主程序/HWCV-exe/path.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
实现文件:path.cpp 路径操作实现文件
|
||||
*/
|
||||
#include "path.h"
|
||||
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime()
|
||||
{
|
||||
time(&g_ltime);
|
||||
g_srcTime = ctime(&g_ltime);
|
||||
strncpy(g_timeNow, g_srcTime, strlen(g_srcTime) - 1); //不拷贝换行
|
||||
g_timeNow[strlen(g_srcTime) - 1] = '\0'; //加结束符'\0'
|
||||
|
||||
return g_timeNow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum)
|
||||
{
|
||||
string temp = g_dir; temp += date; temp += "/";
|
||||
temp += subject.substr(0, 4); temp += "/";
|
||||
temp += stuNum; temp += ".jpg";
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector)
|
||||
{
|
||||
// 功能:将filename 中的数据(共cols列)读取到_vector中,_vector可视为二维数组
|
||||
FILE *fp = fopen(filename.c_str(), "r");//打开并读取文件
|
||||
bool flag = true;
|
||||
int i = 0;
|
||||
|
||||
// printf("--read_scanf--");
|
||||
if (!fp){ return 0; }
|
||||
while (flag){
|
||||
double *point = new double[cols];
|
||||
for (i = 0; i<cols; i++){ //读取数据,存在_vector[cols]中
|
||||
if (EOF == fscanf(fp, "%lf", &point[i])) {
|
||||
flag = false; break;
|
||||
}
|
||||
if (EOF == fgetc(fp)) {
|
||||
flag = false; i++; break;
|
||||
}
|
||||
}
|
||||
if (cols == i)
|
||||
_vector.push_back(point);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename)
|
||||
{
|
||||
ifstream file(filename);
|
||||
|
||||
if (!file)/*"配置文件不存在!"*/
|
||||
{
|
||||
/*写入时间*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// cout<<"read"<<endl;
|
||||
|
||||
strcat(g_log_rec, "--ERR:配置文件不存在!");
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*步骤:开始读取信息*/
|
||||
/*仅用作过滤字符*/
|
||||
string temp;
|
||||
file >> temp >> temp;
|
||||
/*---此行6个,参考配置信息:图片对比参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >>temp;
|
||||
file >> g_dir >> temp >> temp >> temp;
|
||||
string g_log_adr_t;
|
||||
file >> g_log_adr_t >> temp;
|
||||
|
||||
memset(g_log_adr, 0, sizeof(g_log_adr));
|
||||
strcpy(g_log_adr, (char*)g_log_adr_t.c_str());
|
||||
|
||||
//if (g_bi_threshold < 0 || g_bi_threshold >255)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// strcat(g_log_rec, "--MSG:配置参数有误-笔迹图像对比参数!");
|
||||
// strcat(g_log_rec, g_dir.c_str());
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
/*---此行6个,参考配置信息:网络配置参数*/
|
||||
file >> temp >> temp >> g_db_hostName >> temp >> g_db_dBName >> temp >> g_db_userName >> temp >> g_db_password >> temp >> g_db_hoster_zk >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
////if (strcmp(g_db_hostName.c_str(), "") || g_bi_threshold >255 || g_bi_threshold < 1)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--MSG:-网络配置参数!");
|
||||
// strcat(g_log_rec, g_db_password.c_str());
|
||||
// strcat(g_log_rec, "\n");
|
||||
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
/*---此行5个,参考配置信息:控制参数*/
|
||||
//备用
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-控制参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/*---此行5个,参考配置信息:数据库查询参数*/
|
||||
file >> temp >> temp >> g_db_qurry_start >> temp >> g_db_qurry_end >> temp >> g_db_qurry_zone >> temp >> g_db_qurry_stu_num >> temp >> g_db_qurry_all >> temp;
|
||||
|
||||
///*检验参数*/
|
||||
//if (0)/*输出到日志错误信息*/{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-数据库查询参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//if (g_doubt_threshold < 0.01)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// /*time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//if (g_conti < 0 || g_conti > 10 || g_conti == NULL)
|
||||
//{
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
///* time_t timer;
|
||||
// struct tm *tblock;
|
||||
// timer = time(NULL);
|
||||
// tblock = localtime(&timer);
|
||||
// strcat(g_log_rec, asctime(tblock));*/
|
||||
// strcat(g_log_rec, "--ERR:配置参数有误-笔迹图像对比参数!\n\n");
|
||||
// SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
file.close();/*关闭文件句柄*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *txt, string txt_file_path, char *type)
|
||||
{
|
||||
FILE* fpzz = fopen(txt_file_path.c_str(), type); //创建文件
|
||||
if (!fpzz) return 0;
|
||||
//要返回错误代码
|
||||
fprintf(fpzz, txt); //从控制台中读入并在文本输出
|
||||
fclose(fpzz);
|
||||
fpzz = NULL;//需要指向空,否则会指向原打开文件地址
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像(不实现,没有必要)
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr){
|
||||
/*char processPic[100] = "E:/imggj/";
|
||||
char *namePic = new char[20];
|
||||
bool flag = false;
|
||||
string xuehao = path, kaoshihao = path;
|
||||
int num_iter = sizeof(path);
|
||||
for (int iter = 0; iter < num_iter; iter++)
|
||||
{
|
||||
if (path[iter] == 'x')
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
xuehao = xuehao.substr(27, 13);
|
||||
kaoshihao = kaoshihao.substr(40, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
xuehao = xuehao.substr(27, 12);
|
||||
kaoshihao = kaoshihao.substr(39, 5);
|
||||
}
|
||||
strcat(processPic, xuehao.c_str());
|
||||
_mkdir(processPic);
|
||||
strcat(processPic, kaoshihao.c_str());
|
||||
strcat(processPic, ".jpg");
|
||||
cvSaveImage(processPic, imggj);*/
|
||||
return 1;
|
||||
}
|
||||
96
测试/服务器测试/鉴定主程序/HWCV-exe/path.h
Normal file
96
测试/服务器测试/鉴定主程序/HWCV-exe/path.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
头文件:path.h 与路径相关操作的函数头文件以及函数原型
|
||||
*/
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cv.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
extern int g_bi_threshold; /*全局变量 二值化阈值*/
|
||||
extern double g_std_kesa[50][50]; /*全局变量 标准差数组*/
|
||||
extern float g_doubt_threshold; /*全局变量 作弊嫌疑阈值*/
|
||||
extern string g_dir; /*全局变量 总路径的目录*/
|
||||
extern int g_conti; /*全局变量 比较标准*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 待定*/
|
||||
/*全局变量 待定*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk;
|
||||
|
||||
|
||||
|
||||
extern time_t g_ltime;
|
||||
extern char *g_srcTime;
|
||||
extern char g_timeNow[32];
|
||||
extern char g_msg[100];
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime();
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum);
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector);
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename);
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *record, string txt_file_path, char *type);
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr);
|
||||
667
测试/服务器测试/鉴定主程序/HWCV-exe/process.cpp
Normal file
667
测试/服务器测试/鉴定主程序/HWCV-exe/process.cpp
Normal file
@@ -0,0 +1,667 @@
|
||||
/*
|
||||
实现文件:process.cpp 图像处理过程的实现文件
|
||||
*/
|
||||
#include "process.h"
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int g_bi_threshold)
|
||||
{
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int i, j;
|
||||
static int black[1000]; //C语言不提倡返回一个局部变量的地址以外的功能,所以你必须定义的局部变量,如静态变量。
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*二值化,并统计黑像素的个数*/
|
||||
for (i = 0; i<height; i++)
|
||||
{
|
||||
for (j = 0; j<width; j++)//对图像每个点进行二值化,原值为128
|
||||
data[i*step + j*channels] = (data[i*step + j*channels]>g_bi_threshold) ? 255 : 0;
|
||||
}
|
||||
|
||||
/*计算每一行的黑像素个数*/
|
||||
int tempBlackPixel = 0;
|
||||
|
||||
memset(black, 0, 1000); //##初始化内存,这里用做清零black数组
|
||||
for (i = height - 1; i>0; i--)
|
||||
{
|
||||
for (int j = 0; j<width; j++)
|
||||
{
|
||||
if (data[i*step + j*channels] == 0) //计算黑色的像素数
|
||||
tempBlackPixel += 1;
|
||||
}
|
||||
black[height - i] = tempBlackPixel; //black记录黑色像素数
|
||||
tempBlackPixel = 0;
|
||||
}
|
||||
//二值化,并统计黑像素的个数**********
|
||||
return black;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j, jbi = 0, jbj = 0;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int brklab = 0;
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
// IplImage* imgjbsb = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
|
||||
cvCopy(img, imgjbsb, NULL);
|
||||
uchar *imgjbsbdata = (uchar *)imgjbsb->imageData;
|
||||
|
||||
//以角标为起点进行裁剪与画框
|
||||
CvSize jbcjsize = cvSize(835, 165); //角标裁剪框的大小,宽为835象素,高为165象素
|
||||
IplImage* imgjbcj = cvCreateImage(jbcjsize, img->depth, img->nChannels);
|
||||
uchar *imgjbcjdata = (uchar *)imgjbcj->imageData;
|
||||
int jbcjstep = imgjbcj->widthStep;
|
||||
int jbcjchannels = imgjbcj->nChannels;
|
||||
for (i = 0; i<165; i++)
|
||||
for (j = 0; j<835; j++)
|
||||
imgjbcjdata[i*jbcjstep + j*jbcjchannels] = data[(i + jbi)*step + (j + jbj)*channels];
|
||||
for (i = 0; i<165; i = i + 2)
|
||||
{
|
||||
imgjbsbdata[(i + jbi)*step + jbj*channels] = 0;
|
||||
imgjbsbdata[(i + jbi)*step + (jbj + 835)*channels] = 0;
|
||||
}
|
||||
for (j = 0; j<835; j = j + 2)
|
||||
{
|
||||
imgjbsbdata[jbi*step + (j + jbj)*channels] = 0;
|
||||
imgjbsbdata[(jbi + 165)*step + (j + jbj)*channels] = 0;
|
||||
}
|
||||
|
||||
return imgjbcj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
/*定义新的图像*/
|
||||
IplImage* imglk = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels);
|
||||
|
||||
/* 获取图像信息*/
|
||||
height = imgbj->height;
|
||||
width = imgbj->width;
|
||||
step = imgbj->widthStep;
|
||||
channels = imgbj->nChannels;
|
||||
data = (uchar *)imgbj->imageData;
|
||||
|
||||
// printf("--outline--");
|
||||
for (j = 0; j<height; j++){
|
||||
for (i = 0; i<width; i++){
|
||||
imglk->imageData[j*step + i*channels] = 255;
|
||||
}
|
||||
for (i = 0; i<width - 1; i++){
|
||||
if (data[j*step + (i + 1)*channels] - data[j*step + i*channels] == 255) //竖线右侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
else if (data[j*step + i*channels] - data[j*step + (i + 1)*channels] == 255) //竖线左侧框
|
||||
imglk->imageData[j*step + (i + 1)*channels] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<width; i++){
|
||||
for (j = 0; j<height - 1; j++){
|
||||
if (data[j*step + i*channels] - data[(j + 1)*step + i*channels] == 255) //横线下侧框
|
||||
imglk->imageData[(j + 1)*step + i*channels] = 0;
|
||||
else if (data[(j + 1)*step + i*channels] - data[j*step + i*channels] == 255) //横线上侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
}
|
||||
}
|
||||
return imglk;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int feat[50][50] = { 0 }; //特征值初始化
|
||||
Point featblk[32]; //标记相同H的黑点坐标
|
||||
int featk; //标记相同H的黑点数目
|
||||
int m; //for 里面的变量
|
||||
// printf("--outlinefeature--");
|
||||
// 获取图像信息
|
||||
height = imglk->height;
|
||||
width = imglk->width;
|
||||
step = imglk->widthStep;
|
||||
channels = imglk->nChannels;
|
||||
data = (uchar *)imglk->imageData;
|
||||
|
||||
//初始化特征矩阵 最大值为47 ,非空的特征字有1081个
|
||||
int outllab[9][9] = { \
|
||||
{3, 37, 10, 36, 2, 35, 9, 34, 1}, { 38, 3, 21, 20, 2, 19, 18, 1, 33 }, \
|
||||
{11, 22, 3, 10, 2, 9, 1, 17, 8}, { 39, 23, 11, 3, 2, 1, 8, 16, 32 }, \
|
||||
{4, 4, 4, 4, 0, 0, 0, 0, 0}, { 40, 24, 12, 5, 6, 7, 15, 31, 47 }, \
|
||||
{12, 25, 5, 13, 6, 14, 7, 30, 15}, { 41, 5, 26, 27, 6, 28, 29, 7, 46 }, \
|
||||
{5, 42, 13, 43, 6, 44, 14, 45, 7} };
|
||||
|
||||
|
||||
for (i = 4; i <= width - 5; i++){
|
||||
for (j = 4; j <= height - 5; j++){
|
||||
if (data[j*step + i*channels] == 0){
|
||||
//**************H=1
|
||||
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
if (data[j*step + (i + 1)*channels] == 0){ //右侧点
|
||||
featblk[featk].x = i + 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i + 1; m >= i - 1; m--){ //上排点
|
||||
if (data[(j - 1)*step + m*channels] == 0) {
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
if (data[j*step + (i - 1)*channels] == 0){ //左侧点
|
||||
featblk[featk].x = i - 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i - 1; m <= i + 1; m++) { //下排点
|
||||
if (data[(j + 1)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=1*******************
|
||||
|
||||
|
||||
//*********************H=2
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 1; m >= j - 2; m--){
|
||||
if (data[m*step + (i + 2)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 1; m >= i - 2; m--){ //上排点
|
||||
if (data[(j - 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 1; m <= j + 2; m++){ //左侧点
|
||||
if (data[m*step + (i - 2)*channels] == 0){
|
||||
featblk[featk].x = i - 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 1; m <= i + 2; m++){ //下排点
|
||||
if (data[(j + 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=2********************
|
||||
|
||||
//*********************H=3
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 2; m >= j - 3; m--){
|
||||
if (data[m*step + (i + 3)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 2; m >= i - 3; m--){ //上排点
|
||||
if (data[(j - 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 2; m <= j + 3; m++){ //左侧点
|
||||
if (data[m*step + (i - 3)*channels] == 0){
|
||||
featblk[featk].x = i - 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 2; m <= i + 3; m++){ //下排点
|
||||
if (data[(j + 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=3********************
|
||||
|
||||
//*********************H=4
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 3; m >= j - 4; m--){
|
||||
if (data[m*step + (i + 4)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 3; m >= i - 4; m--) { //上排点
|
||||
if (data[(j - 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 3; m <= j + 4; m++){ //左侧点
|
||||
if (data[m*step + (i - 4)*channels] == 0){
|
||||
featblk[featk].x = i - 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 3; m <= i + 4; m++){ //下排点
|
||||
if (data[(j + 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=4***********************
|
||||
}// if
|
||||
} //for j
|
||||
} //for i
|
||||
|
||||
//****注:最终特征值为feat(x,y)+feat(y,x),放入feat(x,y)中,x<y
|
||||
for (i = 1; i<50; i++)
|
||||
for (j = 0; j<i; j++){
|
||||
feat[j][i] = feat[i][j] + feat[j][i];
|
||||
feat[i][j] = 0;
|
||||
}
|
||||
memcpy(feature, feat, 2500 * 4); //int有四个字节
|
||||
// printf("轮廓特征值计算完成\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
//原图
|
||||
IplImage* imglk = 0; //轮廓图
|
||||
IplImage* imggj = 0; //骨架图
|
||||
IplImage* imgjbsb = 0; //角标识别图
|
||||
IplImage* imgbj = 0; //只提取笔记部分的图像
|
||||
IplImage* imgbjhf = 0; //为文字区域画上方格
|
||||
IplImage* imgwzbj = 0; //为文字区域标出是否为文字(文字标记)
|
||||
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int i, j; //用于返回图像每行黑像素的个数
|
||||
//int feature[50][50]={0}; //特征值初始化
|
||||
// cout << "loadImage" << endl;
|
||||
IplImage* img = cvLoadImage(path, 0);
|
||||
|
||||
/* 获取图像信息*/
|
||||
|
||||
// cout << "获取图像信息" << endl;
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*开始处理*/
|
||||
|
||||
/*图像放大*/
|
||||
// cout << "图像放大" << endl;
|
||||
IplImage* imgbig = 0; //原图的放大图
|
||||
CvSize dst_cvsize; //目标图像的大小
|
||||
float scale = 1;
|
||||
if (width<840){
|
||||
scale = (float)840 / width;
|
||||
dst_cvsize.width = 840;
|
||||
dst_cvsize.height = (int)(height*scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_cvsize.width = width;
|
||||
dst_cvsize.height = height;
|
||||
}
|
||||
|
||||
imgbig = cvCreateImage(dst_cvsize, img->depth, img->nChannels);
|
||||
cvResize(img, imgbig, CV_INTER_LINEAR); // CV_INTER_NN - 最近邻插值,
|
||||
//CV_INTER_LINEAR - 双线性插值 (缺省使用),
|
||||
//CV_INTER_AREA - 使用象素关系重采样。当图像缩小时候,该方法可以避免波纹出现。
|
||||
//CV_INTER_CUBIC - 立方插值.
|
||||
|
||||
/*二值化*/
|
||||
binary(imgbig, g_bi_threshold);
|
||||
//SaveLog("singlefeature_binary\n", "D:\\HWCV\\numtxt.txt", "a");
|
||||
|
||||
|
||||
|
||||
/*裁剪识别*/
|
||||
int jbwhite = 5, jbblack = 4;
|
||||
imgjbsb = cvCreateImage(cvGetSize(imgbig), imgbig->depth, imgbig->nChannels);
|
||||
imgbj = Cjbsb(imgbig, imgjbsb, jbwhite, jbblack); //返回文字的笔迹部分
|
||||
|
||||
|
||||
/*计算骨架图*/
|
||||
imggj = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels); //复制
|
||||
cvCopy(imgbj, imggj, NULL);
|
||||
uchar *gjdata = (uchar *)imggj->imageData;
|
||||
|
||||
beforethin(gjdata, gjdata, imggj->width, imggj->height);
|
||||
|
||||
/*笔迹图像颜色范围转换,以进行细化*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--1
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 255)
|
||||
gjdata[j*imggj->widthStep + i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*细化*/
|
||||
ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width);
|
||||
|
||||
/*笔记图像颜色范围转化回正常水平*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--255,反转过来
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 1)
|
||||
gjdata[j*imggj->widthStep + i] = 0;
|
||||
else
|
||||
gjdata[j*imggj->widthStep + i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
/*计算骨架特征徝*/
|
||||
outlinefeature(imggj, feature); //特征值占48*48的右上三角形,feature调用返回
|
||||
|
||||
/*释放内存*/
|
||||
cvReleaseImage(&imgbig);
|
||||
cvReleaseImage(&img);
|
||||
cvReleaseImage(&imgbj);
|
||||
cvReleaseImage(&imglk);
|
||||
cvReleaseImage(&imgjbsb);
|
||||
cvReleaseImage(&imgbjhf);
|
||||
cvReleaseImage(&imgwzbj);
|
||||
cvDestroyAllWindows();
|
||||
cout << "singleOK" << endl;
|
||||
return imggj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
unsigned long i, j;
|
||||
|
||||
for (i = 0; i<ly; i++){
|
||||
for (j = 0; j<lx; j++){
|
||||
//这里要视前景是白点还是黑点而定,可以改动
|
||||
//如果前景是白点,就是这样;反之反过来
|
||||
//jp[i*lx+j]=ip[i*lx+j];
|
||||
/* jp[i*lx+j]=255;*/
|
||||
if (ip[i*lx + j]>0)
|
||||
jp[i*lx + j] = 0;
|
||||
else
|
||||
jp[i*lx + j] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
char *f, *g;
|
||||
char n[10];
|
||||
char a[5] = { 0, -1, 1, 0, 0 };
|
||||
char b[5] = { 0, 0, 0, 1, -1 };
|
||||
char nrnd, cond, n48, n26, n24, n46, n68, n82, n123, n345, n567, n781;
|
||||
short k, shori;
|
||||
unsigned long i, j;
|
||||
long ii, jj, kk, kk1, kk2, kk3, size;
|
||||
|
||||
// printf("--Thinner_Rosenfeld--");
|
||||
size = (long)lx * (long)ly;
|
||||
|
||||
g = (char *)malloc(size);
|
||||
if (g == NULL){
|
||||
printf("error in alocating mmeory!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
f = (char *)image;
|
||||
for (kk = 0l; kk<size; kk++){
|
||||
g[kk] = f[kk];
|
||||
}
|
||||
|
||||
do{
|
||||
shori = 0;
|
||||
for (k = 1; k <= 4; k++){
|
||||
for (i = 1; i<lx - 1; i++){
|
||||
ii = i + a[k];
|
||||
|
||||
for (j = 1; j<ly - 1; j++){
|
||||
kk = i*ly + j;
|
||||
|
||||
if (!f[kk])
|
||||
continue;
|
||||
|
||||
jj = j + b[k];
|
||||
kk1 = ii*ly + jj;
|
||||
|
||||
if (f[kk1])
|
||||
continue;
|
||||
|
||||
kk1 = kk - ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk3 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[8] = f[kk3];
|
||||
kk1 = kk + ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
|
||||
nrnd = n[1] + n[2] + n[3] + n[4]
|
||||
+ n[5] + n[6] + n[7] + n[8];
|
||||
if (nrnd <= 1)
|
||||
continue;
|
||||
|
||||
cond = 0;
|
||||
n48 = n[4] + n[8];
|
||||
n26 = n[2] + n[6];
|
||||
n24 = n[2] + n[4];
|
||||
n46 = n[4] + n[6];
|
||||
n68 = n[6] + n[8];
|
||||
n82 = n[8] + n[2];
|
||||
n123 = n[1] + n[2] + n[3];
|
||||
n345 = n[3] + n[4] + n[5];
|
||||
n567 = n[5] + n[6] + n[7];
|
||||
n781 = n[7] + n[8] + n[1];
|
||||
|
||||
if (n[2] == 1 && n48 == 0 && n567>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[6] == 1 && n48 == 0 && n123>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[8] == 1 && n26 == 0 && n345>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[4] == 1 && n26 == 0 && n781>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[5] == 1 && n46 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[7] == 1 && n68 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[1] == 1 && n82 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[3] == 1 && n24 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
cond = 1;
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<lx; i++){
|
||||
for (j = 0; j<ly; j++){
|
||||
kk = i*ly + j;
|
||||
f[kk] = g[kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (shori);
|
||||
free(g);
|
||||
}
|
||||
97
测试/服务器测试/鉴定主程序/HWCV-exe/process.h
Normal file
97
测试/服务器测试/鉴定主程序/HWCV-exe/process.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
头文件:process.h 图像处理函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#include "Point.h"
|
||||
#include "path.h"
|
||||
#include "process.h"
|
||||
#include <cv.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <highgui.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
extern IplImage* src;
|
||||
|
||||
/***************************************函数原型****************************************/
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int bithro);
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack);
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj);
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly);
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly);
|
||||
243
测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.cpp
Normal file
243
测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
主函数文件:segmentation.cpp 主函数的实现文件
|
||||
*/
|
||||
#include "segmentation.h"
|
||||
//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//没有界面运行
|
||||
|
||||
int ComputeImage(vector<string> files, vector<int> flag_exist, double bzckesa[50][50], double *wcd, int conti)
|
||||
{
|
||||
cout << "ComputeImage" << endl;
|
||||
int i, ii, jj, size;
|
||||
double bzcu[50][50] = { 0 }; //标准差中的u
|
||||
double featurep[50][50][30] = { 0 }; //所有图像的轮廓方向特征初始化//干什么 //30
|
||||
int feature[50][50][30] = { 0 }; //所有图像的特征值
|
||||
int featx[50][50] = { 0 }; //循环赋值的feature
|
||||
int featureall; //图像特征值和 //做什么用
|
||||
|
||||
size = flag_exist.size();
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
memset(featx, 0, sizeof(featx));
|
||||
cout << "singlefeature:" << (char*)files[flag_exist[i]].c_str() << endl;
|
||||
//检查文件存在与否
|
||||
|
||||
|
||||
singlefeature((char*)files[flag_exist[i]].c_str(), featx); //featx[][50]
|
||||
featureall = 0; //图像特征值和的初始化
|
||||
for (ii = 0; ii < 48; ii++) //将featx存起来,回头看能不能用函数换掉
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
{
|
||||
feature[ii][jj][i] = featx[ii][jj];
|
||||
featureall = featureall + featx[ii][jj];
|
||||
}
|
||||
//求轮廓方向特征featurep,式(5) 与标准差中的u的和
|
||||
for (ii = 0; ii < 48; ii++)
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
{
|
||||
featurep[ii][jj][i] = (double)featx[ii][jj] / featureall;
|
||||
bzcu[ii][jj] += (double)featx[ii][jj] / featureall * 1000; //标准差的值过小,进行放大(1)
|
||||
}
|
||||
}
|
||||
//处理完一个人的每一张图片后
|
||||
for (ii = 0; ii < 48; ii++)//求标准差中的u
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
bzcu[ii][jj] = bzcu[ii][jj] / size;
|
||||
//求相似性就是带权卡方wcd
|
||||
for (i = 0; i < size; i++)
|
||||
for (ii = 0; ii < 48; ii++)
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
if (featurep[ii][jj][i] * featurep[ii][jj][conti] != 0 && bzckesa[ii][jj] != -1)
|
||||
wcd[i] += pow((featurep[ii][jj][i] - featurep[ii][jj][conti]), 2) / ((featurep[ii][jj][i] + featurep[ii][jj][conti])*bzckesa[ii][jj]);
|
||||
|
||||
memset(feature, 0, sizeof(feature));
|
||||
memset(featurep, 0, sizeof(featurep));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*主函数*/
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
if(argc<2) return -1;
|
||||
//for(int iii=0;iii<argc;iii++)
|
||||
// cout<<"argv"<<iii<<" "<<argv[iii]<<endl;
|
||||
char *fpname1 = argv[1];
|
||||
|
||||
// cout<<"开始鉴定"<<fpname1<<endl;
|
||||
//char *fpname1 = "010209400748";
|
||||
/*变量定义*/
|
||||
int i, ii, jj;
|
||||
double bzckesa[50][50] = { 0 };
|
||||
double wcd[30] = { 0 };
|
||||
|
||||
int featdif[30] = { 0 };
|
||||
float maxx = 0; //最大特征值的标号与值
|
||||
int xyimgnum = 0; //嫌疑图片的数目
|
||||
char str[80]; //存储地址
|
||||
|
||||
vector<string> suspict; //记录嫌疑图片地址
|
||||
vector<float> suspict_wcd; //嫌疑图片的wcd值
|
||||
vector<string> files; //存储该生所有考试文件路径
|
||||
vector<string> dateVec, subjectVec, stuNum2;
|
||||
vector<string> flagVec;//记录查到的学生的所有考试信息
|
||||
|
||||
//读取配置文件,并配置各项参数
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
strcat(g_log_rec, GetTime());
|
||||
if (!ReadConfig("D:/HWCV/config/configure.cfg"))
|
||||
{
|
||||
strcat(g_log_rec, ",config failed!\n");
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
return 0;
|
||||
}
|
||||
cout<<"ReadConfig success"<<endl;
|
||||
|
||||
//初始化log文件
|
||||
strcat(g_log_rec, ",");
|
||||
strcat(g_log_rec, fpname1);//考号
|
||||
strcat(g_log_rec, ",");
|
||||
|
||||
/*
|
||||
string temp=g_db_hostName;
|
||||
temp+=g_db_dBName;temp+=g_db_userName;temp+=g_db_password;
|
||||
SaveLog((char*)temp.c_str(), g_log_adr, "a");
|
||||
*/
|
||||
|
||||
/*步骤:读取标准差文件*/
|
||||
int bzccolumns = 47;//txt文件中有47列
|
||||
vector<double *> output_bzc;
|
||||
if (!ReadScanf("D:\\HWCV\\config\\stdfile.db", bzccolumns, output_bzc)) return 0;
|
||||
for (ii = 0; ii < 48; ii++)//output_vector可视为二维数组;输出数组元素:
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
bzckesa[ii][jj] = output_bzc[ii][jj];
|
||||
|
||||
//查询数据库
|
||||
string stuNum = fpname1;
|
||||
cout << "查询数据库" << endl;
|
||||
DbImg(stuNum, dateVec, subjectVec, stuNum2);
|
||||
|
||||
//生成路径();
|
||||
cout << "生成路径-dateVec的个数:" << dateVec.size() << endl;
|
||||
vector<int> flag_exist;
|
||||
fstream _file;
|
||||
for (int cp_i = 0; cp_i < dateVec.size(); cp_i++)
|
||||
{
|
||||
string path_t = CrPath(dateVec[cp_i], subjectVec[cp_i], stuNum2[cp_i]);
|
||||
cout << path_t << endl;
|
||||
SaveLog((char*)path_t.c_str(), "D:/HWCV/1.txt", "a");
|
||||
SaveLog("\n", "D:/HWCV/1.txt", "a");
|
||||
files.push_back(path_t);
|
||||
_file.open(path_t.c_str(), ios::in);
|
||||
|
||||
if (_file)
|
||||
{
|
||||
//SaveLog("OK", "D:/HWCV/1.txt", "a");
|
||||
flag_exist.push_back(cp_i);
|
||||
}
|
||||
}
|
||||
int size = flag_exist.size();
|
||||
cout << "最终size个数:" << size << endl;
|
||||
if (size == 0)
|
||||
{
|
||||
system("pause");
|
||||
return 0; //没找到人,直接返回
|
||||
}
|
||||
//开始对每一张图片进行处理
|
||||
cout << "对每一张图片进行处理" << endl;
|
||||
for (int r = 0; r < size; r++)
|
||||
{
|
||||
memset(wcd, 0, sizeof(wcd));
|
||||
ComputeImage(files, flag_exist, bzckesa, wcd, r);
|
||||
|
||||
xyimgnum = 0;
|
||||
int flagc = 0;
|
||||
//疑似作弊
|
||||
for (i = 0; i < files.size(); i++)
|
||||
{
|
||||
if (i == flag_exist[flagc])
|
||||
{
|
||||
flagc++;
|
||||
if (wcd[i]>0.12)
|
||||
{
|
||||
flagVec.push_back("1");//嫌疑标记1
|
||||
xyimgnum++;
|
||||
suspict.push_back(files[i].c_str());
|
||||
suspict_wcd.push_back(wcd[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagVec.push_back("0");//嫌疑标记1
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flagVec.push_back("0");//嫌疑标记1
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 验证作弊数量
|
||||
if (xyimgnum < 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
flagVec.clear();
|
||||
}
|
||||
|
||||
// 结果更新数据库
|
||||
cout << "更新数据库" << endl;
|
||||
DbUpdate(stuNum, dateVec, subjectVec, stuNum2, flagVec);
|
||||
|
||||
// 将结果存入log文件
|
||||
char pic_num[20];
|
||||
_itoa(size, pic_num, 10);
|
||||
strcat(g_log_rec, pic_num);
|
||||
if (xyimgnum > 0)
|
||||
{
|
||||
g_stu_sus++;
|
||||
//输出嫌疑图片数量到csv
|
||||
char b[20];
|
||||
sprintf(b, ",%d", xyimgnum);
|
||||
strcat(g_log_rec, b);
|
||||
strcat(g_log_rec, "\n");
|
||||
//逐个输出嫌疑图像
|
||||
for (i = 0; i < xyimgnum; i++)
|
||||
{
|
||||
strcat(g_log_rec, ",,,");
|
||||
strcat(g_log_rec, suspict[i].c_str());
|
||||
strcat(g_log_rec, ",");
|
||||
float sim=(1.0-suspict_wcd[i])*100;
|
||||
char a[20];
|
||||
sprintf(a, "%g", sim);
|
||||
strcat(g_log_rec, a);
|
||||
strcat(g_log_rec, "%%\n");
|
||||
}
|
||||
}
|
||||
else strcat(g_log_rec, "\n");
|
||||
//strcat(g_log_rec, "\n");
|
||||
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
cout << "结果存入log文件:" << g_log_adr <<" 完毕"<< endl;
|
||||
|
||||
|
||||
/*善后*/
|
||||
suspict.clear();
|
||||
suspict_wcd.clear();
|
||||
output_bzc.clear();
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
memset(bzckesa, 0, sizeof(bzckesa));
|
||||
memset(wcd, 0, sizeof(wcd));
|
||||
memset(featdif, 0, sizeof(featdif));
|
||||
files.clear();
|
||||
dateVec.clear();
|
||||
subjectVec.clear();
|
||||
stuNum2.clear();
|
||||
flagVec.clear();
|
||||
|
||||
system("pause");
|
||||
/*返回值*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
75
测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.h
Normal file
75
测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
头文件:segmentation.h 主函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#ifdef WIN32 //屏蔽VC6对STL的一些不完全支持造成
|
||||
#pragma warning (disable: 4514 4786)
|
||||
#endif
|
||||
#include "StdAfx.h"
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
#include "Point.h"
|
||||
#include "process.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*定义全局变量*/
|
||||
|
||||
|
||||
int g_bi_threshold = 230; /* 全局变量 二值化阈值*/
|
||||
double g_std_kesa[50][50]; /* 全局变量 标准差数组*/
|
||||
float g_doubt_threshold = 0.12; /* 全局变量 作弊嫌疑阈值*/
|
||||
string g_dir = "Y:/"; /* 全局变量 总路径的目录*/
|
||||
int g_cheat_num_threshold = 0; /* 全局变量 默认作弊阈值*/
|
||||
int g_conti = 1; /* 全局变量 默认作弊比较的图片*/
|
||||
|
||||
int g_all_img_num = 0; /* 全局变量 已鉴定的全部图片数量*/
|
||||
int g_doubt_img_num = 0; /* 全局变量 已鉴定怀疑的图片数量*/
|
||||
int g_all_stu_num = 0; /* 全局变量 已鉴定的全部学生数量*/
|
||||
int g_doubt_stu_num = 0; /* 全局变量 已鉴定怀疑的学生数量*/
|
||||
|
||||
//string g_db_hostName = "192.168.200.97"; /*全局变量 服务器ip或名称*/
|
||||
//string g_db_dBName = "purple"; /*全局变量 服务器ODBC数据源*/
|
||||
//string g_db_userName = "BJSH"; /*全局变量 服务器用户名*/
|
||||
//string g_db_password = "bjshadmin"; /*全局变量 服务器密码*/
|
||||
////string g_db_hostName = "localhost"; /*全局变量 服务器ip或名称*/
|
||||
////string g_db_dBName = "orcl123"; /*全局变量 服务器ODBC数据源*/
|
||||
////string g_db_userName = "yannsy"; /*全局变量 服务器用户名*/
|
||||
////string g_db_password = "123456"; /*全局变量 服务器密码*/
|
||||
|
||||
|
||||
/*
|
||||
string g_db_hostName = "192.168.200.97"; //全局变量 服务器ip或名称
|
||||
string g_db_dBName = "purple"; //全局变量 服务器ODBC数据源
|
||||
string g_db_userName = "BJSH"; //全局变量 服务器用户名
|
||||
string g_db_password = "bjshadmin"; //全局变量 服务器密码
|
||||
*/
|
||||
|
||||
string g_db_hostName = "localhost"; //全局变量 服务器ip或名称
|
||||
string g_db_dBName = "orcl123"; //全局变量 服务器ODBC数据源
|
||||
string g_db_userName = "yannsy"; //全局变量 服务器用户名
|
||||
string g_db_password = "123456"; //全局变量 服务器密码
|
||||
|
||||
|
||||
string g_db_qurry_start = "200906"; /*全局变量 数据库查询_开始日期*/
|
||||
string g_db_qurry_end = "201610"; /*全局变量 数据库查询_结束日期*/
|
||||
string g_db_qurry_zone = "0"; /*全局变量 数据库查询_特定区域*/
|
||||
string g_db_qurry_stu_num = "0"; /*全局变量 数据库查询_特定考号*/
|
||||
bool g_db_qurry_all = true; /*全局变量 数据库查询_查询全部标记*/
|
||||
string g_db_hoster_zk = "ZK"; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
|
||||
|
||||
bool g_output_cmd_config = false; /*全局变量 输出参数控制*/
|
||||
bool g_output_txt_config = false; /*全局变量 输出中间文件选项*/
|
||||
char g_log_adr[50] = "D:/HWCV/log_ori.txt"; /*全局变量 程序日志存储地址*/
|
||||
char g_log_rec[500] = { 0 }; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 输出txt结果文件*/
|
||||
/*全局变量 输出txt结果文件地址*/
|
||||
|
||||
|
||||
|
||||
time_t g_ltime;
|
||||
char *g_srcTime=NULL;
|
||||
char g_timeNow[32]={0};
|
||||
char g_msg[100]={0};
|
||||
int g_stu_sus;
|
||||
22
测试/本机测试/1-我-算法/HWCV-exe.sln
Normal file
22
测试/本机测试/1-我-算法/HWCV-exe.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HWCV-exe", "HWCV-exe\HWCV-exe.vcxproj", "{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
209
测试/本机测试/1-我-算法/HWCV-exe/DBop.cpp
Normal file
209
测试/本机测试/1-我-算法/HWCV-exe/DBop.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
实现文件:DBop.cpp 数据库操作实现文件
|
||||
*/
|
||||
#include "DBop.h"
|
||||
#include "path.h"
|
||||
|
||||
/*本地的全局变量*/
|
||||
|
||||
_ConnectionPtr p_conn; /*全局变量 连接对象*/
|
||||
_RecordsetPtr p_recordset; /*全局变量 记录集对象*/
|
||||
_CommandPtr p_cmd; /*全局变量 操作集对象*/
|
||||
string str_conn; /*全局变量 连接字符串设置*/
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 根据string类的stu【存储学号】,搜索出所有此人的考试信息,并分别存储在不同的变量中
|
||||
|
||||
@变量 stuNum 学号
|
||||
@变量 date<vector> 考试时间
|
||||
@变量 subject<vector> 考试科目
|
||||
@变量 stuNum<vector> 考号
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2)//搜寻图片
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
//cout<<g_db_userName.c_str()<<endl;
|
||||
//cout<<g_db_password.c_str()<<endl;
|
||||
//cout<<g_db_hostName.c_str()<<endl;
|
||||
//cout<<g_db_dBName.c_str()<<endl;
|
||||
|
||||
/*创建链接描述符*/
|
||||
//Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = BJSH;Password=bjshadmin;Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.200.97)(PORT=1521))
|
||||
//(CONNECT_DATA=(SERVICE_NAME=purple)))",
|
||||
str_conn = "Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = ";
|
||||
str_conn += userName; //===仅初始化一次===//
|
||||
str_conn += ";Password="; //==================//
|
||||
str_conn += password;
|
||||
str_conn += ";Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=";
|
||||
str_conn += hostName;
|
||||
str_conn += ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=";
|
||||
str_conn += dBName;
|
||||
str_conn += ")))";
|
||||
|
||||
//构造查询语句 下句注释是sql语句,需要构造成这种类型
|
||||
/*select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010207203867*/
|
||||
/*string sql = "select KS_ZKZ2, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201504' AND KS_ZKZ = ";*/
|
||||
// select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225
|
||||
//"select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225",
|
||||
string sql = "select KS_ZKZ, KSSJ, TJ_KC_DM from ";
|
||||
sql += g_db_hoster_zk;
|
||||
sql += ".T_BYSQ_KS_KC WHERE KSSJ between ";
|
||||
sql += g_db_qurry_start;
|
||||
sql += " and ";
|
||||
sql += g_db_qurry_end;
|
||||
sql += "AND KS_ZKZ =";
|
||||
sql += stuNum.c_str();
|
||||
|
||||
_bstr_t _vstr_sql(sql.c_str());/* 转换string为_variant_t */
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
/*创建、打开连接*/
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()),
|
||||
//p_conn->Open("Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = BJSH;Password=bjshadmin;Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.200.97)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=purple)))",
|
||||
_bstr_t(userName.c_str()),
|
||||
_bstr_t(password.c_str()),
|
||||
adConnectUnspecified);
|
||||
|
||||
|
||||
|
||||
|
||||
// SaveLog((char*)str_conn.c_str(), g_log_adr, "a");
|
||||
HRESULT hr = p_recordset->Open(_bstr_t(_vstr_sql),//执行sq语句,查询一个学生的所有考试信息
|
||||
//HRESULT hr = p_recordset->Open("select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010214100225",
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
cout<<"count:"<<p_recordset->RecordCount <<endl;
|
||||
//将结果集输出到三个vector变量中
|
||||
if (p_recordset->RecordCount < 1)//结果集为空
|
||||
{
|
||||
return 0;//没有信息,直接跳过这个人
|
||||
}
|
||||
do{ //将结果集输出到三个vector变量中
|
||||
dateVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KSSJ"))->GetValue()));
|
||||
subjectVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("TJ_KC_DM"))->GetValue()));
|
||||
stuNum2.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ"))->GetValue()));
|
||||
p_recordset->MoveNext();
|
||||
} while (!p_recordset->EndOfFile);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
/*printf("%x", e.Error());
|
||||
cout<<"Failed"<<endl;*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
|
||||
strcat(g_log_rec, "DBImg-Err:");
|
||||
strcat(g_log_rec, (char*)e.Description());
|
||||
strcat(g_log_rec, " ");
|
||||
strcat(g_log_rec, (char*)e.Error());
|
||||
strcat(g_log_rec, " ");
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
|
||||
::CoUninitialize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*关闭查询*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
|
||||
|
||||
@变量 stuNum:学号
|
||||
@变量 subject:考试科目
|
||||
@变量 flagCheat:作弊标记
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec)
|
||||
{
|
||||
/*字符转换,方便使用*/
|
||||
string userName(g_db_userName.c_str());
|
||||
string password(g_db_password.c_str());
|
||||
string hostName(g_db_hostName.c_str());
|
||||
string dBName(g_db_dBName.c_str());
|
||||
|
||||
/*更新字串设置*/
|
||||
int count = subjectVec.size();
|
||||
vector<string> sqlKC; //课程表:作弊第一字段
|
||||
int ci = 0; //循环
|
||||
|
||||
|
||||
/*构造更新语句*/
|
||||
for (ci = 0; ci < count; ++ci)
|
||||
{
|
||||
/*作弊的*/
|
||||
string sqlKC1 = "UPDATE ";
|
||||
sqlKC1 += g_db_hoster_zk;
|
||||
sqlKC1 += ".T_BYSQ_KS_KC SET BJSH_JG_JQ =";//天津_课程_代码
|
||||
sqlKC1 += flagVec[ci].c_str();
|
||||
sqlKC1 += " WHERE KS_ZKZ2=";
|
||||
sqlKC1 += stuNum2[ci].c_str();
|
||||
sqlKC1 += " AND TJ_KC_DM=";
|
||||
sqlKC1 += subjectVec[ci].c_str();
|
||||
sqlKC1 += " AND KSSJ=";
|
||||
sqlKC1 += dateVec[ci].c_str();
|
||||
sqlKC1 += " AND KS_ZKZ=";
|
||||
sqlKC1 += stuNum.c_str();
|
||||
|
||||
sqlKC.push_back(sqlKC1);
|
||||
}
|
||||
|
||||
::CoInitialize(NULL);//初始化com组件
|
||||
|
||||
/*更新数据库表*/
|
||||
try{
|
||||
p_conn.CreateInstance("ADODB.Connection");//创建连接
|
||||
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
|
||||
p_cmd.CreateInstance("ADODB.Command");
|
||||
|
||||
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
|
||||
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
|
||||
p_cmd->ActiveConnection = p_conn;
|
||||
|
||||
for (ci = 0; ci < count; ++ci)
|
||||
{
|
||||
p_recordset->Open(_bstr_t(sqlKC[ci].c_str()),//更新第二条
|
||||
p_conn.GetInterfacePtr(),
|
||||
adOpenStatic,
|
||||
adLockOptimistic,
|
||||
adCmdText);
|
||||
}
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
|
||||
strcat(g_log_rec, "DBUpdate-Err:");
|
||||
strcat(g_log_rec, (char*)e.Description());
|
||||
strcat(g_log_rec, " ");
|
||||
strcat(g_log_rec, (char*)e.Error());
|
||||
strcat(g_log_rec, " ");
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
|
||||
::CoUninitialize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*关闭查询*/
|
||||
::CoUninitialize();
|
||||
|
||||
return 1;
|
||||
}
|
||||
55
测试/本机测试/1-我-算法/HWCV-exe/DBop.h
Normal file
55
测试/本机测试/1-我-算法/HWCV-exe/DBop.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
头文件:DBop.h 数据库操作头文件
|
||||
*/
|
||||
#pragma once
|
||||
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile")
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
extern FILE *g_log_fpzz; /*全局变量 程序日志专用文件句柄*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk; /*全局变量 数据库用户,zk(考试院的zk,本地的yannsy)*/
|
||||
/*****************************************函数原型*************************************/
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 根据string类的stu【存储学号】,搜索出所有此人的考试信息,并分别存储在不同的变量中
|
||||
|
||||
@变量 stuNum 学号
|
||||
@变量 date<vector> 考试时间
|
||||
@变量 subject<vector> 考试科目
|
||||
@变量 stuNum<vector> 考号
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2);
|
||||
|
||||
|
||||
/**
|
||||
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
|
||||
|
||||
@变量 stuNum:学号
|
||||
@变量 subject:考试科目
|
||||
@变量 flagCheat:作弊标记
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec);
|
||||
106
测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj
Normal file
106
测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{FB6A1EE7-710E-424B-A80E-A931EDB7DDBF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>HWCVexe</RootNamespace>
|
||||
<ProjectName>HWCV</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<LibraryPath>C:\Program Files %28x86%29\OpenCV\lib;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86)</LibraryPath>
|
||||
<ExecutablePath>C:\Program Files %28x86%29\OpenCV\otherlibs;C:\Program Files %28x86%29\OpenCV\bin;C:\Program Files %28x86%29\OpenCV\cvaux\include;$(VC_ExecutablePath_x86);$(WindowsSdk_71A_ExecutablePath);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH)</ExecutablePath>
|
||||
<IncludePath>C:\Program Files %28x86%29\OpenCV\cv\include;C:\Program Files %28x86%29\OpenCV\cvaux\include;C:\Program Files %28x86%29\OpenCV\cxcore\include;C:\Program Files %28x86%29\OpenCV\ml\include;C:\Program Files %28x86%29\OpenCV\otherlibs\highgui;C:\Program Files (x86)\OpenCV\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.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;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>cv.lib;cvaux.lib;cxcore.lib;highgui.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</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="path.h" />
|
||||
<ClInclude Include="Point.h" />
|
||||
<ClInclude Include="process.h" />
|
||||
<ClInclude Include="segmentation.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="path.cpp" />
|
||||
<ClCompile Include="process.cpp" />
|
||||
<ClCompile Include="segmentation.cpp" />
|
||||
<ClCompile Include="seg_bck.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
51
测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj.filters
Normal file
51
测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj.filters
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="path.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Point.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="process.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="segmentation.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="path.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="process.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="segmentation.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="seg_bck.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
13
测试/本机测试/1-我-算法/HWCV-exe/Point.h
Normal file
13
测试/本机测试/1-我-算法/HWCV-exe/Point.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
头文件:Point.h 图像中的像素点定义
|
||||
*/
|
||||
#pragma once
|
||||
class Point{
|
||||
private:
|
||||
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
void setpoint(int a,int b){x=a;y=b;}
|
||||
};
|
||||
8
测试/本机测试/1-我-算法/HWCV-exe/StdAfx.cpp
Normal file
8
测试/本机测试/1-我-算法/HWCV-exe/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// HWCV.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
24
测试/本机测试/1-我-算法/HWCV-exe/StdAfx.h
Normal file
24
测试/本机测试/1-我-算法/HWCV-exe/StdAfx.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
#define AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
// Insert your headers here
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__0B833134_257D_4F21_9707_24C780138809__INCLUDED_)
|
||||
264
测试/本机测试/1-我-算法/HWCV-exe/path.cpp
Normal file
264
测试/本机测试/1-我-算法/HWCV-exe/path.cpp
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
实现文件:path.cpp 路径操作实现文件
|
||||
*/
|
||||
#include "path.h"
|
||||
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime()
|
||||
{
|
||||
time( <ime );
|
||||
srcTime = ctime( <ime );
|
||||
strncpy(timeNow, srcTime, strlen(srcTime)-1); //不拷贝换行
|
||||
timeNow[strlen(srcTime)-1] = '\0'; //加结束符'\0'
|
||||
|
||||
return timeNow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum)
|
||||
{
|
||||
string temp = g_dir; temp += date; temp += "/";
|
||||
temp += subject.substr(0, 4); temp += "/";
|
||||
temp += stuNum; temp += ".jpg";
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector)
|
||||
{
|
||||
// 功能:将filename 中的数据(共cols列)读取到_vector中,_vector可视为二维数组
|
||||
FILE *fp = fopen(filename.c_str(), "r");//打开并读取文件
|
||||
bool flag = true;
|
||||
int i = 0;
|
||||
|
||||
// printf("--read_scanf--");
|
||||
if (!fp){ return 0; }
|
||||
while (flag){
|
||||
double *point = new double[cols];
|
||||
for (i = 0; i<cols; i++){ //读取数据,存在_vector[cols]中
|
||||
if (EOF == fscanf(fp, "%lf", &point[i])) {
|
||||
flag = false; break;
|
||||
}
|
||||
if (EOF == fgetc(fp)) {
|
||||
flag = false; i++; break;
|
||||
}
|
||||
}
|
||||
if (cols == i)
|
||||
_vector.push_back(point);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename)
|
||||
{
|
||||
ifstream file(filename);
|
||||
|
||||
if (!file)/*"配置文件不存在!"*/
|
||||
{
|
||||
/*写入时间*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
cout<<"read"<<endl;
|
||||
|
||||
strcat(g_log_rec, "--ERR:配置文件不存在!");
|
||||
SaveLog(g_log_rec, g_err_adr, "a");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*步骤:开始读取信息*/
|
||||
|
||||
string temp;/*仅用作过滤字符*/
|
||||
file >> temp >> temp;
|
||||
/*---此行6个,参考配置信息:图片对比参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >>temp;
|
||||
file >> g_dir >> temp >> temp >> temp;
|
||||
string g_log_adr_t;
|
||||
file >> g_log_adr_t >> temp;
|
||||
|
||||
memset(g_log_adr, 0, sizeof(g_log_adr));
|
||||
strcpy(g_log_adr, (char*)g_log_adr_t.c_str());
|
||||
|
||||
|
||||
/*---此行6个,参考配置信息:网络配置参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
|
||||
/*---此行5个,参考配置信息:控制参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
/*---此行5个,参考配置信息:数据库查询参数*/
|
||||
file >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp >> temp;
|
||||
|
||||
file.close();/*关闭文件句柄*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *txt, string txt_file_path, char *type)
|
||||
{
|
||||
FILE* fpzz = fopen(txt_file_path.c_str(), type); //创建文件
|
||||
if (NULL == fpzz)
|
||||
{
|
||||
return 0;
|
||||
}//要返回错误代码
|
||||
fprintf(fpzz, txt); //从控制台中读入并在文本输出
|
||||
fclose(fpzz);
|
||||
fpzz = NULL;//需要指向空,否则会指向原打开文件地址
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像(不实现,没有必要)
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:获取指定目录下的文件
|
||||
@变量 path 路径
|
||||
@变量 files 输出vector格式的文件
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:获取指定目录下的目录
|
||||
@变量 path 目录
|
||||
@变量 files 返回的目录vector
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:搜索目录
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
122
测试/本机测试/1-我-算法/HWCV-exe/path.h
Normal file
122
测试/本机测试/1-我-算法/HWCV-exe/path.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
头文件:path.h 与路径相关操作的函数头文件以及函数原型
|
||||
*/
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cv.h>
|
||||
#include <io.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
extern int g_bi_threshold; /*全局变量 二值化阈值*/
|
||||
extern double g_std_kesa[50][50]; /*全局变量 标准差数组*/
|
||||
extern float g_doubt_threshold; /*全局变量 作弊嫌疑阈值*/
|
||||
extern string g_dir; /*全局变量 总路径的目录*/
|
||||
extern int g_conti; /*全局变量 比较标准*/
|
||||
|
||||
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
|
||||
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
|
||||
extern string g_db_userName; /*全局变量 服务器用户名*/
|
||||
extern string g_db_password; /*全局变量 服务器密码*/
|
||||
|
||||
extern char g_log_adr[50]; /*全局变量 程序日志存储地址*/
|
||||
extern char g_err_adr[50]; /*全局变量 错误日志存储地址*/
|
||||
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
|
||||
/*全局变量 待定*/
|
||||
/*全局变量 待定*/
|
||||
|
||||
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
|
||||
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
|
||||
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
|
||||
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
|
||||
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
|
||||
extern string g_db_hoster_zk;
|
||||
|
||||
|
||||
|
||||
extern time_t ltime;
|
||||
extern char *srcTime;
|
||||
extern char timeNow[32];
|
||||
extern char msg[100];
|
||||
|
||||
/**
|
||||
获取并返回当前时间
|
||||
*/
|
||||
char* GetTime();
|
||||
|
||||
|
||||
/**
|
||||
根据学生信息创建文件路径,用于文件读取
|
||||
|
||||
@变量 date 考试日期
|
||||
@变量 subject 考试科目
|
||||
@变量 stuNum 考号
|
||||
@返回值 返回生成的文件路径
|
||||
*/
|
||||
string CrPath(string date, string subject, string stuNum);
|
||||
|
||||
|
||||
/*
|
||||
功能:读取标准差文件
|
||||
@变量 filesname 文件名
|
||||
@变量 col 行数
|
||||
@变量 _vector 读取到的标准差存到vector中
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int ReadScanf(const string &filename, const int &cols, vector<double *> &_vector);
|
||||
|
||||
|
||||
/**
|
||||
读取配置文件,并配置各项参数
|
||||
|
||||
@变量 filename 配置文件的路径
|
||||
@返回值 成功1 失败0
|
||||
*/
|
||||
int ReadConfig(char *filename);
|
||||
|
||||
|
||||
/**
|
||||
函数功能:存储过程数据到txt文件
|
||||
|
||||
@变量: record 存储的语句
|
||||
@变量 g_txt_file_path 存储的位置
|
||||
@返回值 1成功 0失败
|
||||
*/
|
||||
int SaveLog(char *record, string txt_file_path, char *type);
|
||||
|
||||
|
||||
/*
|
||||
功能:保存中间鉴定图像
|
||||
@变量
|
||||
@变量
|
||||
@返回值
|
||||
*/
|
||||
int SaveImg(IplImage *img, char *g_process_img_adr);
|
||||
|
||||
|
||||
/*
|
||||
功能:获取指定目录下的文件
|
||||
@变量 path 路径
|
||||
@变量 files 输出vector格式的文件
|
||||
*/
|
||||
void getFiles(string path, vector<string>& files);
|
||||
|
||||
|
||||
/*
|
||||
功能:获取指定目录下的目录
|
||||
@变量 path 目录
|
||||
@变量 files 返回的目录vector
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int getFolders(string path, vector<string>& files);
|
||||
|
||||
|
||||
/*
|
||||
功能:搜索目录
|
||||
*/
|
||||
int searchDir(char *path, vector<string> &dir);
|
||||
665
测试/本机测试/1-我-算法/HWCV-exe/process.cpp
Normal file
665
测试/本机测试/1-我-算法/HWCV-exe/process.cpp
Normal file
@@ -0,0 +1,665 @@
|
||||
/*
|
||||
实现文件:process.cpp 图像处理过程的实现文件
|
||||
*/
|
||||
#include "process.h"
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int g_bi_threshold)
|
||||
{
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int i, j;
|
||||
static int black[1000]; //C语言不提倡返回一个局部变量的地址以外的功能,所以你必须定义的局部变量,如静态变量。
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*二值化,并统计黑像素的个数*/
|
||||
for (i = 0; i<height; i++)
|
||||
{
|
||||
for (j = 0; j<width; j++)//对图像每个点进行二值化,原值为128
|
||||
data[i*step + j*channels] = (data[i*step + j*channels]>g_bi_threshold) ? 255 : 0;
|
||||
}
|
||||
|
||||
/*计算每一行的黑像素个数*/
|
||||
int tempBlackPixel = 0;
|
||||
|
||||
memset(black, 0, 1000); //##初始化内存,这里用做清零black数组
|
||||
for (i = height - 1; i>0; i--)
|
||||
{
|
||||
for (int j = 0; j<width; j++)
|
||||
{
|
||||
if (data[i*step + j*channels] == 0) //计算黑色的像素数
|
||||
tempBlackPixel += 1;
|
||||
}
|
||||
black[height - i] = tempBlackPixel; //black记录黑色像素数
|
||||
tempBlackPixel = 0;
|
||||
}
|
||||
//二值化,并统计黑像素的个数**********
|
||||
return black;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j, jbi = 0, jbj = 0;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
int brklab = 0;
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
// IplImage* imgjbsb = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
|
||||
cvCopy(img, imgjbsb, NULL);
|
||||
uchar *imgjbsbdata = (uchar *)imgjbsb->imageData;
|
||||
|
||||
//以角标为起点进行裁剪与画框
|
||||
CvSize jbcjsize = cvSize(835, 165); //角标裁剪框的大小,宽为835象素,高为165象素
|
||||
IplImage* imgjbcj = cvCreateImage(jbcjsize, img->depth, img->nChannels);
|
||||
uchar *imgjbcjdata = (uchar *)imgjbcj->imageData;
|
||||
int jbcjstep = imgjbcj->widthStep;
|
||||
int jbcjchannels = imgjbcj->nChannels;
|
||||
for (i = 0; i<165; i++)
|
||||
for (j = 0; j<835; j++)
|
||||
imgjbcjdata[i*jbcjstep + j*jbcjchannels] = data[(i + jbi)*step + (j + jbj)*channels];
|
||||
for (i = 0; i<165; i = i + 2)
|
||||
{
|
||||
imgjbsbdata[(i + jbi)*step + jbj*channels] = 0;
|
||||
imgjbsbdata[(i + jbi)*step + (jbj + 835)*channels] = 0;
|
||||
}
|
||||
for (j = 0; j<835; j = j + 2)
|
||||
{
|
||||
imgjbsbdata[jbi*step + (j + jbj)*channels] = 0;
|
||||
imgjbsbdata[(jbi + 165)*step + (j + jbj)*channels] = 0;
|
||||
}
|
||||
|
||||
return imgjbcj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
/*定义新的图像*/
|
||||
IplImage* imglk = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels);
|
||||
|
||||
/* 获取图像信息*/
|
||||
height = imgbj->height;
|
||||
width = imgbj->width;
|
||||
step = imgbj->widthStep;
|
||||
channels = imgbj->nChannels;
|
||||
data = (uchar *)imgbj->imageData;
|
||||
|
||||
// printf("--outline--");
|
||||
for (j = 0; j<height; j++){
|
||||
for (i = 0; i<width; i++){
|
||||
imglk->imageData[j*step + i*channels] = 255;
|
||||
}
|
||||
for (i = 0; i<width - 1; i++){
|
||||
if (data[j*step + (i + 1)*channels] - data[j*step + i*channels] == 255) //竖线右侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
else if (data[j*step + i*channels] - data[j*step + (i + 1)*channels] == 255) //竖线左侧框
|
||||
imglk->imageData[j*step + (i + 1)*channels] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<width; i++){
|
||||
for (j = 0; j<height - 1; j++){
|
||||
if (data[j*step + i*channels] - data[(j + 1)*step + i*channels] == 255) //横线下侧框
|
||||
imglk->imageData[(j + 1)*step + i*channels] = 0;
|
||||
else if (data[(j + 1)*step + i*channels] - data[j*step + i*channels] == 255) //横线上侧框
|
||||
imglk->imageData[j*step + i*channels] = 0;
|
||||
}
|
||||
}
|
||||
return imglk;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
int i, j;
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int feat[50][50] = { 0 }; //特征值初始化
|
||||
Point featblk[32]; //标记相同H的黑点坐标
|
||||
int featk; //标记相同H的黑点数目
|
||||
int m; //for 里面的变量
|
||||
// printf("--outlinefeature--");
|
||||
// 获取图像信息
|
||||
height = imglk->height;
|
||||
width = imglk->width;
|
||||
step = imglk->widthStep;
|
||||
channels = imglk->nChannels;
|
||||
data = (uchar *)imglk->imageData;
|
||||
|
||||
//初始化特征矩阵 最大值为47 ,非空的特征字有1081个
|
||||
int outllab[9][9] = { \
|
||||
{3, 37, 10, 36, 2, 35, 9, 34, 1}, { 38, 3, 21, 20, 2, 19, 18, 1, 33 }, \
|
||||
{11, 22, 3, 10, 2, 9, 1, 17, 8}, { 39, 23, 11, 3, 2, 1, 8, 16, 32 }, \
|
||||
{4, 4, 4, 4, 0, 0, 0, 0, 0}, { 40, 24, 12, 5, 6, 7, 15, 31, 47 }, \
|
||||
{12, 25, 5, 13, 6, 14, 7, 30, 15}, { 41, 5, 26, 27, 6, 28, 29, 7, 46 }, \
|
||||
{5, 42, 13, 43, 6, 44, 14, 45, 7} };
|
||||
|
||||
|
||||
for (i = 4; i <= width - 5; i++){
|
||||
for (j = 4; j <= height - 5; j++){
|
||||
if (data[j*step + i*channels] == 0){
|
||||
//**************H=1
|
||||
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
if (data[j*step + (i + 1)*channels] == 0){ //右侧点
|
||||
featblk[featk].x = i + 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i + 1; m >= i - 1; m--){ //上排点
|
||||
if (data[(j - 1)*step + m*channels] == 0) {
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
if (data[j*step + (i - 1)*channels] == 0){ //左侧点
|
||||
featblk[featk].x = i - 1;
|
||||
featblk[featk].y = j;
|
||||
featk++;
|
||||
}
|
||||
for (m = i - 1; m <= i + 1; m++) { //下排点
|
||||
if (data[(j + 1)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 1;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=1*******************
|
||||
|
||||
|
||||
//*********************H=2
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 1; m >= j - 2; m--){
|
||||
if (data[m*step + (i + 2)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 1; m >= i - 2; m--){ //上排点
|
||||
if (data[(j - 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 1; m <= j + 2; m++){ //左侧点
|
||||
if (data[m*step + (i - 2)*channels] == 0){
|
||||
featblk[featk].x = i - 2;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 1; m <= i + 2; m++){ //下排点
|
||||
if (data[(j + 2)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 2;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=2********************
|
||||
|
||||
//*********************H=3
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 2; m >= j - 3; m--){
|
||||
if (data[m*step + (i + 3)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 2; m >= i - 3; m--){ //上排点
|
||||
if (data[(j - 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 2; m <= j + 3; m++){ //左侧点
|
||||
if (data[m*step + (i - 3)*channels] == 0){
|
||||
featblk[featk].x = i - 3;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 2; m <= i + 3; m++){ //下排点
|
||||
if (data[(j + 3)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 3;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=3********************
|
||||
|
||||
//*********************H=4
|
||||
memset(featblk, 0, sizeof(Point) * 32); //归零
|
||||
featk = 0;
|
||||
|
||||
for (m = j + 3; m >= j - 4; m--){
|
||||
if (data[m*step + (i + 4)*channels] == 0){ //右排点
|
||||
featblk[featk].x = i + 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i + 3; m >= i - 4; m--) { //上排点
|
||||
if (data[(j - 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j - 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = j - 3; m <= j + 4; m++){ //左侧点
|
||||
if (data[m*step + (i - 4)*channels] == 0){
|
||||
featblk[featk].x = i - 4;
|
||||
featblk[featk].y = m;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
for (m = i - 3; m <= i + 4; m++){ //下排点
|
||||
if (data[(j + 4)*step + m*channels] == 0){
|
||||
featblk[featk].x = m;
|
||||
featblk[featk].y = j + 4;
|
||||
featk++;
|
||||
}
|
||||
}
|
||||
//统计特征点
|
||||
if (featk >= 2){
|
||||
for (m = 1; m <= featk - 1; m++){
|
||||
feat[outllab[featblk[m - 1].x - i + 4][featblk[m - 1].y - j + 4]][outllab[featblk[m].x - i + 4][featblk[m].y - j + 4]]++;
|
||||
}
|
||||
}
|
||||
//H=4***********************
|
||||
}// if
|
||||
} //for j
|
||||
} //for i
|
||||
|
||||
//****注:最终特征值为feat(x,y)+feat(y,x),放入feat(x,y)中,x<y
|
||||
for (i = 1; i<50; i++)
|
||||
for (j = 0; j<i; j++){
|
||||
feat[j][i] = feat[i][j] + feat[j][i];
|
||||
feat[i][j] = 0;
|
||||
}
|
||||
memcpy(feature, feat, 2500 * 4); //int有四个字节
|
||||
// printf("轮廓特征值计算完成\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50])
|
||||
{
|
||||
//定义变量
|
||||
//原图
|
||||
IplImage* imglk = 0; //轮廓图
|
||||
IplImage* imggj = 0; //骨架图
|
||||
IplImage* imgjbsb = 0; //角标识别图
|
||||
IplImage* imgbj = 0; //只提取笔记部分的图像
|
||||
IplImage* imgbjhf = 0; //为文字区域画上方格
|
||||
IplImage* imgwzbj = 0; //为文字区域标出是否为文字(文字标记)
|
||||
|
||||
int height, width, step, channels;
|
||||
uchar *data;
|
||||
|
||||
int i, j; //用于返回图像每行黑像素的个数
|
||||
//int feature[50][50]={0}; //特征值初始化
|
||||
|
||||
IplImage* img = cvLoadImage(path, 0);
|
||||
|
||||
/* 获取图像信息*/
|
||||
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*开始处理*/
|
||||
|
||||
/*图像放大*/
|
||||
IplImage* imgbig = 0; //原图的放大图
|
||||
CvSize dst_cvsize; //目标图像的大小
|
||||
float scale = 1;
|
||||
if (width<840){
|
||||
scale = (float)840 / width;
|
||||
dst_cvsize.width = 840;
|
||||
dst_cvsize.height = (int)(height*scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_cvsize.width = width;
|
||||
dst_cvsize.height = height;
|
||||
}
|
||||
|
||||
imgbig = cvCreateImage(dst_cvsize, img->depth, img->nChannels);
|
||||
cvResize(img, imgbig, CV_INTER_LINEAR); // CV_INTER_NN - 最近邻插值,
|
||||
//CV_INTER_LINEAR - 双线性插值 (缺省使用),
|
||||
//CV_INTER_AREA - 使用象素关系重采样。当图像缩小时候,该方法可以避免波纹出现。
|
||||
//CV_INTER_CUBIC - 立方插值.
|
||||
|
||||
/*二值化*/
|
||||
binary(imgbig, g_bi_threshold);
|
||||
//SaveLog("singlefeature_binary\n", "D:\\HWCV\\numtxt.txt", "a");
|
||||
|
||||
|
||||
|
||||
/*裁剪识别*/
|
||||
int jbwhite = 5, jbblack = 4;
|
||||
imgjbsb = cvCreateImage(cvGetSize(imgbig), imgbig->depth, imgbig->nChannels);
|
||||
imgbj = Cjbsb(imgbig, imgjbsb, jbwhite, jbblack); //返回文字的笔迹部分
|
||||
|
||||
|
||||
/*计算骨架图*/
|
||||
imggj = cvCreateImage(cvGetSize(imgbj), imgbj->depth, imgbj->nChannels); //复制
|
||||
cvCopy(imgbj, imggj, NULL);
|
||||
uchar *gjdata = (uchar *)imggj->imageData;
|
||||
|
||||
beforethin(gjdata, gjdata, imggj->width, imggj->height);
|
||||
|
||||
/*笔迹图像颜色范围转换,以进行细化*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--1
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 255)
|
||||
gjdata[j*imggj->widthStep + i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*细化*/
|
||||
ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width);
|
||||
|
||||
/*笔记图像颜色范围转化回正常水平*/
|
||||
for (j = 0; j<imggj->height; j++)//取值范围转到0--255,反转过来
|
||||
{
|
||||
for (i = 0; i<imggj->width; i++)
|
||||
{
|
||||
if (gjdata[j*imggj->widthStep + i] == 1)
|
||||
gjdata[j*imggj->widthStep + i] = 0;
|
||||
else
|
||||
gjdata[j*imggj->widthStep + i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
/*计算骨架特征徝*/
|
||||
outlinefeature(imggj, feature); //特征值占48*48的右上三角形,feature调用返回
|
||||
|
||||
/*释放内存*/
|
||||
cvReleaseImage(&imgbig);
|
||||
cvReleaseImage(&img);
|
||||
cvReleaseImage(&imgbj);
|
||||
cvReleaseImage(&imglk);
|
||||
cvReleaseImage(&imgjbsb);
|
||||
cvReleaseImage(&imgbjhf);
|
||||
cvReleaseImage(&imgwzbj);
|
||||
cvDestroyAllWindows();
|
||||
|
||||
return imggj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
unsigned long i, j;
|
||||
|
||||
for (i = 0; i<ly; i++){
|
||||
for (j = 0; j<lx; j++){
|
||||
//这里要视前景是白点还是黑点而定,可以改动
|
||||
//如果前景是白点,就是这样;反之反过来
|
||||
//jp[i*lx+j]=ip[i*lx+j];
|
||||
/* jp[i*lx+j]=255;*/
|
||||
if (ip[i*lx + j]>0)
|
||||
jp[i*lx + j] = 0;
|
||||
else
|
||||
jp[i*lx + j] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly)
|
||||
{
|
||||
char *f, *g;
|
||||
char n[10];
|
||||
char a[5] = { 0, -1, 1, 0, 0 };
|
||||
char b[5] = { 0, 0, 0, 1, -1 };
|
||||
char nrnd, cond, n48, n26, n24, n46, n68, n82, n123, n345, n567, n781;
|
||||
short k, shori;
|
||||
unsigned long i, j;
|
||||
long ii, jj, kk, kk1, kk2, kk3, size;
|
||||
|
||||
// printf("--Thinner_Rosenfeld--");
|
||||
size = (long)lx * (long)ly;
|
||||
|
||||
g = (char *)malloc(size);
|
||||
if (g == NULL){
|
||||
printf("error in alocating mmeory!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
f = (char *)image;
|
||||
for (kk = 0l; kk<size; kk++){
|
||||
g[kk] = f[kk];
|
||||
}
|
||||
|
||||
do{
|
||||
shori = 0;
|
||||
for (k = 1; k <= 4; k++){
|
||||
for (i = 1; i<lx - 1; i++){
|
||||
ii = i + a[k];
|
||||
|
||||
for (j = 1; j<ly - 1; j++){
|
||||
kk = i*ly + j;
|
||||
|
||||
if (!f[kk])
|
||||
continue;
|
||||
|
||||
jj = j + b[k];
|
||||
kk1 = ii*ly + jj;
|
||||
|
||||
if (f[kk1])
|
||||
continue;
|
||||
|
||||
kk1 = kk - ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk3 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[8] = f[kk3];
|
||||
kk1 = kk + ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
|
||||
nrnd = n[1] + n[2] + n[3] + n[4]
|
||||
+ n[5] + n[6] + n[7] + n[8];
|
||||
if (nrnd <= 1)
|
||||
continue;
|
||||
|
||||
cond = 0;
|
||||
n48 = n[4] + n[8];
|
||||
n26 = n[2] + n[6];
|
||||
n24 = n[2] + n[4];
|
||||
n46 = n[4] + n[6];
|
||||
n68 = n[6] + n[8];
|
||||
n82 = n[8] + n[2];
|
||||
n123 = n[1] + n[2] + n[3];
|
||||
n345 = n[3] + n[4] + n[5];
|
||||
n567 = n[5] + n[6] + n[7];
|
||||
n781 = n[7] + n[8] + n[1];
|
||||
|
||||
if (n[2] == 1 && n48 == 0 && n567>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[6] == 1 && n48 == 0 && n123>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[8] == 1 && n26 == 0 && n345>0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[4] == 1 && n26 == 0 && n781>0) {
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[5] == 1 && n46 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[7] == 1 && n68 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[1] == 1 && n82 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
if (n[3] == 1 && n24 == 0){
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
cond = 1;
|
||||
if (!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<lx; i++){
|
||||
for (j = 0; j<ly; j++){
|
||||
kk = i*ly + j;
|
||||
f[kk] = g[kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (shori);
|
||||
free(g);
|
||||
}
|
||||
97
测试/本机测试/1-我-算法/HWCV-exe/process.h
Normal file
97
测试/本机测试/1-我-算法/HWCV-exe/process.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
头文件:process.h 图像处理函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#include "Point.h"
|
||||
#include "path.h"
|
||||
#include "process.h"
|
||||
#include <cv.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <highgui.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*全局变量*/
|
||||
extern IplImage* src;
|
||||
|
||||
/***************************************函数原型****************************************/
|
||||
|
||||
/*
|
||||
功能:读入图像文件,进行二值化
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 bithro 二值化阈值
|
||||
@返回值 黑像素的数目(待用)
|
||||
*/
|
||||
int* binary(IplImage* img, int bithro);
|
||||
|
||||
|
||||
/*
|
||||
功能:读入图像文件,对图像进行裁剪
|
||||
|
||||
@变量 img iplimage图像文件
|
||||
@变量 img 裁剪后的iplimage图像文件
|
||||
@jbwhite
|
||||
@jbblack
|
||||
@返回值 返回裁剪后的图像
|
||||
*/
|
||||
IplImage* Cjbsb(IplImage* img, IplImage* imgjbsb, int jbwhite, int jbblack);
|
||||
|
||||
|
||||
/*
|
||||
功能:计算图像的特征
|
||||
|
||||
@变量 imgbj 笔迹部分的图像
|
||||
@返回值 计算得到的特征图像
|
||||
*/
|
||||
IplImage* outline(IplImage* imgbj);
|
||||
|
||||
|
||||
/*
|
||||
功能:输入图像的特征轮廓图,返回图像的特征值
|
||||
@变量 imglk 输入的图像轮廓图
|
||||
@变量 feature 得到的图像特征
|
||||
@返回值 成功1失败0
|
||||
*/
|
||||
int outlinefeature(IplImage* imglk, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:对单张图像的处理,最终得到一个特征值,用来计算各个图像之间的卡方距离
|
||||
|
||||
@变量 path 图像的物理地址
|
||||
@变量 feature 图像的特征值
|
||||
@返回值 处理后的图像
|
||||
*/
|
||||
IplImage* singlefeature(char* path, int feature[][50]);
|
||||
|
||||
|
||||
/*
|
||||
功能:细化之前的图像颜色处理,将颜色范围转换到0-1
|
||||
|
||||
@变量 ip 图像的句柄
|
||||
@变量 jp
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 空
|
||||
*/
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly);
|
||||
|
||||
|
||||
/*功能:细化算法 ,Rosenfeld细化算法,用于完成对笔迹图像的股价提取
|
||||
|
||||
@变量 image 代表图象的一维数组
|
||||
@变量 lx 图象宽度
|
||||
@变量 ly 图象高度
|
||||
@返回值 无返回值
|
||||
*/
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly);
|
||||
219
测试/本机测试/1-我-算法/HWCV-exe/seg_bck.cpp
Normal file
219
测试/本机测试/1-我-算法/HWCV-exe/seg_bck.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
///*
|
||||
//主函数文件:segmentation.cpp 主函数的实现文件
|
||||
//*/
|
||||
//#include "segmentation.h"
|
||||
////#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//无界面运行
|
||||
///*主函数*/
|
||||
//int ComputeImage(vector<string> files, double bzckesa[50][50], double *wcd, int conti);
|
||||
//int main(int argc, char* argv[])
|
||||
//{
|
||||
// /*变量定义*/
|
||||
// string dir = "E:\\xiangmu\\Img\\imgjiaobiao\\010211100518"; //存储目录
|
||||
// //string dir;
|
||||
// //if (argc < 2)
|
||||
// // return -1;
|
||||
// //else
|
||||
// // dir = argv[1];
|
||||
// cout << (char*)dir.c_str() << endl;
|
||||
// char record[2400] = { 0 };
|
||||
// FILE* fpzz = NULL;//需要注意
|
||||
// int i, ii, jj, feature[50][50][30] = { 0 }, featureall = 0;
|
||||
// double featurep[50][50][30] = { 0 };
|
||||
// double bzcu[50][50] = { 0 };
|
||||
// double bzckesa[50][50] = { 0 };
|
||||
// double wcd[30] = { 0 };
|
||||
//
|
||||
// int featx[50][50] = { 0 };
|
||||
// int featdif[30] = { 0 };
|
||||
// float maxx = 0; //最大特征值的标号与值
|
||||
// int xyimgnum = 0; //嫌疑图片的数目
|
||||
// char str[80]; //存储地址
|
||||
//
|
||||
// vector<string> suspict; //记录嫌疑图片地址
|
||||
// vector<float> suspict_wcd; //嫌疑图片的wcd值
|
||||
// vector<string> files; //存储该生所有考试文件路径
|
||||
//
|
||||
// /*读取配置文件,并配置各项参数*/
|
||||
// if (!ReadConfig("D:/HWCV/config/configure.cfg"))
|
||||
// {
|
||||
// // SaveLog("\t配置文件读取失败\n", g_log_adr, "a");
|
||||
// SaveLog("\n0\n", g_log_adr, "a");
|
||||
// return 0;
|
||||
// }
|
||||
// char path[100] = "E:/xiangmu/Img/imgjiaobiao/";
|
||||
//
|
||||
//
|
||||
//
|
||||
// /*步骤:读取标准差文件*/
|
||||
// int bzccolumns = 47;//txt文件中有47列
|
||||
// vector<double *> output_bzc;
|
||||
// if (!ReadScanf("D:\\HWCV\\config\\stdfile.db", bzccolumns, output_bzc))
|
||||
// {
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
//
|
||||
// // SaveLog("\n读取路径:D:\\HWCV\\config\\stdfile.db 的标准差文件失败!\n", g_log_adr, "a");
|
||||
// SaveLog("\n0\n", g_log_adr, "a");
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// //开始检测
|
||||
// //-------------------------------------------------------------//
|
||||
// getFiles(dir.c_str(), files); //遍历当前文件夹下的所有文件
|
||||
// int size = files.size();
|
||||
//
|
||||
// for (i = 0; i < size; i++)
|
||||
// {
|
||||
// // cout << ".";
|
||||
// memset(str, 0, sizeof(str));
|
||||
// memset(featx, 0, sizeof(featx));
|
||||
// memset(bzcu, 0, sizeof(bzcu));
|
||||
//
|
||||
// strcpy(str, files[i].c_str());
|
||||
// singlefeature(str, featx);//featx[][50]
|
||||
//
|
||||
// featureall = 0; //图像特征值和的初始化
|
||||
// for (ii = 0; ii < 48; ii++) //将featx存起来,回头看能不能用函数换掉
|
||||
// for (jj = ii + 1; jj < 47; jj++)
|
||||
// {
|
||||
// feature[ii][jj][i] = featx[ii][jj];
|
||||
// featureall = featureall + featx[ii][jj];
|
||||
// }
|
||||
// /*求轮廓方向特征featurep,式(5) 与标准差中的u的和*/
|
||||
// for (ii = 0; ii < 48; ii++)
|
||||
// for (jj = ii + 1; jj < 47; jj++)
|
||||
// {
|
||||
// featurep[ii][jj][i] = (double)featx[ii][jj] / featureall;
|
||||
// bzcu[ii][jj] += (double)featx[ii][jj] / featureall * 1000; //标准差的值过小,进行放大(1)
|
||||
// }
|
||||
// }/*处理完全部图片*/
|
||||
//
|
||||
// /*求标准差中u*/
|
||||
// for (ii = 0; ii < 48; ii++)
|
||||
// for (jj = ii + 1; jj < 47; jj++)
|
||||
// bzcu[ii][jj] = bzcu[ii][jj] / size;
|
||||
//
|
||||
//
|
||||
// for (ii = 0; ii < 48; ii++)//output_vector可视为二维数组;输出数组元素:
|
||||
// for (jj = ii + 1; jj < 47; jj++)
|
||||
// bzckesa[ii][jj] = output_bzc[ii][jj];
|
||||
//
|
||||
// /*求相似性,即带权卡方wcd*/
|
||||
// for (i = 0; i < size; i++)
|
||||
// for (ii = 0; ii < 48; ii++)
|
||||
// for (jj = ii + 1; jj < 47; jj++)
|
||||
// if (featurep[ii][jj][i] * featurep[ii][jj][g_conti] != 0 && bzckesa[ii][jj] != -1)
|
||||
// wcd[i] += pow((featurep[ii][jj][i] - featurep[ii][jj][g_conti]), 2) / ((featurep[ii][jj][i] + featurep[ii][jj][g_conti])*bzckesa[ii][jj]);
|
||||
//
|
||||
// //标出所有有嫌疑的图像1,无嫌疑的图像0
|
||||
// for (i = 0; i < size; i++)
|
||||
// {
|
||||
// if (wcd[i] > 0.12)
|
||||
// {
|
||||
// xyimgnum++;
|
||||
// suspict.push_back(files[i].c_str());
|
||||
// suspict_wcd.push_back(wcd[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /*将结果存入log文件*/
|
||||
// strcat(g_log_rec, "\n");
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// // strcat(g_log_rec, GetTime());
|
||||
// // strcat(g_log_rec, "\t考生考号:");
|
||||
// strcat(g_log_rec, dir.substr(27, 22).c_str());
|
||||
// strcat(g_log_rec, "\t");//图片总数为:
|
||||
// char pic_num[20];
|
||||
// _itoa(size, pic_num, 10);
|
||||
// strcat(g_log_rec, pic_num);
|
||||
// if (xyimgnum > 0)
|
||||
// {
|
||||
// char b[20];
|
||||
// sprintf(b, "\t%d", xyimgnum);
|
||||
// strcat(g_log_rec, b);
|
||||
// strcat(g_log_rec, "\n");
|
||||
// for (i = 0; i < xyimgnum; i++)
|
||||
// {
|
||||
// // cout << "嫌疑图像:" << files[i].c_str() << endl;
|
||||
// strcat(g_log_rec, "\t\t\t");//\t嫌疑图像:
|
||||
// strcat(g_log_rec, suspict[i].c_str());
|
||||
// strcat(g_log_rec, "\t");//相似度:
|
||||
// float sim = (1.0 - suspict_wcd[i]) * 100;
|
||||
// char a[20];
|
||||
// sprintf(a, "%g", sim);
|
||||
// strcat(g_log_rec, a);
|
||||
// strcat(g_log_rec, "%%\n");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // strcat(g_log_rec, "\t该考生没有嫌疑图像!\n");
|
||||
// strcat(g_log_rec, "\t0\n");
|
||||
// // cout << "该考生无嫌疑图像!" << endl;
|
||||
// }
|
||||
// SaveLog(g_log_rec, g_log_adr, "a");
|
||||
//
|
||||
//
|
||||
// /*善后*/
|
||||
// suspict.clear();
|
||||
// suspict_wcd.clear();
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// memset(feature, 0, sizeof(feature));
|
||||
// memset(featurep, 0, sizeof(featurep));
|
||||
// memset(bzckesa, 0, sizeof(bzckesa));
|
||||
// memset(wcd, 0, sizeof(wcd));
|
||||
// memset(featdif, 0, sizeof(featdif));
|
||||
// files.clear();
|
||||
// memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
//
|
||||
// /*返回值*/
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//int ComputeImage(vector<string> files, double bzckesa[50][50], double *wcd, int conti)
|
||||
//{
|
||||
// int i, ii, jj, k, size;
|
||||
// double bzcu[50][50] = { 0 }; //标准差中的u
|
||||
// double featurep[50][50][30] = { 0 }; //所有图像的轮廓方向特征初始化//干什么 //30
|
||||
// int feature[50][50][30] = { 0 }; //所有图像的特征值初始化 //所有图像指的什么意思 //30找出30的位置或者50的位置限制。。。。带入num_dir==49的情况进行类比
|
||||
// int featx[50][50] = { 0 }; //循环赋值的feature
|
||||
// int featureall; //图像特征值和 //做什么用
|
||||
// IplImage* imglk[30]; //轮廓图变量 //30
|
||||
//
|
||||
// size = files.size();
|
||||
// for (i = 0; i < size; i++)
|
||||
// {
|
||||
// memset(featx, 0, sizeof(featx));
|
||||
// // strcpy(str,files[i].c_str());
|
||||
// imglk[i] = singlefeature((char*)files[i].c_str(), featx); //featx[][50]
|
||||
// featureall = 0; //图像特征值和的初始化
|
||||
// for (ii = 0; ii<48; ii++) //将featx存起来,回头看能不能用函数换掉
|
||||
// for (jj = ii + 1; jj<47; jj++)
|
||||
// {
|
||||
// feature[ii][jj][i] = featx[ii][jj];
|
||||
// featureall = featureall + featx[ii][jj];
|
||||
// }
|
||||
// //求轮廓方向特征featurep,式(5) 与标准差中的u的和
|
||||
// for (ii = 0; ii<48; ii++)
|
||||
// for (jj = ii + 1; jj<47; jj++)
|
||||
// {
|
||||
// featurep[ii][jj][i] = (double)featx[ii][jj] / featureall;
|
||||
// bzcu[ii][jj] += (double)featx[ii][jj] / featureall * 1000; //标准差的值过小,进行放大(1)
|
||||
// }
|
||||
// }
|
||||
// //处理完一个人的每一张图片后
|
||||
// for (ii = 0; ii<48; ii++)//求标准差中的u
|
||||
// for (jj = ii + 1; jj<47; jj++)
|
||||
// bzcu[ii][jj] = bzcu[ii][jj] / size;
|
||||
// //求相似性就是带权卡方wcd
|
||||
// for (i = 0; i < size; i++)
|
||||
// for (ii = 0; ii<48; ii++)
|
||||
// for (jj = ii + 1; jj<47; jj++)
|
||||
// if (featurep[ii][jj][i] * featurep[ii][jj][conti] != 0 && bzckesa[ii][jj] != -1)
|
||||
// wcd[i] += pow((featurep[ii][jj][i] - featurep[ii][jj][conti]), 2) / ((featurep[ii][jj][i] + featurep[ii][jj][conti])*bzckesa[ii][jj]);
|
||||
// memset(imglk, 0, sizeof(imglk));
|
||||
// memset(feature, 0, sizeof(feature));
|
||||
// memset(featurep, 0, sizeof(featurep));
|
||||
//
|
||||
// return 1;
|
||||
//}
|
||||
225
测试/本机测试/1-我-算法/HWCV-exe/segmentation.cpp
Normal file
225
测试/本机测试/1-我-算法/HWCV-exe/segmentation.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
主函数文件:segmentation.cpp 主函数的实现文件
|
||||
*/
|
||||
#include "segmentation.h"
|
||||
//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//无界面运行
|
||||
/*主函数*/
|
||||
|
||||
|
||||
int ComputeImage(vector<string> files, double bzckesa[50][50], double *wcd, int conti)
|
||||
{
|
||||
int i, ii, jj, k, size;
|
||||
double bzcu[50][50] = { 0 }; //标准差中的u
|
||||
double featurep[50][50][30] = { 0 }; //所有图像的轮廓方向特征初始化//干什么 //30
|
||||
int feature[50][50][30] = { 0 }; //所有图像的特征值初始化 //所有图像指的什么意思 //30找出30的位置或者50的位置限制。。。。带入num_dir==49的情况进行类比
|
||||
int featx[50][50] = { 0 }; //循环赋值的feature
|
||||
int featureall; //图像特征值和 //做什么用
|
||||
|
||||
size = files.size();
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
memset(featx, 0, sizeof(featx));
|
||||
// strcpy(str,files[i].c_str());
|
||||
singlefeature((char*)files[i].c_str(), featx); //featx[][50]
|
||||
featureall = 0; //图像特征值和的初始化
|
||||
for (ii = 0; ii < 48; ii++) //将featx存起来,回头看能不能用函数换掉
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
{
|
||||
feature[ii][jj][i] = featx[ii][jj];
|
||||
featureall = featureall + featx[ii][jj];
|
||||
}
|
||||
//求轮廓方向特征featurep,式(5) 与标准差中的u的和
|
||||
for (ii = 0; ii < 48; ii++)
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
{
|
||||
featurep[ii][jj][i] = (double)featx[ii][jj] / featureall;
|
||||
bzcu[ii][jj] += (double)featx[ii][jj] / featureall * 1000; //标准差的值过小,进行放大(1)
|
||||
}
|
||||
}
|
||||
//处理完一个人的每一张图片后
|
||||
for (ii = 0; ii < 48; ii++)//求标准差中的u
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
bzcu[ii][jj] = bzcu[ii][jj] / size;
|
||||
//求相似性就是带权卡方wcd
|
||||
for (i = 0; i < size; i++)
|
||||
for (ii = 0; ii < 48; ii++)
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
if (featurep[ii][jj][i] * featurep[ii][jj][conti] != 0 && bzckesa[ii][jj] != -1)
|
||||
wcd[i] += pow((featurep[ii][jj][i] - featurep[ii][jj][conti]), 2) / ((featurep[ii][jj][i] + featurep[ii][jj][conti])*bzckesa[ii][jj]);
|
||||
memset(feature, 0, sizeof(feature));
|
||||
memset(featurep, 0, sizeof(featurep));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
/*变量定义*/
|
||||
//string dir;
|
||||
//if (argc < 2)
|
||||
// return -1;
|
||||
//else
|
||||
// dir = argv[1];
|
||||
|
||||
|
||||
// 调试
|
||||
// string dir = "E:/xiangmu/Img/imgjiaobiao/010211100518"; //存储目录
|
||||
|
||||
// 定义变量
|
||||
vector<string> dir; //存储目录
|
||||
int conti = 1; //对比图像的标号
|
||||
int size_dir, num_dir;
|
||||
char record[2400] = { 0 };
|
||||
|
||||
// 获取待检测文件夹到size
|
||||
char path[100] = "E:/xiangmu/Img/imgjiaobiao/";//D:/xiangmu/Img/imgjiaobiao/
|
||||
searchDir(path, dir);//获取filePath下的所有一级目录并存储到dir中
|
||||
// dir.push_back("E:/xiangmu/Img/imgjiaobiao/010211100518"); //存储目录
|
||||
size_dir = dir.size(); //dir的大小就是学生的数量
|
||||
stuAll = size_dir;
|
||||
cout << "学生总数为" << stuAll << endl;
|
||||
|
||||
// 开始检测每个文件夹下的
|
||||
for (num_dir = 0; num_dir < size_dir; num_dir++)//对每一个学生目录进行循环
|
||||
{
|
||||
cout <<(char*)dir[num_dir].c_str();
|
||||
char record[2400] = { 0 };
|
||||
FILE* fpzz = NULL;//需要注意
|
||||
int i, ii, jj, feature[50][50][30] = { 0 }, featureall = 0;
|
||||
double featurep[50][50][30] = { 0 };
|
||||
double bzcu[50][50] = { 0 };
|
||||
double bzckesa[50][50] = { 0 };
|
||||
double wcd[30] = { 0 };
|
||||
|
||||
int featx[50][50] = { 0 };
|
||||
int featdif[30] = { 0 };
|
||||
float maxx = 0; //最大特征值的标号与值
|
||||
int xyimgnum = 0; //嫌疑图片的数目
|
||||
char str[80]; //存储地址
|
||||
|
||||
vector<string> suspict; //记录嫌疑图片地址
|
||||
vector<float> suspict_wcd; //嫌疑图片的wcd值
|
||||
vector<string> files; //存储该生所有考试文件路径
|
||||
|
||||
/*读取配置文件,并配置各项参数*/
|
||||
if (!ReadConfig("D:/HWCV/config/configure.cfg"))
|
||||
{
|
||||
// SaveLog("\t配置文件读取失败\n", g_log_adr, "a");
|
||||
SaveLog("\n0\n", g_log_adr, "a");
|
||||
return 0;
|
||||
}
|
||||
char path[100] = "E:/xiangmu/Img/imgjiaobiao/";
|
||||
|
||||
|
||||
|
||||
/*步骤:读取标准差文件*/
|
||||
int bzccolumns = 47;//txt文件中有47列
|
||||
vector<double *> output_bzc;
|
||||
if (!ReadScanf("D:\\HWCV\\config\\stdfile.db", bzccolumns, output_bzc))
|
||||
{
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
|
||||
// SaveLog("\n读取路径:D:\\HWCV\\config\\stdfile.db 的标准差文件失败!\n", g_log_adr, "a");
|
||||
SaveLog("\n0\n", g_log_adr, "a");
|
||||
return 0;
|
||||
}
|
||||
for (ii = 0; ii < 48; ii++)//output_vector可视为二维数组;输出数组元素:
|
||||
for (jj = ii + 1; jj < 47; jj++)
|
||||
bzckesa[ii][jj] = output_bzc[ii][jj];
|
||||
|
||||
//开始检测
|
||||
//-------------------------------------------------------------//
|
||||
getFiles(dir[num_dir].c_str(), files); //遍历当前文件夹下的所有文件
|
||||
int size = files.size();
|
||||
cout << " 文件数:" << size;
|
||||
|
||||
//开始对每一张图片进行处理
|
||||
for (int r = 0; r < size; r++)
|
||||
{
|
||||
memset(wcd, 0, sizeof(wcd));
|
||||
ComputeImage(files, bzckesa, wcd, r);
|
||||
xyimgnum = 0;
|
||||
//求卡方距离的最大值
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
// cout << files[i].c_str() << " " << wcd[i] << endl;
|
||||
if (wcd[i]>0.12)
|
||||
{
|
||||
xyimgnum++;
|
||||
suspict.push_back(files[i].c_str());
|
||||
suspict_wcd.push_back(wcd[i]);
|
||||
}
|
||||
}
|
||||
if (xyimgnum < 3) break;
|
||||
}
|
||||
|
||||
/*将结果存入log文件*/
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
// strcat(g_log_rec, GetTime());
|
||||
// strcat(g_log_rec, "\t考生考号:");
|
||||
strcat(g_log_rec, dir[num_dir].substr(27, 22).c_str());//学号
|
||||
strcat(g_log_rec, ",");//图片总数为:
|
||||
char pic_num[20];
|
||||
_itoa(size, pic_num, 10);
|
||||
strcat(g_log_rec, pic_num);
|
||||
if (xyimgnum > 0)
|
||||
{
|
||||
stuSus++;
|
||||
char b[20];
|
||||
sprintf(b, ",%d", xyimgnum);
|
||||
strcat(g_log_rec, b);
|
||||
strcat(g_log_rec, "\n");
|
||||
for (i = 0; i < xyimgnum; i++)
|
||||
{
|
||||
// cout << "嫌疑图像:" << files[i].c_str() << endl;
|
||||
strcat(g_log_rec, ",,,");//\t嫌疑图像:
|
||||
strcat(g_log_rec, suspict[i].c_str());
|
||||
strcat(g_log_rec, ",");//相似度:
|
||||
float sim = (1.0 - suspict_wcd[i]) * 100;
|
||||
char a[20];
|
||||
sprintf(a, "%g", sim);
|
||||
strcat(g_log_rec, a);
|
||||
strcat(g_log_rec, "%%\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// strcat(g_log_rec, "\t该考生没有嫌疑图像!\n");
|
||||
strcat(g_log_rec, ",0,");
|
||||
// cout << "该考生无嫌疑图像!" << endl;
|
||||
}
|
||||
SaveLog(g_log_rec, g_log_adr, "a");
|
||||
|
||||
printf("嫌疑数量:%d, ", xyimgnum);
|
||||
picAll += size;
|
||||
picSus += xyimgnum;
|
||||
printf("全部:%d嫌疑:%d比例为:%g\n", picAll, picSus, ((float)picSus) / ((float)picAll));
|
||||
xyimgnum = 0;
|
||||
|
||||
/*善后*/
|
||||
suspict.clear();
|
||||
suspict_wcd.clear();
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
memset(feature, 0, sizeof(feature));
|
||||
memset(featurep, 0, sizeof(featurep));
|
||||
memset(bzckesa, 0, sizeof(bzckesa));
|
||||
memset(wcd, 0, sizeof(wcd));
|
||||
memset(featdif, 0, sizeof(featdif));
|
||||
files.clear();
|
||||
memset(g_log_rec, 0, sizeof(g_log_rec));
|
||||
|
||||
/*返回值*/
|
||||
}
|
||||
|
||||
dir.clear();
|
||||
|
||||
cout << "学生总数:" << stuAll << " 作弊人数:" << stuSus << endl;
|
||||
printf("已经打印到txt中!");
|
||||
string open = "start " + (string)g_log_adr;
|
||||
system(open.c_str());
|
||||
system("pause");
|
||||
|
||||
return 0; //(1-wcd[maxi])*100
|
||||
}
|
||||
45
测试/本机测试/1-我-算法/HWCV-exe/segmentation.h
Normal file
45
测试/本机测试/1-我-算法/HWCV-exe/segmentation.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
头文件:segmentation.h 主函数头文件
|
||||
*/
|
||||
#pragma once
|
||||
#ifdef WIN32 //屏蔽VC6对STL的一些不完全支持造成
|
||||
#pragma warning (disable: 4514 4786)
|
||||
#endif
|
||||
#include "StdAfx.h"
|
||||
#include "path.h"
|
||||
#include "Point.h"
|
||||
#include "process.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*定义全局变量*/
|
||||
|
||||
|
||||
int g_bi_threshold = 230; /* 全局变量 二值化阈值*/
|
||||
double g_std_kesa[50][50]; /* 全局变量 标准差数组*/
|
||||
float g_doubt_threshold = 0.12; /* 全局变量 作弊嫌疑阈值*/
|
||||
string g_dir = "Y:/"; /* 全局变量 总路径的目录*/
|
||||
int g_cheat_num_threshold = 0; /* 全局变量 默认作弊阈值*/
|
||||
int g_conti = 1; /* 全局变量 默认作弊比较的图片*/
|
||||
|
||||
int g_all_img_num = 0; /* 全局变量 已鉴定的全部图片数量*/
|
||||
int g_doubt_img_num = 0; /* 全局变量 已鉴定怀疑的图片数量*/
|
||||
int g_all_stu_num = 0; /* 全局变量 已鉴定的全部学生数量*/
|
||||
int g_doubt_stu_num = 0; /* 全局变量 已鉴定怀疑的学生数量*/
|
||||
|
||||
bool g_output_cmd_config = false; /*全局变量 输出参数控制*/
|
||||
bool g_output_txt_config = false; /*全局变量 输出中间文件选项*/
|
||||
char g_log_adr[50] = "D:/HWCV/log_ori.txt"; /*全局变量 程序日志存储地址*/
|
||||
char g_log_rec[500] = { 0 }; /*全局变量 程序日志专用变量*/
|
||||
char g_err_adr[50]= "D:/HWCV/err_ori.txt"; /*错误日志路径*/
|
||||
/*全局变量 输出txt结果文件*/
|
||||
/*全局变量 输出txt结果文件地址*/
|
||||
int picAll =0, picSus=0;
|
||||
int stuAll = 0, stuSus = 0;
|
||||
|
||||
|
||||
|
||||
time_t ltime;
|
||||
char *srcTime=NULL;
|
||||
char timeNow[32]={0};
|
||||
char msg[100]={0};
|
||||
22
测试/本机测试/2-侯-算法/handwriting.sln
Normal file
22
测试/本机测试/2-侯-算法/handwriting.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "handwriting", "handwriting\handwriting.vcxproj", "{4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
54
测试/本机测试/2-侯-算法/handwriting/Cjbsb.cpp
Normal file
54
测试/本机测试/2-侯-算法/handwriting/Cjbsb.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 程序名:Cjbsb.c
|
||||
功能:读入图像文件,甄别图像的角标
|
||||
*/
|
||||
#pragma once
|
||||
#include <cv.h>
|
||||
#include <highgui.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern IplImage* src;
|
||||
|
||||
IplImage* Cjbsb(IplImage* img,IplImage* imgjbsb,int jbwhite,int jbblack)
|
||||
{
|
||||
/*定义变量*/
|
||||
int i,j,ii,jj,sumjb1,sumjb2,jbi=0,jbj=0;
|
||||
int height,width,step,channels;
|
||||
uchar *data;
|
||||
int brklab=0;
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
// IplImage* imgjbsb = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
|
||||
cvCopy(img,imgjbsb,NULL);
|
||||
uchar *imgjbsbdata= (uchar *)imgjbsb->imageData;
|
||||
|
||||
|
||||
|
||||
|
||||
//以角标为起点进行裁剪与画框
|
||||
CvSize jbcjsize=cvSize(835,165); //角标裁剪框的大小,宽为835象素,高为165象素
|
||||
IplImage* imgjbcj = cvCreateImage(jbcjsize,img->depth,img->nChannels);
|
||||
uchar *imgjbcjdata= (uchar *)imgjbcj->imageData;
|
||||
int jbcjstep = imgjbcj->widthStep;
|
||||
int jbcjchannels = imgjbcj->nChannels;
|
||||
for(i=0;i<165;i++)
|
||||
for(j=0;j<835;j++)
|
||||
imgjbcjdata[i*jbcjstep+j*jbcjchannels]=data[(i+jbi)*step+(j+jbj)*channels];
|
||||
for(i=0;i<165;i=i+2)
|
||||
{
|
||||
imgjbsbdata[(i+jbi)*step+jbj*channels]=0;
|
||||
imgjbsbdata[(i+jbi)*step+(jbj+835)*channels]=0;
|
||||
}
|
||||
for(j=0;j<835;j=j+2)
|
||||
{
|
||||
imgjbsbdata[jbi*step+(j+jbj)*channels]=0;
|
||||
imgjbsbdata[(jbi+165)*step+(j+jbj)*channels]=0;
|
||||
}
|
||||
|
||||
return imgjbcj;
|
||||
}
|
||||
0
测试/本机测试/2-侯-算法/handwriting/Cword.cpp
Normal file
0
测试/本机测试/2-侯-算法/handwriting/Cword.cpp
Normal file
11
测试/本机测试/2-侯-算法/handwriting/Cword.h
Normal file
11
测试/本机测试/2-侯-算法/handwriting/Cword.h
Normal file
@@ -0,0 +1,11 @@
|
||||
class Cword{
|
||||
private:
|
||||
|
||||
public:
|
||||
Point wbegin;
|
||||
Point wend;
|
||||
// int n; //在总个数中的位置
|
||||
int nn; //在文字中的序号
|
||||
bool isword; //是否为文字
|
||||
int blacknum; //本文字中的黑色像素数
|
||||
};
|
||||
29
测试/本机测试/2-侯-算法/handwriting/Integral.cpp
Normal file
29
测试/本机测试/2-侯-算法/handwriting/Integral.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
IplImage* Integral(IplImage* img, int width, int height)
|
||||
{
|
||||
unsigned long *columnSum = new unsigned long[width]; // sum of each column
|
||||
// calculate integral of the first line
|
||||
for(int i=0;i<width;i++)
|
||||
{
|
||||
columnSum[i]=inputMatrix[i];
|
||||
outputMatrix[i] = inputMatrix[i];
|
||||
if(i>0)
|
||||
{
|
||||
outputMatrix[i] += outputMatrix[i-1];
|
||||
}
|
||||
}
|
||||
for (int i=1;i<height;i++)
|
||||
{
|
||||
int offset = i*width;
|
||||
// first column of each line
|
||||
columnSum[0] +=inputMatrix[offset];
|
||||
outputMatrix[offset] = columnSum[0];
|
||||
// other columns
|
||||
for(int j=1;j<width;j++)
|
||||
{
|
||||
columnSum[j] += inputMatrix[offset+j];
|
||||
outputMatrix[offset+j] = outputMatrix[offset+j-1] + columnSum[j];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} */
|
||||
9
测试/本机测试/2-侯-算法/handwriting/Point.h
Normal file
9
测试/本机测试/2-侯-算法/handwriting/Point.h
Normal file
@@ -0,0 +1,9 @@
|
||||
class Point{
|
||||
private:
|
||||
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
void setpoint(int a,int b){x=a;y=b;}
|
||||
};
|
||||
683
测试/本机测试/2-侯-算法/handwriting/Thinner.cpp
Normal file
683
测试/本机测试/2-侯-算法/handwriting/Thinner.cpp
Normal file
@@ -0,0 +1,683 @@
|
||||
//**************************************************************************
|
||||
//Thinner.cpp
|
||||
//细化算法实现文件
|
||||
//**************************************************************************
|
||||
//#include "StdAfx.h"
|
||||
#pragma once
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include "Thinner.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly){
|
||||
//void beforethin(char *ip, char *jp, unsigned long lx, unsigned long ly)
|
||||
unsigned long i,j;
|
||||
for(i=0; i<ly; i++){
|
||||
for(j=0; j<lx; j++){
|
||||
//这里要视前景是白点还是黑点而定,可以改动
|
||||
//如果前景是白点,就是这样;反之反过来
|
||||
//jp[i*lx+j]=ip[i*lx+j];
|
||||
/* jp[i*lx+j]=255;*/
|
||||
if(ip[i*lx+j]>0)
|
||||
jp[i*lx+j]=0;
|
||||
else
|
||||
jp[i*lx+j]=255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Hilditch细化算法
|
||||
//功能:对图象进行细化
|
||||
//参数:image:代表图象的一维数组
|
||||
// lx:图象宽度
|
||||
// ly:图象高度
|
||||
// 无返回值
|
||||
void ThinnerHilditch(void *image, unsigned long lx, unsigned long ly){
|
||||
char *f, *g;
|
||||
char n[10];
|
||||
unsigned int counter;
|
||||
short k, shori, xx, nrn;
|
||||
unsigned long i, j;
|
||||
long kk, kk11, kk12, kk13, kk21, kk22, kk23, kk31, kk32, kk33, size;
|
||||
size = (long)lx * (long)ly;
|
||||
g = (char *)malloc(size);
|
||||
|
||||
if(g == NULL){
|
||||
printf("error in allocating memory!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
f = (char *)image;
|
||||
for(i=0; i<lx; i++){
|
||||
for(j=0; j<ly; j++){
|
||||
kk=i*ly+j;
|
||||
if(f[kk]!=0){
|
||||
f[kk]=1;
|
||||
g[kk]=f[kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
counter = 1;
|
||||
|
||||
do{
|
||||
printf("%4d*",counter);
|
||||
counter++;
|
||||
shori = 0;
|
||||
|
||||
for(i=0; i<lx; i++){
|
||||
for(j=0; j<ly; j++){
|
||||
kk = i*ly+j;
|
||||
if(f[kk]<0)
|
||||
f[kk] = 0;
|
||||
g[kk]= f[kk];
|
||||
}
|
||||
}
|
||||
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk=i*ly+j;
|
||||
|
||||
if(f[kk]!=1)
|
||||
continue;
|
||||
|
||||
kk11 = (i-1)*ly+j-1;
|
||||
kk12 = kk11 + 1;
|
||||
kk13 = kk12 + 1;
|
||||
kk21 = i*ly+j-1;
|
||||
kk22 = kk21 + 1;
|
||||
kk23 = kk22 + 1;
|
||||
kk31 = (i+1)*ly+j-1;
|
||||
kk32 = kk31 + 1;
|
||||
kk33 = kk32 + 1;
|
||||
|
||||
if((g[kk12]&&g[kk21]&&g[kk23]&&g[kk32])!=0)
|
||||
continue;
|
||||
|
||||
nrn = g[kk11] + g[kk12] + g[kk13] + g[kk21] + g[kk23] +
|
||||
g[kk31] + g[kk32] + g[kk33];
|
||||
|
||||
if(nrn <= 1){
|
||||
f[kk22] = 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
n[4] = f[kk11];
|
||||
n[3] = f[kk12];
|
||||
n[2] = f[kk13];
|
||||
n[5] = f[kk21];
|
||||
n[1] = f[kk23];
|
||||
n[6] = f[kk31];
|
||||
n[7] = f[kk32];
|
||||
n[8] = f[kk33];
|
||||
n[9] = n[1];
|
||||
xx = 0;
|
||||
|
||||
for(k=1; k<8; k=k+2){
|
||||
if((!n[k])&&(n[k+1]||n[k+2]))
|
||||
xx++;
|
||||
}
|
||||
|
||||
if(xx!=1){
|
||||
f[kk22] = 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(f[kk12] == -1){
|
||||
f[kk12] = 0;
|
||||
n[3] = 0;
|
||||
xx = 0;
|
||||
|
||||
for(k=1; k<8; k=k+2){
|
||||
if((!n[k])&&(n[k+1]||n[k+2]))
|
||||
xx++;
|
||||
}
|
||||
|
||||
if(xx != 1){
|
||||
f[kk12] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
f[kk12] = -1;
|
||||
n[3] = -1;
|
||||
}
|
||||
|
||||
if(f[kk21]!=-1){
|
||||
f[kk22] = -1;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
f[kk21] = 0;
|
||||
n[5] = 0;
|
||||
xx = 0;
|
||||
|
||||
for(k=1; k<8; k=k+2){
|
||||
if((!n[k])&&(n[k+1]||n[k+2])){
|
||||
xx++;
|
||||
}
|
||||
}
|
||||
|
||||
if(xx == 1){
|
||||
f[kk21] = -1;
|
||||
f[kk22] = -1;
|
||||
shori =1;
|
||||
}
|
||||
else
|
||||
f[kk21] = -1;
|
||||
}
|
||||
}
|
||||
}while(shori);
|
||||
|
||||
free(g);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Pavlidis细化算法
|
||||
//功能:对图象进行细化
|
||||
//参数:image:代表图象的一维数组
|
||||
// lx:图象宽度
|
||||
// ly:图象高度
|
||||
// 无返回值
|
||||
void ThinnerPavlidis(void *image, unsigned long lx, unsigned long ly){
|
||||
char erase, n[8];
|
||||
char *f;
|
||||
unsigned char bdr1,bdr2,bdr4,bdr5;
|
||||
short c,k,b;
|
||||
unsigned long i,j;
|
||||
long kk,kk1,kk2,kk3;
|
||||
f = (char*)image;
|
||||
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk = i*ly + j;
|
||||
if(f[kk])
|
||||
f[kk] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0, kk1=0, kk2=ly-1; i<lx; i++, kk1+=ly, kk2+=ly){
|
||||
f[kk1]=0;
|
||||
f[kk2]=0;
|
||||
}
|
||||
|
||||
for(j=0, kk=(lx-1)*ly; j<ly; j++,kk++){
|
||||
f[j]=0;
|
||||
f[kk]=0;
|
||||
}
|
||||
|
||||
c=5;
|
||||
erase =1;
|
||||
while(erase){
|
||||
c++;
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk=i*ly+j;
|
||||
if(f[kk]!=1)
|
||||
continue;
|
||||
|
||||
kk1 = kk-ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk3 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[0] = f[kk3];
|
||||
kk1 = kk + ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
|
||||
bdr1 =0;
|
||||
for(k=0; k<8; k++){
|
||||
if(n[k]>=1)
|
||||
bdr1|=0x80>>k;
|
||||
}
|
||||
|
||||
if((bdr1&0252)== 0252)
|
||||
continue;
|
||||
f[kk] = 2;
|
||||
b=0;
|
||||
|
||||
for(k=0; k<=7; k++){
|
||||
b+=bdr1&(0x80>>k);
|
||||
}
|
||||
|
||||
if(b<=1)
|
||||
f[kk]=3;
|
||||
|
||||
if((bdr1&0160)!=0&&(bdr1&07)!=0&&(bdr1&0210)==0)
|
||||
f[kk]=3;
|
||||
else if((bdr1&&0301)!=0&&(bdr1&034)!=0&&(bdr1&042)==0)
|
||||
f[kk]=3;
|
||||
else if((bdr1&0202)==0 && (bdr1&01)!=0)
|
||||
f[kk]=3;
|
||||
else if((bdr1&0240)==0 && (bdr1&0100)!=0)
|
||||
f[kk]=3;
|
||||
else if((bdr1&050)==0 && (bdr1&020)!=0)
|
||||
f[kk]=3;
|
||||
else if((bdr1&012)==0 && (bdr1&04)!=0)
|
||||
f[kk]=3;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk = i*ly + j;
|
||||
if(!f[kk])
|
||||
continue;
|
||||
|
||||
kk1 = kk - ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk2 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[0] = f[kk3];
|
||||
kk1 = kk + ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
bdr1 = bdr2 =0;
|
||||
|
||||
for(k=0; k<=7; k++){
|
||||
if(n[k]>=1)
|
||||
bdr1|=0x80>>k;
|
||||
if(n[k]>=2)
|
||||
bdr2|=0x80>>k;
|
||||
}
|
||||
|
||||
if(bdr1==bdr2){
|
||||
f[kk] = 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(f[kk]!=2)
|
||||
continue;
|
||||
|
||||
if((bdr2&0200)!=0 && (bdr1&010)==0 &&((bdr1&0100)!=0 &&(bdr1&001)!=0 ||
|
||||
((bdr1&0100)!=0 ||(bdr1 & 001)!=0) && (bdr1&060)!=0 &&(bdr1&06)!=0)){
|
||||
f[kk] = 4;
|
||||
}
|
||||
|
||||
else if((bdr2&040)!=0 && (bdr1&02)==0 && ((bdr1&020)!=0 && (bdr1&0100)!=0 ||
|
||||
((bdr1&020)!=0 || (bdr1&0100)!=0) && (bdr1&014)!=0 && (bdr1&0201)!=0)){
|
||||
f[kk] = 4;
|
||||
}
|
||||
|
||||
else if((bdr2&010)!=0 && (bdr1&0200)==0 && ((bdr1&04)!=0 && (bdr1&020)!=0 ||
|
||||
((bdr1&04)!=0 || (bdr1&020)!=0) && (bdr1&03)!=0 && (bdr1&0140)!=0)){
|
||||
f[kk] = 4;
|
||||
}
|
||||
|
||||
else if((bdr2&02)!=0 && (bdr1&040)==0 && ((bdr1&01)!=0 && (bdr1&04)!=0 ||
|
||||
((bdr1&01)!=0 || (bdr1&04)!=0) && (bdr1&0300)!=0 && (bdr1&030)!=0)){
|
||||
f[kk] = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk = i*ly + j;
|
||||
if(f[kk]!=2)
|
||||
continue;
|
||||
kk1 = kk - ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk2 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[0] = f[kk3];
|
||||
kk1 = kk + ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
bdr4 = bdr5 =0;
|
||||
for(k=0; k<=7; k++){
|
||||
if(n[k]>=4)
|
||||
bdr4|=0x80>>k;
|
||||
if(n[k]>=5)
|
||||
bdr5|=0x80>>k;
|
||||
}
|
||||
if((bdr4&010) == 0){
|
||||
f[kk] = 5;
|
||||
continue;
|
||||
}
|
||||
if((bdr4&040) == 0 && bdr5 ==0){
|
||||
f[kk] = 5;
|
||||
continue;
|
||||
}
|
||||
if(f[kk]==3||f[kk]==4)
|
||||
f[kk] = c;
|
||||
}
|
||||
}
|
||||
|
||||
erase = 0;
|
||||
for(i=1; i<lx-1; i++){
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk = i*ly +j;
|
||||
if(f[kk]==2||f[kk] == 5){
|
||||
erase = 1;
|
||||
f[kk] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Rosenfeld细化算法
|
||||
//功能:对图象进行细化
|
||||
//参数:image:代表图象的一维数组
|
||||
// lx:图象宽度
|
||||
// ly:图象高度
|
||||
// 无返回值
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly){
|
||||
char *f, *g;
|
||||
char n[10];
|
||||
char a[5] = {0, -1, 1, 0, 0};
|
||||
char b[5] = {0, 0, 0, 1, -1};
|
||||
char nrnd, cond, n48, n26, n24, n46, n68, n82, n123, n345, n567, n781;
|
||||
short k, shori;
|
||||
unsigned long i, j;
|
||||
long ii, jj, kk, kk1, kk2, kk3, size;
|
||||
size = (long)lx * (long)ly;
|
||||
|
||||
g = (char *)malloc(size);
|
||||
if(g==NULL){
|
||||
printf("error in alocating mmeory!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
f = (char *)image;
|
||||
for(kk=0l; kk<size; kk++){
|
||||
g[kk] = f[kk];
|
||||
}
|
||||
|
||||
do{
|
||||
shori = 0;
|
||||
for(k=1; k<=4; k++){
|
||||
for(i=1; i<lx-1; i++){
|
||||
ii = i + a[k];
|
||||
|
||||
for(j=1; j<ly-1; j++){
|
||||
kk = i*ly + j;
|
||||
|
||||
if(!f[kk])
|
||||
continue;
|
||||
|
||||
jj = j + b[k];
|
||||
kk1 = ii*ly + jj;
|
||||
|
||||
if(f[kk1])
|
||||
continue;
|
||||
|
||||
kk1 = kk - ly -1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[3] = f[kk1];
|
||||
n[2] = f[kk2];
|
||||
n[1] = f[kk3];
|
||||
kk1 = kk - 1;
|
||||
kk3 = kk + 1;
|
||||
n[4] = f[kk1];
|
||||
n[8] = f[kk3];
|
||||
kk1 = kk + ly - 1;
|
||||
kk2 = kk1 + 1;
|
||||
kk3 = kk2 + 1;
|
||||
n[5] = f[kk1];
|
||||
n[6] = f[kk2];
|
||||
n[7] = f[kk3];
|
||||
|
||||
nrnd = n[1] + n[2] + n[3] + n[4]
|
||||
+n[5] + n[6] + n[7] + n[8];
|
||||
if(nrnd<=1)
|
||||
continue;
|
||||
|
||||
cond = 0;
|
||||
n48 = n[4] + n[8];
|
||||
n26 = n[2] + n[6];
|
||||
n24 = n[2] + n[4];
|
||||
n46 = n[4] + n[6];
|
||||
n68 = n[6] + n[8];
|
||||
n82 = n[8] + n[2];
|
||||
n123 = n[1] + n[2] + n[3];
|
||||
n345 = n[3] + n[4] + n[5];
|
||||
n567 = n[5] + n[6] + n[7];
|
||||
n781 = n[7] + n[8] + n[1];
|
||||
|
||||
if(n[2]==1 && n48==0 && n567>0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[6]==1 && n48==0 && n123>0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[8]==1 && n26==0 && n345>0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[4]==1 && n26==0 && n781>0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[5]==1 && n46==0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[7]==1 && n68==0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[1]==1 && n82==0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(n[3]==1 && n24==0){
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
cond = 1;
|
||||
if(!cond)
|
||||
continue;
|
||||
g[kk] = 0;
|
||||
shori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<lx; i++){
|
||||
for(j=0; j<ly; j++){
|
||||
kk = i*ly + j;
|
||||
f[kk] = g[kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
}while(shori);
|
||||
|
||||
free(g);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//基于索引表的细化细化算法
|
||||
//功能:对图象进行细化
|
||||
//参数:lpDIBBits:代表图象的一维数组
|
||||
// lWidth:图象高度
|
||||
// lHeight:图象宽度
|
||||
// 无返回值
|
||||
|
||||
/*
|
||||
BOOL WINAPI ThiningDIBSkeleton (LPSTR lpDIBBits, LONG lWidth, LONG lHeight){
|
||||
//循环变量
|
||||
long i;
|
||||
long j;
|
||||
long lLength;
|
||||
|
||||
unsigned char deletemark[256] = {
|
||||
0,0,0,0,0,0,0,1, 0,0,1,1,0,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 0,0,1,1,1,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 1,0,0,0,1,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 1,0,1,1,1,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0, 1,0,0,0,1,0,1,1,
|
||||
1,0,0,0,0,0,0,0, 1,0,1,1,1,0,1,1,
|
||||
0,0,1,1,0,0,1,1, 0,0,0,1,0,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 0,0,0,1,0,0,1,1,
|
||||
1,1,0,1,0,0,0,1, 0,0,0,0,0,0,0,0,
|
||||
1,1,0,1,0,0,0,1, 1,1,0,0,1,0,0,0,
|
||||
0,1,1,1,0,0,1,1, 0,0,0,1,0,0,1,1,
|
||||
0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,
|
||||
1,1,1,1,0,0,1,1, 1,1,0,0,1,1,0,0,
|
||||
1,1,1,1,0,0,1,1, 1,1,0,0,1,1,0,0
|
||||
};//索引表
|
||||
|
||||
unsigned char p0, p1, p2, p3, p4, p5, p6, p7;
|
||||
unsigned char *pmid, *pmidtemp;
|
||||
unsigned char sum;
|
||||
int changed;
|
||||
bool bStart = true;
|
||||
lLength = lWidth * lHeight;
|
||||
unsigned char *pTemp = (unsigned char *)malloc(sizeof(unsigned char) * lWidth * lHeight);
|
||||
|
||||
// P0 P1 P2
|
||||
// P7 P3
|
||||
// P6 P5 P4
|
||||
|
||||
while(bStart){
|
||||
bStart = false;
|
||||
changed = 0;
|
||||
|
||||
//首先求边缘点(并行)
|
||||
pmid = (unsigned char *)lpDIBBits + lWidth + 1;
|
||||
memset(pTemp, (BYTE) 0, lLength);
|
||||
pmidtemp = (unsigned char *)pTemp + lWidth + 1;
|
||||
for(i = 1; i < lHeight -1; i++){
|
||||
for(j = 1; j < lWidth - 1; j++){
|
||||
if( *pmid == 0){
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
continue;
|
||||
}
|
||||
|
||||
p3 = *(pmid + 1);
|
||||
p2 = *(pmid + 1 - lWidth);
|
||||
p1 = *(pmid - lWidth);
|
||||
p0 = *(pmid - lWidth -1);
|
||||
p7 = *(pmid - 1);
|
||||
p6 = *(pmid + lWidth - 1);
|
||||
p5 = *(pmid + lWidth);
|
||||
p4 = *(pmid + lWidth + 1);
|
||||
|
||||
sum = p0 & p1 & p2 & p3 & p4 & p5 & p6 & p7;
|
||||
if(sum == 0){
|
||||
*pmidtemp = 1;
|
||||
}
|
||||
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
}
|
||||
pmid++;
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
pmidtemp++;
|
||||
}
|
||||
|
||||
//现在开始串行删除
|
||||
pmid = (unsigned char *)lpDIBBits + lWidth + 1;
|
||||
pmidtemp = (unsigned char *)pTemp + lWidth + 1;
|
||||
|
||||
for(i = 1; i < lHeight -1; i++){
|
||||
for(j = 1; j < lWidth - 1; j++){
|
||||
if( *pmidtemp == 0){
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
continue;
|
||||
}
|
||||
|
||||
p3 = *(pmid + 1);
|
||||
p2 = *(pmid + 1 - lWidth);
|
||||
p1 = *(pmid - lWidth);
|
||||
p0 = *(pmid - lWidth -1);
|
||||
p7 = *(pmid - 1);
|
||||
p6 = *(pmid + lWidth - 1);
|
||||
p5 = *(pmid + lWidth);
|
||||
p4 = *(pmid + lWidth + 1);
|
||||
|
||||
p1 *= 2;
|
||||
p2 *= 4;
|
||||
p3 *= 8;
|
||||
p4 *= 16;
|
||||
p5 *= 32;
|
||||
p6 *= 64;
|
||||
p7 *= 128;
|
||||
|
||||
sum = p0 | p1 | p2 | p3 | p4 | p5 | p6 | p7;
|
||||
if(deletemark[sum] == 1){
|
||||
*pmid = 0;
|
||||
bStart = true;
|
||||
}
|
||||
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
}
|
||||
|
||||
pmid++;
|
||||
pmid++;
|
||||
pmidtemp++;
|
||||
pmidtemp++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
11
测试/本机测试/2-侯-算法/handwriting/Thinner.h
Normal file
11
测试/本机测试/2-侯-算法/handwriting/Thinner.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//***************************************************************************
|
||||
// 文件:Thinner.h
|
||||
// 功能:四种不同的细化算法
|
||||
//***************************************************************************
|
||||
|
||||
void beforethin(unsigned char *ip,unsigned char *jp, unsigned long lx, unsigned long ly);
|
||||
void ThinnerHilditch(void *image, unsigned long lx, unsigned long ly);
|
||||
void ThinnerPavlidis(void *image, unsigned long lx, unsigned long ly);
|
||||
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly);
|
||||
//注意该函数lWidth应该是Height;
|
||||
//BOOL WINAPI ThiningDIBSkeleton (LPSTR lpDIBBits, LONG lWidth, LONG lHeight);
|
||||
47
测试/本机测试/2-侯-算法/handwriting/binary.cpp
Normal file
47
测试/本机测试/2-侯-算法/handwriting/binary.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 程序名:binary.c
|
||||
功能:读入图像文件,进行二值化
|
||||
*/
|
||||
#pragma once
|
||||
#include <cv.h>
|
||||
#include <highgui.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int* binary(IplImage* img,int bithro)
|
||||
{
|
||||
int height,width,step,channels;
|
||||
uchar *data;
|
||||
int i,j;
|
||||
static int black[1000]; //C语言不提倡返回一个局部变量的地址以外的功能,所以你必须定义的局部变量,如静态变量。
|
||||
/* 获取图像信息*/
|
||||
height = img->height;
|
||||
width = img->width;
|
||||
step = img->widthStep;
|
||||
channels = img->nChannels;
|
||||
data = (uchar *)img->imageData;
|
||||
|
||||
/*二值化,并统计黑像素的个数*/
|
||||
for(i=0;i<height;i++)
|
||||
{
|
||||
for(j=0;j<width;j++)//对图像每个点进行二值化,原值为128
|
||||
data[i*step+j*channels]=(data[i*step+j*channels]>bithro)?255:0;
|
||||
}
|
||||
|
||||
/*计算每一行的黑像素个数*/
|
||||
int tempBlackPixel=0;
|
||||
|
||||
memset(black,0,1000); //##初始化内存,这里用做清零black数组
|
||||
for(i=height-1;i>0;i--)
|
||||
{
|
||||
for(int j=0;j<width;j++)
|
||||
{
|
||||
if(data[i*step+j*channels]==0) //计算黑色的像素数
|
||||
tempBlackPixel+=1;
|
||||
}
|
||||
black[height-i]=tempBlackPixel; //black记录黑色像素数
|
||||
tempBlackPixel=0;
|
||||
}
|
||||
//二值化,并统计黑像素的个数**********
|
||||
return black;
|
||||
}
|
||||
|
||||
|
||||
14
测试/本机测试/2-侯-算法/handwriting/binary2.cpp
Normal file
14
测试/本机测试/2-侯-算法/handwriting/binary2.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
//图像的二值化
|
||||
#include <cv.h>
|
||||
#include <highgui.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
int* Binary2(IplImage *g_pGrayImage,int bithro)
|
||||
{
|
||||
IplImage *g_pBinaryImage = NULL;
|
||||
// 转为二值图
|
||||
cvThreshold(g_pGrayImage, g_pBinaryImage, bithro, 255, CV_THRESH_BINARY);
|
||||
cvCopy(g_pGrayImage, g_pBinaryImage,NULL);
|
||||
return 0;
|
||||
}
|
||||
39
测试/本机测试/2-侯-算法/handwriting/getFiles.cpp
Normal file
39
测试/本机测试/2-侯-算法/handwriting/getFiles.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/* 程序名:getFiles.c
|
||||
功能:返回一个文件夹下的所有文件名
|
||||
*/
|
||||
#pragma once
|
||||
#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) );
|
||||
// cout<<fileinfo.name<<endl;
|
||||
}
|
||||
}while(_findnext(hFile, &fileinfo) == 0);
|
||||
|
||||
_findclose(hFile);
|
||||
}
|
||||
}
|
||||
39
测试/本机测试/2-侯-算法/handwriting/getFolders.cpp
Normal file
39
测试/本机测试/2-侯-算法/handwriting/getFolders.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/* 程序名:getFolders.c
|
||||
功能:返回一个文件夹下的所有文件夹的名称
|
||||
*/
|
||||
#pragma once
|
||||
#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;
|
||||
|
||||
}
|
||||
28
测试/本机测试/2-侯-算法/handwriting/getType.cpp
Normal file
28
测试/本机测试/2-侯-算法/handwriting/getType.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*程序名:getType.c
|
||||
功能:读入图像文件名,得到图像类型
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
char * getType(char fileName[], char type[])
|
||||
{
|
||||
int i=strlen(fileName)-1, j;
|
||||
char ch;
|
||||
|
||||
for(type[0]='\0';i>=0;i--)
|
||||
{
|
||||
if(fileName[i] == '.')
|
||||
{// 遇到文件类型分隔符
|
||||
for(j=i; fileName[j]!='\0'; j++)
|
||||
{
|
||||
ch = fileName[j];
|
||||
type[j-i] = ('A'<=ch && ch<='Z') ? (ch+'a'-'A'): ch;
|
||||
}
|
||||
|
||||
type[j-i] = '\0';
|
||||
break;
|
||||
}
|
||||
else if(fileName[i] == '/' || fileName[i]=='\\') break;// 遇到目录分割符,退出
|
||||
}
|
||||
return type;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user