diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f91ff2b --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e17b128 --- /dev/null +++ b/README.md @@ -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 diff --git a/测试/服务器测试/wei服务-监控文件夹/Check.cpp b/测试/服务器测试/wei服务-监控文件夹/Check.cpp new file mode 100644 index 0000000..5231f1c --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/Check.cpp @@ -0,0 +1,65 @@ +#include "Check.h" + +char* GetTime(); + +/*ܣ鵱ǰľļУȡļɾļ +@ path ļλ +@ֵ ؼ⵽ı +*/ +int CheckFile(char* path, vector& 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; +} \ No newline at end of file diff --git a/测试/服务器测试/wei服务-监控文件夹/Check.h b/测试/服务器测试/wei服务-监控文件夹/Check.h new file mode 100644 index 0000000..b1131e4 --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/Check.h @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +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& files); + + diff --git a/测试/服务器测试/wei服务-监控文件夹/HWCV-exe.exe b/测试/服务器测试/wei服务-监控文件夹/HWCV-exe.exe new file mode 100644 index 0000000..fe6ed75 Binary files /dev/null and b/测试/服务器测试/wei服务-监控文件夹/HWCV-exe.exe differ diff --git a/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsp b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsp new file mode 100644 index 0000000..765385c --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsp @@ -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 diff --git a/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsw b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsw new file mode 100644 index 0000000..d8ca624 --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.dsw @@ -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> +{{{ +}}} + +############################################################################### + diff --git a/测试/服务器测试/wei服务-监控文件夹/HWCVServe.opt b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.opt new file mode 100644 index 0000000..6d503a1 Binary files /dev/null and b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.opt differ diff --git a/测试/服务器测试/wei服务-监控文件夹/HWCVServe.plg b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.plg new file mode 100644 index 0000000..293141e --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/HWCVServe.plg @@ -0,0 +1,29 @@ + + +
+

Build Log

+

+--------------------Configuration: HWCVServe - Win32 Debug-------------------- +

+

Command Lines

+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"" +

Output Window

+Compiling... +Main.cpp +e:\˧˧\github\hwcv\\\wei-ļ\main.cpp(63) : warning C4786: 'std::reverse_iterator,std::allocator > const *,std::basic_string,std::allocator >,std::basic_string,std::allocator > const &,std::basic_string,std::allocator > 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::allocator > *,std::basic_string,std::allocator >,std::basic_string,std::allocator > &,std::basic_string,std::allocator > *,int>' : identifier was truncated to '255' characters in the debug information +c:\program files\vc\vc98\include\vector(39) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +c:\program files\vc\vc98\include\vector(60) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::~vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information + + + +

Results

+Main.obj - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/服务器测试/wei服务-监控文件夹/Main.cpp b/测试/服务器测试/wei服务-监控文件夹/Main.cpp new file mode 100644 index 0000000..bdc7758 --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/Main.cpp @@ -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 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; +} diff --git a/测试/服务器测试/wei服务-监控文件夹/Main.h b/测试/服务器测试/wei服务-监控文件夹/Main.h new file mode 100644 index 0000000..b7708d3 --- /dev/null +++ b/测试/服务器测试/wei服务-监控文件夹/Main.h @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +#include +#include +#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}; \ No newline at end of file diff --git a/测试/服务器测试/输出文件/readme.txt b/测试/服务器测试/输出文件/readme.txt new file mode 100644 index 0000000..09df9ad --- /dev/null +++ b/测试/服务器测试/输出文件/readme.txt @@ -0,0 +1 @@ +ѯݿ⣬ļСD:/HWCV/Check/дļļΪ⿼Ŀ \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.cpp b/测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.cpp new file mode 100644 index 0000000..5da8082 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/DBop.cpp @@ -0,0 +1,123 @@ +/* +ʵļDBop.cpp ݿʵļ +*/ +#include "DBop.h" + +/*صȫֱ*/ + +_ConnectionPtr p_conn; /*ȫֱ Ӷ*/ +_RecordsetPtr p_recordset; /*ȫֱ ¼*/ +_CommandPtr p_cmd; /*ȫֱ */ +string str_conn; /*ȫֱ ַ*/ + + +/** +ܣ ѯѧѧţеָλõݿϢ(ѧ)ȫ洢Ϊstuvector͵ı + +@ stu ѧѧŴ洢 +@ֵ ɹ1 ʧ0 +*/ +int DbStu(vector& 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<Open(_vstr_qurry, + p_conn.GetInterfacePtr(), + adOpenStatic, + adLockOptimistic, + adCmdText); + if (!(SUCCEEDED(hr1))){ exit(-1); }//ȡɹֱ˳ + + int count_exit = 10; + do + {//ȡɹÿһд浽vectorstuĩβ + 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.ErrorInfo() << endl;*/ } + + cout<<"ѯ"< no_namespace rename("EOF", "adoEOF") + #else #pragma message( "Using Latest ADO" ) + #import no_namespace rename("EOF", "adoEOF") +#endif +*/ +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + + +/** +ܣ ѯѧѧţеָλõ +ݿϢ(ѧ)ȫ洢Ϊstuvector +ı + +@ stu ѧѧŴ洢 +@ֵ ɹ1 ʧ0 +*/ +int DbStu(vector& stu); + + + +int WriteToLog(char* str); \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.cpp b/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.cpp @@ -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 diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.h b/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/StdAfx.h @@ -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 + +// 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_) diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/main.cpp b/测试/服务器测试/输出文件/输出待检测检测文件 source/main.cpp new file mode 100644 index 0000000..cf57237 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/main.cpp @@ -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<<"ʼ"< stuNum; + + //ȡļø + memset(g_log_rec, 0, sizeof(g_log_rec)); + strcat(g_log_rec, GetTime()); + if (!ReadConfig("D:/HWCV/config/configure.cfg")) + { + cout<<"!ReadConfig"<> 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"<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"<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; +} diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/path.h b/测试/服务器测试/输出文件/输出待检测检测文件 source/path.h new file mode 100644 index 0000000..8c64b73 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/path.h @@ -0,0 +1,69 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include + +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); diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsp b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsp new file mode 100644 index 0000000..b9c2c8d --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsp @@ -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 diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsw b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsw new file mode 100644 index 0000000..e0cf035 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.dsw @@ -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> +{{{ +}}} + +############################################################################### + diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.opt b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.opt new file mode 100644 index 0000000..225d412 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.opt differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.plg b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.plg new file mode 100644 index 0000000..16dbd57 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件 source/test_all.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: test_all - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+test_all.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.cpp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.cpp new file mode 100644 index 0000000..ea579b6 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.cpp @@ -0,0 +1,119 @@ +/* +ʵļDBop.cpp ݿʵļ +*/ +#include "DBop.h" +#include "path.h" + +/*صȫֱ*/ + +_ConnectionPtr p_conn; /*ȫֱ Ӷ*/ +_RecordsetPtr p_recordset; /*ȫֱ ¼*/ +_CommandPtr p_cmd; /*ȫֱ */ +string str_conn; /*ȫֱ ַ*/ + + +/** +ܣ ѯѧѧţеָλõݿϢ(ѧ)ȫ洢Ϊstuvector͵ı + +@ stu ѧѧŴ洢 +@ֵ ɹ1 ʧ0 +*/ +int DbStu(vector& 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<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 + {//ȡɹÿһд浽vectorstuĩβ + 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; +} \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.h b/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.h new file mode 100644 index 0000000..a3ee7ac --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/DBop.h @@ -0,0 +1,41 @@ +/* +ͷļDBop.h ݿͷļ +*/ +#pragma once +#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile") +#include +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + +/** +ܣ ѯѧѧţеָλõݿϢ(ѧ)ȫ洢Ϊstuvector͵ı + +@ stu ѧѧŴ洢 +@ֵ ɹ1 ʧ0 +*/ +int DbStu(vector& stu); diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsp new file mode 100644 index 0000000..a24213a --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsp @@ -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 diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsw b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsw new file mode 100644 index 0000000..5879021 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.dsw @@ -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> +{{{ +}}} + +############################################################################### + diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.opt b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.opt new file mode 100644 index 0000000..d403969 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.opt differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.plg b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.plg new file mode 100644 index 0000000..500f815 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/HWCV_exe.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: HWCV_exe - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+HWCV_exe.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/Point.h b/测试/服务器测试/输出文件/输出待检测检测文件try catch/Point.h new file mode 100644 index 0000000..dd5b512 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/Point.h @@ -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;} +}; \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.cpp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.cpp @@ -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 diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.h b/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/StdAfx.h @@ -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 + +// 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_) diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/calibfilter.ax b/测试/服务器测试/输出文件/输出待检测检测文件try catch/calibfilter.ax new file mode 100644 index 0000000..6521c8f Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/calibfilter.ax differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/createsamples.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/createsamples.exe new file mode 100644 index 0000000..859b2e1 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/createsamples.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cv100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cv100.dll new file mode 100644 index 0000000..7655750 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cv100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvaux100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvaux100.dll new file mode 100644 index 0000000..860c8a9 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvaux100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvcam100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvcam100.dll new file mode 100644 index 0000000..933ef69 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvcam100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvinfo.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvinfo.exe new file mode 100644 index 0000000..6463d23 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvinfo.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvtest.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvtest.exe new file mode 100644 index 0000000..34fcdcc Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cvtest.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcore100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcore100.dll new file mode 100644 index 0000000..c2910f3 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcore100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcoretest.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcoretest.exe new file mode 100644 index 0000000..6b46283 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxcoretest.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxts001.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxts001.dll new file mode 100644 index 0000000..3f7f192 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/cxts001.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/haartraining.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/haartraining.exe new file mode 100644 index 0000000..e418330 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/haartraining.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/highgui100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/highgui100.dll new file mode 100644 index 0000000..a480999 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/highgui100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/libguide40.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/libguide40.dll new file mode 100644 index 0000000..104dac3 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/libguide40.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/ml100.dll b/测试/服务器测试/输出文件/输出待检测检测文件try catch/ml100.dll new file mode 100644 index 0000000..56fd236 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/ml100.dll differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.cpp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.cpp new file mode 100644 index 0000000..09f80d9 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.cpp @@ -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 &_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> 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; +} \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.h b/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.h new file mode 100644 index 0000000..84fd40e --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/path.h @@ -0,0 +1,98 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include +#include +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 &_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); \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/performance.exe b/测试/服务器测试/输出文件/输出待检测检测文件try catch/performance.exe new file mode 100644 index 0000000..594fe19 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/performance.exe differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/process.cpp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/process.cpp new file mode 100644 index 0000000..0b5cd1f --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/process.cpp @@ -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; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; 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; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/proxytrans.ax b/测试/服务器测试/输出文件/输出待检测检测文件try catch/proxytrans.ax new file mode 100644 index 0000000..f5b2ea8 Binary files /dev/null and b/测试/服务器测试/输出文件/输出待检测检测文件try catch/proxytrans.ax differ diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/registerall.bat b/测试/服务器测试/输出文件/输出待检测检测文件try catch/registerall.bat new file mode 100644 index 0000000..2c699ac --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/registerall.bat @@ -0,0 +1,3 @@ +regsvr32 /S %1 calibfilter.ax +regsvr32 /S %1 proxytrans.ax +regsvr32 /S %1 syncfilter.ax diff --git a/测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.cpp b/测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.cpp new file mode 100644 index 0000000..6c83db0 --- /dev/null +++ b/测试/服务器测试/输出文件/输出待检测检测文件try catch/segmentation.cpp @@ -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"< stuNum; + + while(true) + { + //ѯݿ + stuNum.clear(); + DbStu(stuNum); + for(int i=0;i ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& 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<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:"<RecordCount <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")) //49 ͷĿţͼֱӴ + 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"< dateVec, vector subjectVec, vector stuNum2, vector 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 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; +} \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/DBop.h b/测试/服务器测试/鉴定主程序/HWCV-exe/DBop.h new file mode 100644 index 0000000..635f605 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/DBop.h @@ -0,0 +1,55 @@ +/* +ͷļDBop.h ݿͷļ +*/ +#pragma once +#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile") +#include +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& stuNum2); + + +/** +ܣ ѧݿϢ,ѧļݿ + +@ stuNumѧ +@ subjectԿĿ +@ flagCheatױ +@ֵ ɹ1ʧ0 +*/ +int DbUpdate(string stuNum, vector dateVec, vector subjectVec, vector stuNum2, vector flagVec); \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj new file mode 100644 index 0000000..7c3ea37 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj @@ -0,0 +1,104 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {FB6A1EE7-710E-424B-A80E-A931EDB7DDBF} + Win32Proj + HWCVexe + + + + Application + true + v120 + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + E:\program files\opencv\build\x86\vc12\staticlib;$(LibraryPath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + 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) + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj.filters b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj.filters new file mode 100644 index 0000000..291bae6 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe.vcxproj.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe更改前bck.rar b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe更改前bck.rar new file mode 100644 index 0000000..79e530b Binary files /dev/null and b/测试/服务器测试/鉴定主程序/HWCV-exe/HWCV-exe更改前bck.rar differ diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/Point.h b/测试/服务器测试/鉴定主程序/HWCV-exe/Point.h new file mode 100644 index 0000000..dd5b512 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/Point.h @@ -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;} +}; \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.cpp b/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.cpp @@ -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 diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.h b/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/StdAfx.h @@ -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 + +// 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_) diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/path.cpp b/测试/服务器测试/鉴定主程序/HWCV-exe/path.cpp new file mode 100644 index 0000000..f595f7c --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/path.cpp @@ -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 &_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> 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; +} \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/path.h b/测试/服务器测试/鉴定主程序/HWCV-exe/path.h new file mode 100644 index 0000000..e765340 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/path.h @@ -0,0 +1,96 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include +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 &_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); \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/process.cpp b/测试/服务器测试/鉴定主程序/HWCV-exe/process.cpp new file mode 100644 index 0000000..c1e18be --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/process.cpp @@ -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; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; i++) + { + if (gjdata[j*imggj->widthStep + i] == 255) + gjdata[j*imggj->widthStep + i] = 1; + } + } + + /*ϸ*/ + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + /*ʼͼɫΧתˮƽ*/ + for (j = 0; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.cpp b/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.cpp new file mode 100644 index 0000000..50651c5 --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.cpp @@ -0,0 +1,243 @@ +/* +ļsegmentation.cpp ʵļ +*/ +#include "segmentation.h" +//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//ûн + +int ComputeImage(vector files, vector 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; //ͼֵ͵ijʼ + 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 suspict; //¼ͼƬַ + vector suspict_wcd; //ͼƬwcdֵ + vector files; //洢пļ· + vector dateVec, subjectVec, stuNum2; + vector 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"< 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 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; +} + + diff --git a/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.h b/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.h new file mode 100644 index 0000000..368daff --- /dev/null +++ b/测试/服务器测试/鉴定主程序/HWCV-exe/segmentation.h @@ -0,0 +1,75 @@ +/* +ͷļsegmentation.h ͷļ +*/ +#pragma once +#ifdef WIN32 //VC6STLһЩȫ֧ +#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; \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe.sln b/测试/本机测试/1-我-算法/HWCV-exe.sln new file mode 100644 index 0000000..b4b0448 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe.sln @@ -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 diff --git a/测试/本机测试/1-我-算法/HWCV-exe/DBop.cpp b/测试/本机测试/1-我-算法/HWCV-exe/DBop.cpp new file mode 100644 index 0000000..f428a63 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/DBop.cpp @@ -0,0 +1,209 @@ +/* +ʵļDBop.cpp ݿʵļ +*/ +#include "DBop.h" +#include "path.h" + +/*صȫֱ*/ + +_ConnectionPtr p_conn; /*ȫֱ Ӷ*/ +_RecordsetPtr p_recordset; /*ȫֱ ¼*/ +_CommandPtr p_cmd; /*ȫֱ */ +string str_conn; /*ȫֱ ַ*/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& 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<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:"<RecordCount <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"< dateVec, vector subjectVec, vector stuNum2, vector 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 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; +} \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/DBop.h b/测试/本机测试/1-我-算法/HWCV-exe/DBop.h new file mode 100644 index 0000000..635f605 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/DBop.h @@ -0,0 +1,55 @@ +/* +ͷļDBop.h ݿͷļ +*/ +#pragma once +#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile") +#include +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& stuNum2); + + +/** +ܣ ѧݿϢ,ѧļݿ + +@ stuNumѧ +@ subjectԿĿ +@ flagCheatױ +@ֵ ɹ1ʧ0 +*/ +int DbUpdate(string stuNum, vector dateVec, vector subjectVec, vector stuNum2, vector flagVec); \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj b/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj new file mode 100644 index 0000000..f77a171 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj @@ -0,0 +1,106 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {FB6A1EE7-710E-424B-A80E-A931EDB7DDBF} + Win32Proj + HWCVexe + HWCV + + + + Application + true + v120 + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + C:\Program Files %28x86%29\OpenCV\lib;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86) + 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) + 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) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + 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 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj.filters b/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj.filters new file mode 100644 index 0000000..bdf8018 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/HWCV-exe.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/Point.h b/测试/本机测试/1-我-算法/HWCV-exe/Point.h new file mode 100644 index 0000000..dd5b512 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/Point.h @@ -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;} +}; \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.cpp b/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.cpp @@ -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 diff --git a/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.h b/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/StdAfx.h @@ -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 + +// 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_) diff --git a/测试/本机测试/1-我-算法/HWCV-exe/path.cpp b/测试/本机测试/1-我-算法/HWCV-exe/path.cpp new file mode 100644 index 0000000..3819576 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/path.cpp @@ -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 &_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> 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& 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& 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 &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; + +} \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/path.h b/测试/本机测试/1-我-算法/HWCV-exe/path.h new file mode 100644 index 0000000..a07114f --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/path.h @@ -0,0 +1,122 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include +#include + +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 &_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& files); + + +/* +ܣȡָĿ¼µĿ¼ +@ path Ŀ¼ +@ files صĿ¼vector +@ֵ ɹ1ʧ0 +*/ +int getFolders(string path, vector& files); + + +/* +ܣĿ¼ +*/ +int searchDir(char *path, vector &dir); \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/process.cpp b/测试/本机测试/1-我-算法/HWCV-exe/process.cpp new file mode 100644 index 0000000..7ab14b2 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/process.cpp @@ -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; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; i++) + { + if (gjdata[j*imggj->widthStep + i] == 255) + gjdata[j*imggj->widthStep + i] = 1; + } + } + + /*ϸ*/ + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + /*ʼͼɫΧתˮƽ*/ + for (j = 0; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/测试/本机测试/1-我-算法/HWCV-exe/seg_bck.cpp b/测试/本机测试/1-我-算法/HWCV-exe/seg_bck.cpp new file mode 100644 index 0000000..6ae63b4 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/seg_bck.cpp @@ -0,0 +1,219 @@ +///* +//ļsegmentation.cpp ʵļ +//*/ +//#include "segmentation.h" +////#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//޽ +///**/ +//int ComputeImage(vector 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 suspict; //¼ͼƬַ +// vector suspict_wcd; //ͼƬwcdֵ +// vector 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 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; //ͼֵ͵ijʼ +// 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 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; //ͼֵ͵ijʼ +// 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; +//} diff --git a/测试/本机测试/1-我-算法/HWCV-exe/segmentation.cpp b/测试/本机测试/1-我-算法/HWCV-exe/segmentation.cpp new file mode 100644 index 0000000..5e682d2 --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/segmentation.cpp @@ -0,0 +1,225 @@ +/* +ļsegmentation.cpp ʵļ +*/ +#include "segmentation.h" +//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//޽ +/**/ + + +int ComputeImage(vector 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; //ͼֵ͵ijʼ + 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 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 suspict; //¼ͼƬַ + vector suspict_wcd; //ͼƬwcdֵ + vector 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 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 +} diff --git a/测试/本机测试/1-我-算法/HWCV-exe/segmentation.h b/测试/本机测试/1-我-算法/HWCV-exe/segmentation.h new file mode 100644 index 0000000..ba04abe --- /dev/null +++ b/测试/本机测试/1-我-算法/HWCV-exe/segmentation.h @@ -0,0 +1,45 @@ +/* +ͷļsegmentation.h ͷļ +*/ +#pragma once +#ifdef WIN32 //VC6STLһЩȫ֧ +#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}; \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting.sln b/测试/本机测试/2-侯-算法/handwriting.sln new file mode 100644 index 0000000..eac8bae --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting.sln @@ -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 diff --git a/测试/本机测试/2-侯-算法/handwriting/Cjbsb.cpp b/测试/本机测试/2-侯-算法/handwriting/Cjbsb.cpp new file mode 100644 index 0000000..dc997c0 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/Cjbsb.cpp @@ -0,0 +1,54 @@ +/* Cjbsb.c +ܣͼļͼĽDZ +*/ +#pragma once +#include +#include +#include +#include + +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; + + + + + //ԽDZΪвü뻭 + CvSize jbcjsize=cvSize(835,165); //DZüĴСΪ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; +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/Cword.cpp b/测试/本机测试/2-侯-算法/handwriting/Cword.cpp new file mode 100644 index 0000000..e69de29 diff --git a/测试/本机测试/2-侯-算法/handwriting/Cword.h b/测试/本机测试/2-侯-算法/handwriting/Cword.h new file mode 100644 index 0000000..adb2952 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/Cword.h @@ -0,0 +1,11 @@ +class Cword{ +private: + +public: + Point wbegin; + Point wend; +// int n; //ܸеλ + int nn; //е + bool isword; //ǷΪ + int blacknum; //еĺɫ +}; \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/Integral.cpp b/测试/本机测试/2-侯-算法/handwriting/Integral.cpp new file mode 100644 index 0000000..2183208 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/Integral.cpp @@ -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;i0) + { + outputMatrix[i] += outputMatrix[i-1]; + } + } + for (int i=1;i +#include +#include "Thinner.h" +#include + +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; i0) + 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=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=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=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; i0){ + 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 +#include +#include +#include +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;ibithro)?255:0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel=0; + + memset(black,0,1000); //##ʼڴ棬black + for(i=height-1;i>0;i--) + { + for(int j=0;j +#include +#include +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; +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/getFiles.cpp b/测试/本机测试/2-侯-算法/handwriting/getFiles.cpp new file mode 100644 index 0000000..9aa8815 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/getFiles.cpp @@ -0,0 +1,39 @@ +/* getFiles.c +ܣһļµļ +*/ +#pragma once +#include +#include +#include +#include +using namespace std; +#include + +void getFiles(string path, vector& 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< +#include +#include +#include +using namespace std; +#include + +int getFolders(string path, vector& 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; + +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/getType.cpp b/测试/本机测试/2-侯-算法/handwriting/getType.cpp new file mode 100644 index 0000000..b445e83 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/getType.cpp @@ -0,0 +1,28 @@ +/*getType.c +ܣͼļõͼ +*/ +#pragma once +#include +#include +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; +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/gif2ipl.cpp b/测试/本机测试/2-侯-算法/handwriting/gif2ipl.cpp new file mode 100644 index 0000000..0bed703 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/gif2ipl.cpp @@ -0,0 +1,58 @@ +/* gif2ipl.c +ܣgifͼ񡣵õӦrgbͼ +*/ +#include +#include +#include "FreeImage.h" +#include +IplImage* gif2ipl(const char* filename) +{ + FreeImage_Initialise(); //load the FreeImage function lib + FREE_IMAGE_FORMAT fif = FIF_GIF; + FIBITMAP* fiBmp = FreeImage_Load(fif,filename,GIF_DEFAULT); + FIMULTIBITMAP * pGIF=FreeImage_OpenMultiBitmap(fif,filename,0,1,0,GIF_PLAYBACK); + // FIBITMAPINFO fiBmpInfo = getfiBmpInfo(fiBmp); + int gifImgCnt=FreeImage_GetPageCount(pGIF); + FIBITMAP * pFrame; + int width,height; + width=FreeImage_GetWidth(fiBmp); + height=FreeImage_GetHeight(fiBmp); + IplImage * iplImg = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3); + iplImg->origin = 1;//should set to 1-top-left structure(Windows bitmap style) + RGBQUAD* ptrPalette =new RGBQUAD; // = FreeImage_GetPalette(fiBmp); + BYTE intens; + BYTE* pIntensity = &intens; + //cvNamedWindow("gif",0); + //printf("gifͼƬĿ%d \n",gifImgCnt); + for (int curFrame=0;curFrameimageData + i*iplImg->widthStep; + for(int j=0;jrgbBlue; + ptrImgDataPerLine[3*j+1] = ptrPalette->rgbGreen; + ptrImgDataPerLine[3*j+2] = ptrPalette->rgbRed; + //ptrImgDataPerLine[3*j] = ptrPalette[intens].rgbBlue; + //ptrImgDataPerLine[3*j+1] = ptrPalette[intens].rgbGreen; + //ptrImgDataPerLine[3*j+2] = ptrPalette[intens].rgbRed; + } + } + + //printf("תͼƬţ %d \n",curFrame); + // cvShowImage("gif",iplImg); + // cvWaitKey(30); + // FreeImage_UnlockPage(pGIF,pFrame,1); + } + FreeImage_Unload(fiBmp); + FreeImage_DeInitialise(); + + return iplImg; +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj b/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj new file mode 100644 index 0000000..f207b0c --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {4A0EA5CA-C4D6-4A83-9201-B683D6FAEBD5} + Win32Proj + handwriting + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + C:\Program Files %28x86%29\OpenCV\otherlibs;C:\Program Files %28x86%29\OpenCV\bin;C:\Program Files %28x86%29\OpenCV\cvaux\include;$(ExecutablePath) + 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) + C:\Program Files %28x86%29\OpenCV\cv\src;C:\Program Files %28x86%29\OpenCV\lib;$(LibraryPath) + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 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 + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj.filters b/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj.filters new file mode 100644 index 0000000..49a048b --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/handwriting.vcxproj.filters @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/outline.cpp b/测试/本机测试/2-侯-算法/handwriting/outline.cpp new file mode 100644 index 0000000..2ac1440 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/outline.cpp @@ -0,0 +1,47 @@ +/* outline.c +ܣͼ񡣵õӦͼ +*/ +#pragma once +#include +#include +#include +#include + +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; + + + for(j=0;jimageData[j*step+i*channels]=255; + for( i=0;iimageData[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;iimageData[(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; +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/outlinefeature.cpp b/测试/本机测试/2-侯-算法/handwriting/outlinefeature.cpp new file mode 100644 index 0000000..8fcc611 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/outlinefeature.cpp @@ -0,0 +1,264 @@ +/* outline.c +ܣͼ񡣷Ӧֵ +*/ +#pragma once +#include +#include +#include +#include +#include "Point.h" + +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 ı + +/* ȡͼϢ*/ + 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=0;i<9;i++) // +// { +// for(j=0;j<9;j++) +// printf("%d*",outllab[i][j]); +// printf("\n"); +// } +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*********************** + + } + + } +} + + //****עֵΪfeat(x,y)+feat(y,x)feat(x,y)Уx +#include +#include +#include +using namespace std; + +int read_scanf(const string &filename,const int &cols,vector &_vector) +{ + FILE *fp=fopen(filename.c_str(),"r"); + bool flag=true; + int i=0; + if(!fp) { cout<<"File open error!\n"; return 0; } + while(flag) + { + double *point=new double[cols]; + for(i=0;i +#include +#include +#include +#include +#include +using namespace std; + +int searchDir( char *path, vector &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; + +} \ No newline at end of file diff --git a/测试/本机测试/2-侯-算法/handwriting/segmentation.cpp b/测试/本机测试/2-侯-算法/handwriting/segmentation.cpp new file mode 100644 index 0000000..f12e425 --- /dev/null +++ b/测试/本机测试/2-侯-算法/handwriting/segmentation.cpp @@ -0,0 +1,246 @@ +/* segmentation.c +ܣܳ򣺶ͼļЧ +*/ +//#include "stdafx.h" +#pragma once +#include +#include +#include +#include +#include +#include +#include "Point.h" +#include "Cword.h" +//#include "FreeImage.h" //ڶgifͼ,gifͼתΪpng +#include //5ڶȡļµļ +#include +#include +#include +#include //ڵʾ,,,мǣʱҪMFCAfx.h) +#include +using namespace std; +#ifdef WIN32 //VC6STLһЩȫ֧ +#pragma warning (disable: 4514 4786) +#endif + +void getFiles(string path, vector& files );//9ȡļļ +void on_mouse( int event, int x, int y, int flags, void* ustc); +char* getType(char fileName[], char type[]); //2ȡͼ +int* binary(IplImage* img,int bithro); //3ֵͼ +int getFolders(string path, vector& files );//11ȡļļе +int read_scanf(const string &filename,const int &cols,vector &_vector);//12ȡѾõֵ +int outlinefeature(IplImage* imglk,int feature[ ][50]); //7ͼֵ +int searchDir(char* path, vector &dir);//ȡĿ¼һļ +IplImage* Cjbsb(IplImage* img,IplImage* imgjbsb,int jbwhite,int jbblack);//4ͼDZʶ +IplImage* worddivide(IplImage* imgbj,int hthro,int wthro,int *gridx,int *gridy,int *gxx,int *gyy); //5ΪϷ +IplImage* outline(IplImage* imgbj); //6ͼӦͼ +IplImage* gif2ipl(const char* filename); //1ȡgifⲿ +IplImage* wordrecognize(IplImage* imgbj,int *gridx,int *gridy,Cword *wordbox,int gx,int gy);//8жϷеǷΪ +IplImage* singlefeature(char* path,int feature[ ][50]);//10óļֵ + +int pos_x=0,pos_y=0; +bool pos_flag=false; +IplImage* src; +int picAll = 0, picSus = 0; +int stuAll = 0, stuSus = 0; + +int ComputeImage(vector 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; //ͼֵ͵ijʼ + 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; +} + +////////////////////////////////////////////////////////////////////////////////////////////// +int main() +{ + // + vector dir; //洢Ŀ¼ + int conti=1; //Աͼı + int size_dir,num_dir; + char record[2400]={0}; + + // ׼ļ + char* fpname= "C:/Users/˧˧/Desktop/result2.txt"; + FILE* fpzz=NULL;//Ҫע + //fpzz=fopen(fpname,"w+"); //ļ //a + //if(NULL==fpzz) return -1;//Ҫش + //fprintf(fpzz,record); //ӿ̨ж벢ı + //fclose(fpzz); + //fpzz=NULL;//Ҫָգָԭļַ + + // ȡļе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 suspict; //¼ͼƬַ + vector suspict_wcd; + vector files; //洢ļ· + + getFiles(dir[num_dir].c_str(), files ); //ǰļµļ + // + printf("ڽе%dĿ¼Ϊ%s",num_dir,dir[num_dir].c_str()); + + size = files.size(); //ͼĿ + // + printf("ļΪ%d\t",size); + + //׼еkesaؽ + string bzcfile="D:/Xiangmu/Img/bzc/bzc.txt"; + //txtļ47 + int bzccolumns=47; + vector output_bzc; + if(!read_scanf(bzcfile,bzccolumns,output_bzc)) return 0; + //output_vectorΪά;Ԫأ + //int rows=output_bzc.size(); + for(ii=0;ii<48;ii++) + for(jj=ii+1;jj<47;jj++) + bzckesa[ii][jj]=output_bzc[ii][jj]; + + //ʼÿһͼƬд + for(int r=0;r0.12) + { + xyimgnum++; + suspict.push_back(files[i].c_str()); + suspict_wcd.push_back(wcd[i]); + } + } + if (xyimgnum<3) break; + } + + //txt + //------------------------------------------------------// + char record[8000]; + memset(record, 0, sizeof(record)); + char pic_num[20]; + memset(pic_num, 0, sizeof(pic_num)); + _itoa(size, pic_num, 10); + strcat(record, dir[num_dir].substr(27, 22).c_str()); //ѧ + strcat(record, "\t"); + strcat(record,pic_num); + if(xyimgnum>0) + { + stuSus++; + char b[20]; + sprintf(b, "\t%d", xyimgnum); + strcat(record, b); + strcat(record, "\n"); +// cout << xyimgnum << endl;; + for(int t=0;t +#include +#include +#include +#include +#include "Point.h" +#include "Cword.h" +//#include "FreeImage.h" //ڶgifͼ +#include //5ڶȡļµļ +#include +#include +using namespace std; +#include +#include +#include"Thinner.h" + +/**/ + +void getFiles(string path, vector& files );//ȡļļ +char* getType(char fileName[], char type[]); //ȡͼ +int* binary(IplImage* img,int bithro); //ֵͼ +int outlinefeature(IplImage* imglk,int feature[ ][50]);//ͼֵ +IplImage* Cjbsb(IplImage* img,IplImage* imgjbsb,int jbwhite,int jbblack);//ͼDZʶ +IplImage* gif2ipl(const char* filename); //ȡgifⲿ + +IplImage* singlefeature(char* path,int feature[ ][50]){ + // + IplImage* img = 0; //ԭͼ + IplImage* imglk = 0; //ͼ + IplImage* imggj = 0; //Ǽͼ + IplImage* imgjbsb = 0; //DZʶͼ + IplImage* imgbj = 0; //ֻȡʼDzֵͼ + IplImage* imgbjhf = 0; //ΪϷ + IplImage* imgwzbj = 0; //ΪǷΪֱ֣ǣ + + char imgtype[10]; //жͼ + int height,width,step,channels; + uchar *data; + + int i,j; + int *black; //ڷͼÿкصĸ + //int feature[50][50]={0}; //ֵʼ + + 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=880; + 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 - ֵ. + + /*ֵ*/ + int bithro=230; //ֵֵ (0--255) + black=binary(imgbig,bithro); //ֵͳƺصĸÿкصĸ(black) + //cvNamedWindow("ֵͼ",CV_WINDOW_AUTOSIZE); //ʾͼ + //cvShowImage("ֵͼ",img); + //printf("ֵɣ\n"); + + + + /*DZʶ*/ + 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;jheight;j++) + { //ȡֵΧת0--1 + + for(i=0;iwidth;i++) + { + if(gjdata[j*imggj->widthStep+i]==255) + gjdata[j*imggj->widthStep+i]=1; + } + } + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + for(j=0;jheight;j++) + {//ȡֵΧת0--255,ת + for(i=0;iwidth;i++) + { + if(gjdata[j*imggj->widthStep+i]==1) + gjdata[j*imggj->widthStep+i]=0; + else + gjdata[j*imggj->widthStep+i]=255; + } + } + + //ͼ Ӧͼļ + /* + 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 +#include +#include +#include + +IplImage* worddivide(IplImage* imgbj,int hthro,int wthro,int *gridx,int *gridy,int *gxx,int *gyy){ + /**/ + int height,width,step,channels; + uchar *data; + + int i,j,black[1000]; + int blackend=0; //Ƿָ߽ + int mi=0,mx=500; //Ƿָںɫٵߺֵ + int gx=0,gy=0; //¼ûߵߵкк gridx[10],gridy[30], + memset(gridx,0,10); //ʼڴ棬 + memset(gridy,0,30); //ʼڴ棬 + + /*µͼ*/ + IplImage* imgbjhf = cvCreateImage(cvGetSize(imgbj),imgbj->depth,imgbj->nChannels); //ʼͼ + cvCopy(imgbj,imgbjhf,NULL); + + /* ȡͼϢ*/ + height = imgbjhf->height; + width = imgbjhf->width; + step = imgbjhf->widthStep; + channels = imgbjhf->nChannels; + data = (uchar *)imgbjhf->imageData; + + + /*ı*/ + /*ÿһеĺɫص˲ʹöֵõģ*/ + int tempBlackPixelx=0; //ѭ¼ÿһеĺɫص + + memset(black,0,1000); //ʼڴ棬 + for(j=0;jhthro) || i==height-1){ + blackend=0; + + gridx[gx]=mi; + //printf("<б꣺%d>",gridx[gx]); + gx++; + mx=500; + mi=i; + } + } + + /*ı*/ + + //ÿһеĺظ + int tempBlackPixely=0; + memset(black,0,1000); //ʼڴ棬 + for(i=0;iwthro)){ + blackend=0; + + if(gy==0){ + gridy[gy]=mi; //ºɫٵĵλ + gy++; + } + else if(mi-gridy[gy-1]<=25){ //Ƿ̫Сһ + gridy[gy-1]=mi; // + } + else{ + gridy[gy]=mi; //ºɫٵĵλ + //printf("<б꣺%d>",gridy[gy]); + gy++; + } + mx=500; + mi=i; + } + } + + gridy[gy]=mi; //һнд + gy++; + //for(j=0;j +#include +#include +#include +#include "Point.h" +#include "Cword.h" + +IplImage* wordrecognize(IplImage* imgbj,int *gridx,int *gridy,Cword *wordbox,int gx,int gy){ + /**/ + int i,j,ni,numw,nblack=0,wnum=0; + //Cword wordbox[150]; + int sumnum=(gx-1)*(gy-1); + + int height,width,step,channels; + uchar *data; + + /*µͼ*/ + IplImage* imgwzbj = cvCreateImage(cvGetSize(imgbj),imgbj->depth,imgbj->nChannels); + cvCopy(imgbj,imgwzbj,NULL); + uchar *wzbjdata = (uchar *)imgwzbj->imageData; + + /* ȡͼϢ*/ + height = imgbj->height; + width = imgbj->width; + step = imgbj->widthStep; + channels = imgbj->nChannels; + data = (uchar *)imgbj->imageData; + + /*ʼ*/ + for(i=0;i80){ + wordbox[ni].isword=true; + wnum++; + wordbox[ni].nn=wnum; + + //printf("x= %d;;;y=%d \n",wordbox[ni].wbegin.x,wordbox[ni].wbegin.y); + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+2)*channels]=0; //һͼϣ֣һ+ + wzbjdata[(wordbox[ni].wbegin.x+1)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+3)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+1)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+3)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+4)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+4)*channels]=0; + } + else{ + wordbox[ni].isword=false; + + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+2)*channels]=0; //һͼϣ֣һ- + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+1)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+3)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+4)*channels]=0; + } + wordbox[ni].blacknum=nblack; + nblack=0; + } + return imgwzbj; +} \ No newline at end of file diff --git a/测试/本机测试/HWCV_vc6/HWCV_vc6.dsp b/测试/本机测试/HWCV_vc6/HWCV_vc6.dsp new file mode 100644 index 0000000..fa7f44f --- /dev/null +++ b/测试/本机测试/HWCV_vc6/HWCV_vc6.dsp @@ -0,0 +1,133 @@ +# Microsoft Developer Studio Project File - Name="HWCV_vc6" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=HWCV_vc6 - 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_vc6.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_vc6.mak" CFG="HWCV_vc6 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "HWCV_vc6 - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "HWCV_vc6 - 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_vc6 - 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_vc6 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x804 /d "_DEBUG" +# ADD RSC /l 0x804 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 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 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 "HWCV_vc6 - Win32 Release" +# Name "HWCV_vc6 - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\path.cpp +# End Source File +# Begin Source File + +SOURCE=.\process.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=.\path.h +# End Source File +# Begin Source File + +SOURCE=.\Point.h +# End Source File +# Begin Source File + +SOURCE=.\process.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 diff --git a/测试/本机测试/HWCV_vc6/HWCV_vc6.dsw b/测试/本机测试/HWCV_vc6/HWCV_vc6.dsw new file mode 100644 index 0000000..29a8de7 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/HWCV_vc6.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# : ܱ༭ɾùļ + +############################################################################### + +Project: "HWCV_vc6"=".\HWCV_vc6.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/测试/本机测试/HWCV_vc6/HWCV_vc6.opt b/测试/本机测试/HWCV_vc6/HWCV_vc6.opt new file mode 100644 index 0000000..ae3b405 Binary files /dev/null and b/测试/本机测试/HWCV_vc6/HWCV_vc6.opt differ diff --git a/测试/本机测试/HWCV_vc6/HWCV_vc6.plg b/测试/本机测试/HWCV_vc6/HWCV_vc6.plg new file mode 100644 index 0000000..876fac0 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/HWCV_vc6.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: HWCV_vc6 - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+HWCV_vc6.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/本机测试/HWCV_vc6/Point.h b/测试/本机测试/HWCV_vc6/Point.h new file mode 100644 index 0000000..61a71e1 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/Point.h @@ -0,0 +1,14 @@ +/* +ͷļPoint.h ͼеص㶨 +*/ +#pragma once +#include "StdAfx.h" +class Point{ +private: + +public: + int x; + int y; + + void setpoint(int a,int b){x=a;y=b;} +}; \ No newline at end of file diff --git a/测试/本机测试/HWCV_vc6/StdAfx.cpp b/测试/本机测试/HWCV_vc6/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/测试/本机测试/HWCV_vc6/StdAfx.cpp @@ -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 diff --git a/测试/本机测试/HWCV_vc6/StdAfx.h b/测试/本机测试/HWCV_vc6/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/测试/本机测试/HWCV_vc6/StdAfx.h @@ -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 + +// 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_) diff --git a/测试/本机测试/HWCV_vc6/path.cpp b/测试/本机测试/HWCV_vc6/path.cpp new file mode 100644 index 0000000..5ff4013 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/path.cpp @@ -0,0 +1,263 @@ +/* +ʵļ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 &_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> 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& 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& 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 &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; + +} \ No newline at end of file diff --git a/测试/本机测试/HWCV_vc6/path.h b/测试/本机测试/HWCV_vc6/path.h new file mode 100644 index 0000000..f867936 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/path.h @@ -0,0 +1,123 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include "StdAfx.h" +#include +#include +#include +#include +#include +#include +#include + +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 &_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& files); + + +/* +ܣȡָĿ¼µĿ¼ +@ path Ŀ¼ +@ files صĿ¼vector +@ֵ ɹ1ʧ0 +*/ +int getFolders(string path, vector& files); + + +/* +ܣĿ¼ +*/ +int searchDir(char *path, vector &dir); \ No newline at end of file diff --git a/测试/本机测试/HWCV_vc6/process.cpp b/测试/本机测试/HWCV_vc6/process.cpp new file mode 100644 index 0000000..dd0d370 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/process.cpp @@ -0,0 +1,713 @@ +/* +ʵļprocess.cpp ͼ̵ʵļ +*/ +#include "process.h" + +int ComputeImage(vector files, double bzckesa[50][50], double *wcd, int conti) +{ + cout<<"1231s"<height; + width = img->width; + step = img->widthStep; + channels = img->nChannels; + data = (uchar *)img->imageData; + + /*ֵͳƺصĸ*/ + for (i = 0; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; i++) + { + if (gjdata[j*imggj->widthStep + i] == 255) + gjdata[j*imggj->widthStep + i] = 1; + } + } + + /*ϸ*/ + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + /*ʼͼɫΧתˮƽ*/ + for (j = 0; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +/*ȫֱ*/ +extern IplImage* src; + +/***************************************ԭ****************************************/ + +int ComputeImage(vector files, double bzckesa[50][50], double *wcd, int conti); +/* +ܣͼļжֵ + +@ 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); \ No newline at end of file diff --git a/测试/本机测试/HWCV_vc6/seg_bck.cpp b/测试/本机测试/HWCV_vc6/seg_bck.cpp new file mode 100644 index 0000000..6ae63b4 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/seg_bck.cpp @@ -0,0 +1,219 @@ +///* +//ļsegmentation.cpp ʵļ +//*/ +//#include "segmentation.h" +////#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//޽ +///**/ +//int ComputeImage(vector 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 suspict; //¼ͼƬַ +// vector suspict_wcd; //ͼƬwcdֵ +// vector 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 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; //ͼֵ͵ijʼ +// 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 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; //ͼֵ͵ijʼ +// 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; +//} diff --git a/测试/本机测试/HWCV_vc6/segmentation.cpp b/测试/本机测试/HWCV_vc6/segmentation.cpp new file mode 100644 index 0000000..0431a96 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/segmentation.cpp @@ -0,0 +1,146 @@ +/* +ļsegmentation.cpp ʵļ +*/ +#include "segmentation.h" +//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//޽ +/**/ + + +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; //ͼƬĿ + + vector suspict; //¼ͼƬַ + vector suspict_wcd; //ͼƬwcdֵ + vector 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 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; + } +// cout<<"׼"<0.12) + { + xyimgnum++; + suspict.push_back(files[i].c_str()); + suspict_wcd.push_back(wcd[i]); + } + } + if (xyimgnum<3) break; + } + + /*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)); + + /*ֵ*/ + system("pause"); + return 0; +} diff --git a/测试/本机测试/HWCV_vc6/segmentation.h b/测试/本机测试/HWCV_vc6/segmentation.h new file mode 100644 index 0000000..ffb6da0 --- /dev/null +++ b/测试/本机测试/HWCV_vc6/segmentation.h @@ -0,0 +1,43 @@ +/* +ͷļsegmentation.h ͷļ +*/ +#pragma once +#ifdef WIN32 //VC6STLһЩȫ֧ +#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ļַ*/ + + + +time_t ltime; +char *srcTime=NULL; +char timeNow[32]={0}; +char msg[100]={0}; \ No newline at end of file diff --git a/测试/本机测试/Serve/Serve.dsp b/测试/本机测试/Serve/Serve.dsp new file mode 100644 index 0000000..e42ff45 --- /dev/null +++ b/测试/本机测试/Serve/Serve.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="Serve" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=Serve - 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 "Serve.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 "Serve.mak" CFG="Serve - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Serve - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "Serve - 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)" == "Serve - 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)" == "Serve - 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 "Serve - Win32 Release" +# Name "Serve - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\seachDir.cpp +# End Source File +# Begin Source File + +SOURCE=.\segmentation.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/测试/本机测试/Serve/Serve.dsw b/测试/本机测试/Serve/Serve.dsw new file mode 100644 index 0000000..019bf2a --- /dev/null +++ b/测试/本机测试/Serve/Serve.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# : ܱ༭ɾùļ + +############################################################################### + +Project: "Serve"=".\Serve.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/测试/本机测试/Serve/Serve.opt b/测试/本机测试/Serve/Serve.opt new file mode 100644 index 0000000..d0895ed Binary files /dev/null and b/测试/本机测试/Serve/Serve.opt differ diff --git a/测试/本机测试/Serve/Serve.plg b/测试/本机测试/Serve/Serve.plg new file mode 100644 index 0000000..06c0501 --- /dev/null +++ b/测试/本机测试/Serve/Serve.plg @@ -0,0 +1,35 @@ + + +
+

Build Log

+

+--------------------Configuration: Serve - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP8D94.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/Serve.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"D:\CODE\HWCV\\\Serve\segmentation.cpp" +] +Creating command line "cl.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP8D94.tmp"" +Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP8D95.tmp" with contents +[ +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 /incremental:yes /pdb:"Debug/Serve.pdb" /debug /machine:I386 /out:"Debug/Serve.exe" /pdbtype:sept +".\Debug\seachDir.obj" +".\Debug\segmentation.obj" +] +Creating command line "link.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP8D95.tmp"" +

Output Window

+Compiling... +segmentation.cpp +c:\program files\vc\vc98\include\vector(39) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +c:\program files\vc\vc98\include\vector(60) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::~vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +Linking... + + + +

Results

+Serve.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/本机测试/Serve/seachDir.cpp b/测试/本机测试/Serve/seachDir.cpp new file mode 100644 index 0000000..aa01544 --- /dev/null +++ b/测试/本机测试/Serve/seachDir.cpp @@ -0,0 +1,44 @@ +/* getFiles.c +ܣһļµļ +*/ +#include +#include +#include +#include +#include +#include +using namespace std; + +int searchDir( char *path, vector &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; + +} \ No newline at end of file diff --git a/测试/本机测试/Serve/segmentation.cpp b/测试/本机测试/Serve/segmentation.cpp new file mode 100644 index 0000000..7dd965f --- /dev/null +++ b/测试/本机测试/Serve/segmentation.cpp @@ -0,0 +1,52 @@ +/* segmentation.c +ܣܳ򣺶ͼļЧ +*/ +//#include "stdafx.h" +#include +#include +#include +#include +#include +#include +#include //5ڶȡļµļ +#include +#include +#include +#include +#include +using namespace std; +#ifdef WIN32 //VC6STLһЩȫ֧ +#pragma warning (disable: 4514 4786) +#endif + +int searchDir(char* path, vector &dir);//ȡĿ¼һļ + +int main() +{ + + char path[100] = "E:/xiangmu/Img/imgjiaobiao/"; + + vector dir; //洢Ŀ¼ + + + char* fpname = "C:/Users/˧˧/Desktop/result2.txt"; + char record[2400] = { 0 }; + FILE* fpzz = NULL;//Ҫע + + searchDir(path, dir);//ȡfilePathµһĿ¼洢dir + int size = dir.size(); //dirĴСѧ + + + //ʼ + //-------------------------------------------------------------// + for (int i = 0; i < size; i++)//ÿһѧĿ¼ѭ + { + cout << dir[i].c_str() << endl; + ShellExecute(NULL, "open", + "D:\\CODE\\HWCV\\\\HWCV-exe\\Release\\HWCV.exe", + dir[i].c_str(), + NULL, + SW_SHOWNORMAL); + } + return 0; +} \ No newline at end of file diff --git a/测试/本机测试/获取图像文件/getFiles.cpp b/测试/本机测试/获取图像文件/getFiles.cpp new file mode 100644 index 0000000..f1aec8b --- /dev/null +++ b/测试/本机测试/获取图像文件/getFiles.cpp @@ -0,0 +1,37 @@ +/* getFiles.c +ܣһļµļ +*/ +#include +#include +#include +#include +using namespace std; +#include + +void getFiles(string path, vector& 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); + } +} \ No newline at end of file diff --git a/测试/本机测试/获取图像文件/getFloders.cpp b/测试/本机测试/获取图像文件/getFloders.cpp new file mode 100644 index 0000000..1b393d3 --- /dev/null +++ b/测试/本机测试/获取图像文件/getFloders.cpp @@ -0,0 +1,38 @@ +/* getFolders.c +ܣһļµļе +*/ +#include +#include +#include +#include +using namespace std; +#include + +int getFolders(string path, vector& 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; + +} \ No newline at end of file diff --git a/测试/本机测试/获取图像文件/getFolders.cpp b/测试/本机测试/获取图像文件/getFolders.cpp new file mode 100644 index 0000000..dd18c57 --- /dev/null +++ b/测试/本机测试/获取图像文件/getFolders.cpp @@ -0,0 +1,65 @@ +/* getFolders.c +ܣһļµļе +*/ +#include +#include +#include +#include +using namespace std; +#include + +int getFolders(string path, vector& files ) +{ + using namespace std;//ռ + //ļ + long hFile = 0; + //ļϢ + struct _finddata_t fileinfo; + string p; + + /* + hFile=_findfirst(p.assign(path).append("\\*").c_str(),&fileinfo); //һβ to_search??? + files.push_back(p.assign(path).append("\\").append(fileinfo.name) ); + if(-1==hFile)return -1; //ǰļûļ + + printf("%s\n",fileinfo.name); //ӡҵļļ + int i=0; + while(!_findnext(hFile,&fileinfo)) //ѭϵļ֪ҲΪֹ + { + printf("%s\n",files[i].c_str()); + i++; + } + _findclose(hFile); //˹رվ + system("pause"); + return 0; + */ + + + + int i=0; + if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1) + { + do + { + //Ŀ¼,֮ + //,б + //if((fileinfo.attrib & _A_SUBDIR)) + //{ + // if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0) + // getFiles( p.assign(path).append("\\").append(fileinfo.name), files ); + //} + //else + //{ + if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0) + { + files.push_back(p.assign(path).append("\\").append(fileinfo.name) ); + printf("ļУ%s\n",files[i].c_str()); + i++; + } + //} + }while(_findnext(hFile, &fileinfo) == 0); + _findclose(hFile); + } + return 0; + +} \ No newline at end of file diff --git a/测试/本机测试/获取图像文件/handwriting.dsp b/测试/本机测试/获取图像文件/handwriting.dsp new file mode 100644 index 0000000..ab90c82 --- /dev/null +++ b/测试/本机测试/获取图像文件/handwriting.dsp @@ -0,0 +1,114 @@ +# Microsoft Developer Studio Project File - Name="handwriting" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=handwriting - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "handwriting.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "handwriting.mak" CFG="handwriting - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "handwriting - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "handwriting - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "handwriting - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x804 /d "NDEBUG" +# ADD RSC /l 0x804 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "handwriting - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x804 /d "_DEBUG" +# ADD RSC /l 0x804 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "handwriting - Win32 Release" +# Name "handwriting - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\getFiles.cpp +# End Source File +# Begin Source File + +SOURCE=.\getFloders.cpp +# End Source File +# Begin Source File + +SOURCE=.\searchDir.cpp +# End Source File +# Begin Source File + +SOURCE=.\segmentation.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/测试/本机测试/获取图像文件/handwriting.dsw b/测试/本机测试/获取图像文件/handwriting.dsw new file mode 100644 index 0000000..4aad161 --- /dev/null +++ b/测试/本机测试/获取图像文件/handwriting.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# : ܱ༭ɾùļ + +############################################################################### + +Project: "handwriting"=.\handwriting.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/测试/本机测试/获取图像文件/handwriting.opt b/测试/本机测试/获取图像文件/handwriting.opt new file mode 100644 index 0000000..f0fe020 Binary files /dev/null and b/测试/本机测试/获取图像文件/handwriting.opt differ diff --git a/测试/本机测试/获取图像文件/handwriting.plg b/测试/本机测试/获取图像文件/handwriting.plg new file mode 100644 index 0000000..fe8780c --- /dev/null +++ b/测试/本机测试/获取图像文件/handwriting.plg @@ -0,0 +1,38 @@ + + +
+

Build Log

+

+--------------------Configuration: handwriting - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP9995.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/handwriting.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"D:\CODE\HWCV\\ȡͼļ\segmentation.cpp" +] +Creating command line "cl.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP9995.tmp"" +Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP9996.tmp" with contents +[ +FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/handwriting.pdb" /debug /machine:I386 /out:"Debug/handwriting.exe" /pdbtype:sept +".\Debug\getFiles.obj" +".\Debug\getFloders.obj" +".\Debug\searchDir.obj" +".\Debug\segmentation.obj" +] +Creating command line "link.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP9996.tmp"" +

Output Window

+Compiling... +segmentation.cpp +D:\CODE\HWCV\\ȡͼļ\segmentation.cpp(63) : warning C4508: 'main' : function should return a value; 'void' return type assumed +c:\program files\vc\vc98\include\vector(39) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +c:\program files\vc\vc98\include\vector(60) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::~vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +Linking... + + + +

Results

+handwriting.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/本机测试/获取图像文件/searchDir.cpp b/测试/本机测试/获取图像文件/searchDir.cpp new file mode 100644 index 0000000..aa01544 --- /dev/null +++ b/测试/本机测试/获取图像文件/searchDir.cpp @@ -0,0 +1,44 @@ +/* getFiles.c +ܣһļµļ +*/ +#include +#include +#include +#include +#include +#include +using namespace std; + +int searchDir( char *path, vector &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; + +} \ No newline at end of file diff --git a/测试/本机测试/获取图像文件/segmentation.cpp b/测试/本机测试/获取图像文件/segmentation.cpp new file mode 100644 index 0000000..00822f3 --- /dev/null +++ b/测试/本机测试/获取图像文件/segmentation.cpp @@ -0,0 +1,63 @@ +/* segmentation.c +ܣܳ򣺶ͼļЧ +*/ +//#include "stdafx.h" +#include +#include +#include +#include +#include +#include +#include //5ڶȡļµļ +#include +#include +#include +#include +#include +using namespace std; +#ifdef WIN32 //VC6STLһЩȫ֧ +#pragma warning (disable: 4514 4786) +#endif + +/*----------------------------------*/ + +void getFiles(string path, vector& files );//9ȡļļ +int getFolders(string path, vector& files );//11ȡļļе +int searchDir(char* path, vector &dir);//ȡĿ¼һļ + +int main() +{ + + char path[100] = "E:/xiangmu/Img/imgjiaobiao/"; + + vector dir; //洢Ŀ¼ + int size_dir,num_dir; + + char* fpname= "C:/Users/˧˧/Desktop/result2.txt"; + char record[2400]={0}; + FILE* fpzz=NULL;//Ҫע + + searchDir(path, dir);//ȡfilePathµһĿ¼洢dir + size_dir=dir.size(); //dirĴСѧ + + + //ʼ + //-------------------------------------------------------------// + for(num_dir=0;num_dir files; //洢ļ· + + getFiles(dir[num_dir].c_str(), files ); //ǰļµļ + int size=files.size(); + cout<<"numdir: "< +#include +#include +#include +#include +using namespace std; + +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; +//1 ȡͼϢ + 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; +//----------------------------------------// +//2ҽűλ +//----------------------------------------// + for(i=0;i=200) + sumjb2=sumjb2+imgjbsbdata[ii*step+jj*channels]; + } + if(sumjb2>=255*(100-jbblack)){ //DZںڵڶȡ + jbi=i;//űλ + jbj=j; + for(ii=i-2;iidepth,img->nChannels); + uchar *imgjbcjdata= (uchar *)imgjbcj->imageData; + int jbcjstep = imgjbcj->widthStep; + int jbcjchannels = imgjbcj->nChannels; + for(i=0;i<476;i++){ + for(j=0;j<833;j++){ + imgjbcjdata[i*jbcjstep+j*jbcjchannels]=data[(i+jbi)*step+(j+jbj)*channels]; + } + } + //˴yssעͣûʲôô + for(i=0;i<476;i=i+2){ + imgjbsbdata[(i+jbi)*step+jbj*channels]=0; + imgjbsbdata[(i+jbi)*step+(jbj+833)*channels]=0; + } + for(j=0;j<833;j=j+2){ + imgjbsbdata[jbi*step+(j+jbj)*channels]=0; + imgjbsbdata[(jbi+476)*step+(j+jbj)*channels]=0; + } + + return imgjbcj; + +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/Integral.cpp b/测试/本机测试/转换图像文件到jpg/Integral.cpp new file mode 100644 index 0000000..2183208 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/Integral.cpp @@ -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;i0) + { + outputMatrix[i] += outputMatrix[i-1]; + } + } + for (int i=1;i +#include +#include "Thinner.h" +#include + +//ͼͼɫ +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; i0) + 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; + 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; kk0){ + 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 +#include +#include +#include +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;ibithro)?255:0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel=0; + + memset(black,0,1000); //##ʼڴ棬black + for(i=height-1;i>0;i--) + { + for(int j=0;j +#include +#include +#include +using namespace std; +#include + +void getFiles(string path, vector& 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); + } +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/getFloders.cpp b/测试/本机测试/转换图像文件到jpg/getFloders.cpp new file mode 100644 index 0000000..e6f9107 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/getFloders.cpp @@ -0,0 +1,38 @@ +/* getFolders.c +ܣһļµļе +*/ +#include +#include +#include +#include +using namespace std; +#include + +int getFolders(string path, vector& 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; + +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/getFolders.cpp b/测试/本机测试/转换图像文件到jpg/getFolders.cpp new file mode 100644 index 0000000..dd18c57 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/getFolders.cpp @@ -0,0 +1,65 @@ +/* getFolders.c +ܣһļµļе +*/ +#include +#include +#include +#include +using namespace std; +#include + +int getFolders(string path, vector& files ) +{ + using namespace std;//ռ + //ļ + long hFile = 0; + //ļϢ + struct _finddata_t fileinfo; + string p; + + /* + hFile=_findfirst(p.assign(path).append("\\*").c_str(),&fileinfo); //һβ to_search??? + files.push_back(p.assign(path).append("\\").append(fileinfo.name) ); + if(-1==hFile)return -1; //ǰļûļ + + printf("%s\n",fileinfo.name); //ӡҵļļ + int i=0; + while(!_findnext(hFile,&fileinfo)) //ѭϵļ֪ҲΪֹ + { + printf("%s\n",files[i].c_str()); + i++; + } + _findclose(hFile); //˹رվ + system("pause"); + return 0; + */ + + + + int i=0; + if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1) + { + do + { + //Ŀ¼,֮ + //,б + //if((fileinfo.attrib & _A_SUBDIR)) + //{ + // if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0) + // getFiles( p.assign(path).append("\\").append(fileinfo.name), files ); + //} + //else + //{ + if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0) + { + files.push_back(p.assign(path).append("\\").append(fileinfo.name) ); + printf("ļУ%s\n",files[i].c_str()); + i++; + } + //} + }while(_findnext(hFile, &fileinfo) == 0); + _findclose(hFile); + } + return 0; + +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/getType.cpp b/测试/本机测试/转换图像文件到jpg/getType.cpp new file mode 100644 index 0000000..c7a42d0 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/getType.cpp @@ -0,0 +1,27 @@ +/*getType.c +ܣͼļõͼ +*/ +#include +#include +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; +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/gif2ipl.cpp b/测试/本机测试/转换图像文件到jpg/gif2ipl.cpp new file mode 100644 index 0000000..0bed703 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/gif2ipl.cpp @@ -0,0 +1,58 @@ +/* gif2ipl.c +ܣgifͼ񡣵õӦrgbͼ +*/ +#include +#include +#include "FreeImage.h" +#include +IplImage* gif2ipl(const char* filename) +{ + FreeImage_Initialise(); //load the FreeImage function lib + FREE_IMAGE_FORMAT fif = FIF_GIF; + FIBITMAP* fiBmp = FreeImage_Load(fif,filename,GIF_DEFAULT); + FIMULTIBITMAP * pGIF=FreeImage_OpenMultiBitmap(fif,filename,0,1,0,GIF_PLAYBACK); + // FIBITMAPINFO fiBmpInfo = getfiBmpInfo(fiBmp); + int gifImgCnt=FreeImage_GetPageCount(pGIF); + FIBITMAP * pFrame; + int width,height; + width=FreeImage_GetWidth(fiBmp); + height=FreeImage_GetHeight(fiBmp); + IplImage * iplImg = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3); + iplImg->origin = 1;//should set to 1-top-left structure(Windows bitmap style) + RGBQUAD* ptrPalette =new RGBQUAD; // = FreeImage_GetPalette(fiBmp); + BYTE intens; + BYTE* pIntensity = &intens; + //cvNamedWindow("gif",0); + //printf("gifͼƬĿ%d \n",gifImgCnt); + for (int curFrame=0;curFrameimageData + i*iplImg->widthStep; + for(int j=0;jrgbBlue; + ptrImgDataPerLine[3*j+1] = ptrPalette->rgbGreen; + ptrImgDataPerLine[3*j+2] = ptrPalette->rgbRed; + //ptrImgDataPerLine[3*j] = ptrPalette[intens].rgbBlue; + //ptrImgDataPerLine[3*j+1] = ptrPalette[intens].rgbGreen; + //ptrImgDataPerLine[3*j+2] = ptrPalette[intens].rgbRed; + } + } + + //printf("תͼƬţ %d \n",curFrame); + // cvShowImage("gif",iplImg); + // cvWaitKey(30); + // FreeImage_UnlockPage(pGIF,pFrame,1); + } + FreeImage_Unload(fiBmp); + FreeImage_DeInitialise(); + + return iplImg; +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/handwriting.dsp b/测试/本机测试/转换图像文件到jpg/handwriting.dsp new file mode 100644 index 0000000..e850ae4 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/handwriting.dsp @@ -0,0 +1,146 @@ +# Microsoft Developer Studio Project File - Name="handwriting" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=handwriting - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "handwriting.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "handwriting.mak" CFG="handwriting - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "handwriting - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "handwriting - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "handwriting - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x804 /d "NDEBUG" +# ADD RSC /l 0x804 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "handwriting - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x804 /d "_DEBUG" +# ADD RSC /l 0x804 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "handwriting - Win32 Release" +# Name "handwriting - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\binary.cpp +# End Source File +# Begin Source File + +SOURCE=.\Cjbsb.cpp +# End Source File +# Begin Source File + +SOURCE=.\getFiles.cpp +# End Source File +# Begin Source File + +SOURCE=.\getFloders.cpp +# End Source File +# Begin Source File + +SOURCE=.\getType.cpp +# End Source File +# Begin Source File + +SOURCE=.\gif2ipl.cpp +# End Source File +# Begin Source File + +SOURCE=.\read_scanf.cpp +# End Source File +# Begin Source File + +SOURCE=.\searchDir.cpp +# End Source File +# Begin Source File + +SOURCE=.\segmentation.cpp +# End Source File +# Begin Source File + +SOURCE=.\singlefeature.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Cword.h +# End Source File +# Begin Source File + +SOURCE=.\Point.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 diff --git a/测试/本机测试/转换图像文件到jpg/handwriting.dsw b/测试/本机测试/转换图像文件到jpg/handwriting.dsw new file mode 100644 index 0000000..4aad161 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/handwriting.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# : ܱ༭ɾùļ + +############################################################################### + +Project: "handwriting"=.\handwriting.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/测试/本机测试/转换图像文件到jpg/handwriting.opt b/测试/本机测试/转换图像文件到jpg/handwriting.opt new file mode 100644 index 0000000..e305e67 Binary files /dev/null and b/测试/本机测试/转换图像文件到jpg/handwriting.opt differ diff --git a/测试/本机测试/转换图像文件到jpg/handwriting.plg b/测试/本机测试/转换图像文件到jpg/handwriting.plg new file mode 100644 index 0000000..c271264 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/handwriting.plg @@ -0,0 +1,49 @@ + + +
+

Build Log

+

+--------------------Configuration: handwriting - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP9F62.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/handwriting.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"D:\CODE\HWCV\\תͼļjpg\segmentation.cpp" +] +Creating command line "cl.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP9F62.tmp"" +Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSP9F63.tmp" with contents +[ +FreeImage.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/handwriting.pdb" /debug /machine:I386 /out:"Debug/handwriting.exe" /pdbtype:sept +".\Debug\binary.obj" +".\Debug\Cjbsb.obj" +".\Debug\getFiles.obj" +".\Debug\getFloders.obj" +".\Debug\getType.obj" +".\Debug\gif2ipl.obj" +".\Debug\read_scanf.obj" +".\Debug\searchDir.obj" +".\Debug\segmentation.obj" +".\Debug\singlefeature.obj" +] +Creating command line "link.exe @"C:\Users\˧˧\AppData\Local\Temp\RSP9F63.tmp"" +

Output Window

+Compiling... +segmentation.cpp +d:\code\hwcv\\תͼļjpg\segmentation.cpp(43) : warning C4101: 'end' : unreferenced local variable +d:\code\hwcv\\תͼļjpg\segmentation.cpp(44) : warning C4101: 'cost' : unreferenced local variable +d:\code\hwcv\\תͼļjpg\segmentation.cpp(60) : warning C4101: 'ii' : unreferenced local variable +d:\code\hwcv\\תͼļjpg\segmentation.cpp(60) : warning C4101: 'jj' : unreferenced local variable +d:\code\hwcv\\תͼļjpg\segmentation.cpp(60) : warning C4101: 'j' : unreferenced local variable +d:\code\hwcv\\תͼļjpg\segmentation.cpp(83) : warning C4101: 'x' : unreferenced local variable +c:\program files\vc\vc98\include\vector(39) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +c:\program files\vc\vc98\include\vector(60) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > > >::~vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information +Linking... + + + +

Results

+handwriting.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/测试/本机测试/转换图像文件到jpg/outline.cpp b/测试/本机测试/转换图像文件到jpg/outline.cpp new file mode 100644 index 0000000..bbce186 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/outline.cpp @@ -0,0 +1,46 @@ +/* outline.c +ܣͼ񡣵õӦͼ +*/ +#include +#include +#include +#include + +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; + + + for(j=0;jimageData[j*step+i*channels]=255; + for( i=0;iimageData[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;iimageData[(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; +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/outlinefeature.cpp b/测试/本机测试/转换图像文件到jpg/outlinefeature.cpp new file mode 100644 index 0000000..212415b --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/outlinefeature.cpp @@ -0,0 +1,262 @@ +/* outline.c +ܣͼ񡣷Ӧֵ +*/ +#include +#include +#include +#include +#include "Point.h" + +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 ı + +/* ȡͼϢ*/ + 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*********************** + + } + + } +} + + //****עֵΪfeat(x,y)+feat(y,x)feat(x,y)Уx +#include +#include +#include +using namespace std; + +int read_scanf(const string &filename,const int &cols,vector &_vector) +{ + FILE *fp=fopen(filename.c_str(),"r"); + bool flag=true; + int i=0; + if(!fp) { cout<<"File open error!\n"; return 0; } + while(flag) + { + double *ptr=new double[cols]; + for(i=0;i +#include +#include +#include +#include +#include +using namespace std; + +int searchDir( char *path, vector &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; + +} \ No newline at end of file diff --git a/测试/本机测试/转换图像文件到jpg/segmentation.cpp b/测试/本机测试/转换图像文件到jpg/segmentation.cpp new file mode 100644 index 0000000..0e18d28 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/segmentation.cpp @@ -0,0 +1,94 @@ +/* segmentation.c +ܣܳ򣺶ͼļЧ +*/ +//#include "stdafx.h" +#include +#include +#include +#include +#include +#include +#include "Point.h" +#include "FreeImage.h" //ڶgifͼ,gifͼתΪpng +#include //5ڶȡļµļ +#include +#include +#include +#include //ڵʾ,,,мǣʱҪMFCAfx.h) +#include +using namespace std; +#ifdef WIN32 //VC6STLһЩȫ֧ +#pragma warning (disable: 4514 4786) +#endif + +/*----------------------------------*/ + +void getFiles(string path, vector& files );//9ȡļļ +char* getType(char fileName[], char type[]); //2ȡͼ +int* binary(IplImage* img,int bithro); //3ֵͼ +int getFolders(string path, vector& files );//11ȡļļе +int read_scanf(const string &filename,const int &cols,vector &_vector);//12ȡѾõֵ +int searchDir(char* path, vector &dir);//ȡĿ¼һļ +IplImage* Cjbsb(IplImage* img,IplImage* imgjbsb,int jbwhite,int jbblack);//4ͼDZʶ +IplImage* gif2ipl(const char* filename); //1ȡgifⲿ +IplImage* singlefeature(char* path,int feature[ ][50],int flag);//10óļֵ + +int pos_x=0,pos_y=0; +bool pos_flag=false; +IplImage* src; +int picAll=0,picSus=0; + +int main() +{ + time_t start ,end ;//ʱ + double cost; time(&start); + + // + //------------------------------------------------------// + char path[100] = "D:\\xiangmu\\Img\\imgjiaobiao3\\"; + vector dir; //洢Ŀ¼ + int conti=1; //Աͼı + int size_dir,num_dir; + + searchDir(path, dir);//ȡfilePathµһĿ¼洢dir + size_dir=dir.size(); //dirĴСѧ + + //ʼת + //-------------------------------------------------------------// + for(num_dir=0;num_dir files; //洢ļ· + + getFiles(dir[num_dir].c_str(), files ); //ǰļµļ + // + printf("\n%dĿ¼%s",num_dir,dir[num_dir].c_str()); + + size = files.size(); //ͼĿ + // + printf("\t%d\t",size); + + //ʼÿһͼƬд + //------------------------------------------------------// + int flag=1; + for (i = 0;i < size;i++) + { + memset(str,0,sizeof(str)); + strcpy(str,files[i].c_str()); + try + { + singlefeature(str,featx,flag);//strͼƬ· featxͼƬֵڱfeatx + }catch(int x) + { + + } + flag=0; + } + + + } + return 0; +} + diff --git a/测试/本机测试/转换图像文件到jpg/singlefeature.cpp b/测试/本机测试/转换图像文件到jpg/singlefeature.cpp new file mode 100644 index 0000000..5ea91d8 --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/singlefeature.cpp @@ -0,0 +1,135 @@ +/* singlefeature.c +ܣܳ򣺶ͼļóļֵ +*/ +#include +#include +#include +#include +#include +#include "Point.h" +#include "FreeImage.h" //ڶgifͼ +#include //5ڶȡļµļ +#include +#include +using namespace std; +#include +#include +#include"Thinner.h" + +/**/ + +void getFiles(string path, vector& files );//ȡļļ +char* getType(char fileName[], char type[]); //ȡͼ +int* binary(IplImage* img,int bithro); //ֵͼ +int outlinefeature(IplImage* imglk,int feature[ ][50]);//ͼֵ +IplImage* Cjbsb(IplImage* img,IplImage* imgjbsb,int jbwhite,int jbblack);//ͼDZʶ +IplImage* gif2ipl(const char* filename); //ȡgifⲿ + +IplImage* singlefeature(char* path,int feature[ ][50],int flag){ + // + IplImage* img = 0; //ԭͼ + IplImage* imglk = 0; //ͼ + IplImage* imggj = 0; //Ǽͼ + IplImage* imgjbsb = 0; //DZʶͼ + IplImage* imgbj = 0; //ֻȡʼDzֵͼ + + char imgtype[10]; //жͼ + int height,width,step,channels; + uchar *data; + + int *black; //ڷͼÿкصĸ + //int feature[50][50]={0}; //ֵʼ + + getType(path, imgtype); + if(strcmp(".gif", imgtype) == 0) + { + IplImage* Iplimg=gif2ipl(path); //gif ת rgb ά + img=cvCreateImage(cvGetSize(Iplimg),Iplimg->depth,1); + + cvCvtColor(Iplimg,img,CV_RGB2GRAY); //rgb תҶ + cvReleaseImage(&Iplimg); //ͷʱͼڴ + cvFlip(img,NULL, 0); //ڵõĻҶͼǷתģٷת + } + else if(strcmp(".jpg", imgtype) == 0 || strcmp(".png", imgtype) == 0) + img=cvLoadImage(path,0); + else + return NULL; + + if(!img) + { + printf("Could not load image file: %s\n",path); + exit(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<850){ + scale=(float)850/width; + dst_cvsize.width=850; + 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 - ֵ. + + //ֵ + int bithro=230; //ֵֵ (0--255) + black=binary(imgbig,bithro); //ֵͳƺصĸÿкصĸ(black) + //cvNamedWindow("ֵͼ",CV_WINDOW_AUTOSIZE); //ʾͼ + //cvShowImage("ֵͼ",img); + //printf("ֵɣ\n"); + + //DZʶ,гͼ + int jbwhite=5,jbblack=4; + imgjbsb = cvCreateImage(cvGetSize(imgbig),imgbig->depth,imgbig->nChannels); + imgbj=Cjbsb(imgbig,imgjbsb,jbwhite,jbblack); //ֵıʼ + + //洢üͼ + //D:/xiangmu/Img/imgjiaobiao/010211100059x/0359.gif + char isavePath[200]="E"; + + //˴Ҫ½һ½ļеѡ + string name=path; + strcat(isavePath, name.substr(1, 39).c_str()); + + string md="mkdir "; + md += isavePath; + //ϳ + strcat(isavePath, name.substr(40, 5).c_str()); + strcat(isavePath, ".jpg"); + //ļ + if(flag) system(md.c_str()); + //ͼ + cvSaveImage(isavePath,imgbj); + + + + cvReleaseImage(&imgbig); + cvReleaseImage(&img ); + cvReleaseImage(&imgbj ); + cvDestroyAllWindows(); + cout<<"."; + return imggj; +} + + diff --git a/测试/本机测试/转换图像文件到jpg/worddivide.cpp b/测试/本机测试/转换图像文件到jpg/worddivide.cpp new file mode 100644 index 0000000..feb556f --- /dev/null +++ b/测试/本机测试/转换图像文件到jpg/worddivide.cpp @@ -0,0 +1,136 @@ +/* Cjbsb.c +ܣֻͼļֻֿ +ֻͼļֵֵбб +Ĭϣhthro=10wthro=6 +*/ +#include +#include +#include +#include + +IplImage* worddivide(IplImage* imgbj,int hthro,int wthro,int *gridx,int *gridy,int *gxx,int *gyy){ + /**/ + int height,width,step,channels; + uchar *data; + + int i,j,black[1000]; + int blackend=0; //Ƿָ߽ + int mi=0,mx=500; //Ƿָںɫٵߺֵ + int gx=0,gy=0; //¼ûߵߵкк gridx[10],gridy[30], + memset(gridx,0,10); //ʼڴ棬 + memset(gridy,0,30); //ʼڴ棬 + + /*µͼ*/ + IplImage* imgbjhf = cvCreateImage(cvGetSize(imgbj),imgbj->depth,imgbj->nChannels); //ʼͼ + cvCopy(imgbj,imgbjhf,NULL); + + /* ȡͼϢ*/ + height = imgbjhf->height; + width = imgbjhf->width; + step = imgbjhf->widthStep; + channels = imgbjhf->nChannels; + data = (uchar *)imgbjhf->imageData; + + + /*ı*/ + /*ÿһеĺɫص˲ʹöֵõģ*/ + int tempBlackPixelx=0; //ѭ¼ÿһеĺɫص + + memset(black,0,1000); //ʼڴ棬 + for(j=0;jhthro) || i==height-1){ + blackend=0; + + gridx[gx]=mi; + //printf("<б꣺%d>",gridx[gx]); + gx++; + mx=500; + mi=i; + } + } + + /*ı*/ + + //ÿһеĺظ + int tempBlackPixely=0; + memset(black,0,1000); //ʼڴ棬 + for(i=0;iwthro)){ + blackend=0; + + if(gy==0){ + gridy[gy]=mi; //ºɫٵĵλ + gy++; + } + else if(mi-gridy[gy-1]<=25){ //Ƿ̫Сһ + gridy[gy-1]=mi; // + } + else{ + gridy[gy]=mi; //ºɫٵĵλ + //printf("<б꣺%d>",gridy[gy]); + gy++; + } + mx=500; + mi=i; + } + } + + gridy[gy]=mi; //һнд + gy++; + //for(j=0;j +#include +#include +#include +#include "Point.h" +#include "Cword.h" + +IplImage* wordrecognize(IplImage* imgbj,int *gridx,int *gridy,Cword *wordbox,int gx,int gy){ + /**/ + int i,j,ni,numw,nblack=0,wnum=0; + //Cword wordbox[150]; + int sumnum=(gx-1)*(gy-1); + + int height,width,step,channels; + uchar *data; + + /*µͼ*/ + IplImage* imgwzbj = cvCreateImage(cvGetSize(imgbj),imgbj->depth,imgbj->nChannels); + cvCopy(imgbj,imgwzbj,NULL); + uchar *wzbjdata = (uchar *)imgwzbj->imageData; + + /* ȡͼϢ*/ + height = imgbj->height; + width = imgbj->width; + step = imgbj->widthStep; + channels = imgbj->nChannels; + data = (uchar *)imgbj->imageData; + + /*ʼ*/ + for(i=0;i80){ + wordbox[ni].isword=true; + wnum++; + wordbox[ni].nn=wnum; + + //printf("x= %d;;;y=%d \n",wordbox[ni].wbegin.x,wordbox[ni].wbegin.y); + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+2)*channels]=0; //һͼϣ֣һ+ + wzbjdata[(wordbox[ni].wbegin.x+1)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+3)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+1)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+3)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+4)*step+(wordbox[ni].wbegin.y+2)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+4)*channels]=0; + } + else{ + wordbox[ni].isword=false; + + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+2)*channels]=0; //һͼϣ֣һ- + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+1)*channels]=0; + wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+3)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y)*channels]=0; + //wzbjdata[(wordbox[ni].wbegin.x+2)*step+(wordbox[ni].wbegin.y+4)*channels]=0; + } + wordbox[ni].blacknum=nblack; + nblack=0; + } + return imgwzbj; +} \ No newline at end of file diff --git a/资料/D盘配置文件-已加密.rar b/资料/D盘配置文件-已加密.rar new file mode 100644 index 0000000..c56ca37 Binary files /dev/null and b/资料/D盘配置文件-已加密.rar differ diff --git a/资料/数据库-已加密.rar b/资料/数据库-已加密.rar new file mode 100644 index 0000000..b6a50f9 Binary files /dev/null and b/资料/数据库-已加密.rar differ diff --git a/资料/测试图像.rar b/资料/测试图像.rar new file mode 100644 index 0000000..7133adf Binary files /dev/null and b/资料/测试图像.rar differ diff --git a/部署版本/------HWCV-exe/HWCV-exe.sln b/部署版本/------HWCV-exe/HWCV-exe.sln new file mode 100644 index 0000000..b4b0448 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe.sln @@ -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 diff --git a/部署版本/------HWCV-exe/HWCV-exe/DBop.cpp b/部署版本/------HWCV-exe/HWCV-exe/DBop.cpp new file mode 100644 index 0000000..f428a63 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/DBop.cpp @@ -0,0 +1,209 @@ +/* +ʵļDBop.cpp ݿʵļ +*/ +#include "DBop.h" +#include "path.h" + +/*صȫֱ*/ + +_ConnectionPtr p_conn; /*ȫֱ Ӷ*/ +_RecordsetPtr p_recordset; /*ȫֱ ¼*/ +_CommandPtr p_cmd; /*ȫֱ */ +string str_conn; /*ȫֱ ַ*/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& 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<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:"<RecordCount <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"< dateVec, vector subjectVec, vector stuNum2, vector 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 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; +} \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/DBop.h b/部署版本/------HWCV-exe/HWCV-exe/DBop.h new file mode 100644 index 0000000..635f605 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/DBop.h @@ -0,0 +1,55 @@ +/* +ͷļDBop.h ݿͷļ +*/ +#pragma once +#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile") +#include +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& stuNum2); + + +/** +ܣ ѧݿϢ,ѧļݿ + +@ stuNumѧ +@ subjectԿĿ +@ flagCheatױ +@ֵ ɹ1ʧ0 +*/ +int DbUpdate(string stuNum, vector dateVec, vector subjectVec, vector stuNum2, vector flagVec); \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj b/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj new file mode 100644 index 0000000..01a18aa --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {FB6A1EE7-710E-424B-A80E-A931EDB7DDBF} + Win32Proj + HWCVexe + HWCV + + + + Application + true + v120 + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + E:\program files\opencv\build\x86\vc12\staticlib;$(LibraryPath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + 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) + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj.filters b/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj.filters new file mode 100644 index 0000000..291bae6 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/HWCV-exe.vcxproj.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/Point.h b/部署版本/------HWCV-exe/HWCV-exe/Point.h new file mode 100644 index 0000000..dd5b512 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/Point.h @@ -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;} +}; \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/StdAfx.cpp b/部署版本/------HWCV-exe/HWCV-exe/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/StdAfx.cpp @@ -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 diff --git a/部署版本/------HWCV-exe/HWCV-exe/StdAfx.h b/部署版本/------HWCV-exe/HWCV-exe/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/StdAfx.h @@ -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 + +// 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_) diff --git a/部署版本/------HWCV-exe/HWCV-exe/path.cpp b/部署版本/------HWCV-exe/HWCV-exe/path.cpp new file mode 100644 index 0000000..09f80d9 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/path.cpp @@ -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 &_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> 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; +} \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/path.h b/部署版本/------HWCV-exe/HWCV-exe/path.h new file mode 100644 index 0000000..8ec507e --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/path.h @@ -0,0 +1,97 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include +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 &_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); \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/process.cpp b/部署版本/------HWCV-exe/HWCV-exe/process.cpp new file mode 100644 index 0000000..7ab14b2 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/process.cpp @@ -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; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; i++) + { + if (gjdata[j*imggj->widthStep + i] == 255) + gjdata[j*imggj->widthStep + i] = 1; + } + } + + /*ϸ*/ + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + /*ʼͼɫΧתˮƽ*/ + for (j = 0; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/部署版本/------HWCV-exe/HWCV-exe/segmentation.cpp b/部署版本/------HWCV-exe/HWCV-exe/segmentation.cpp new file mode 100644 index 0000000..9476a0c --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/segmentation.cpp @@ -0,0 +1,241 @@ +/* +ļsegmentation.cpp ʵļ +*/ +#include "segmentation.h" +#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//޽ +/**/ +int main(int argc,char* argv[]) +{ + if(argc<2) return -1; + //for(int iii=0;iii suspict; //¼ͼƬַ + vector suspict_wcd; //ͼƬwcdֵ + vector files; //洢пļ· + vector dateVec, subjectVec, stuNum2; + vector flagVec;//¼鵽ѧпϢ + + /*ȡļø*/ + if (!ReadConfig("D:/HWCV/config/configure.cfg")) + { + SaveLog("\tļȡʧ\n", g_log_adr, "a"); + + return 0; + } + +// cout<<"ReadConfig success"< 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"); + return 0; + } + 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 < realSize; 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 < dateVec.size(); i++) + { + if (wcd[i] > 0.12) + { + xyimgnum++; + suspict.push_back(files[i].c_str()); + suspict_wcd.push_back(wcd[i]); + flagVec.push_back("1");//ɱ1 + } + else + { + flagVec.push_back("0"); + } + } + + //ݿ + DbUpdate(stuNum, dateVec, subjectVec, stuNum2, flagVec); +// cout << "ݿ" << endl; + + /*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, fpname1); + strcat(g_log_rec, " ͼƬΪ"); + char pic_num[20]; + _itoa(realSize, pic_num, 10); + strcat(g_log_rec, pic_num); + if (xyimgnum > 0) + { + + /* strcat(g_log_rec, "\t"); + strcat(g_log_rec, suspict[0].c_str()); + strcat(g_log_rec, "\t"); + char a[20]; + sprintf(a, "%g", suspict_wcd[0]); + strcat(g_log_rec, a); + */ strcat(g_log_rec, "\n"); + for (i = 0; i < xyimgnum; i++) + { + 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"); + SaveLog(g_log_rec, g_log_adr, "a"); + + + /*ƺ*/ + suspict.clear(); + suspict_wcd.clear(); + output_bzc.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(); + dateVec.clear(); + subjectVec.clear(); + stuNum2.clear(); + flagVec.clear(); + + /*ֵ*/ + return 0; +} + + diff --git a/部署版本/------HWCV-exe/HWCV-exe/segmentation.h b/部署版本/------HWCV-exe/HWCV-exe/segmentation.h new file mode 100644 index 0000000..61c8ae5 --- /dev/null +++ b/部署版本/------HWCV-exe/HWCV-exe/segmentation.h @@ -0,0 +1,61 @@ +/* +ͷļsegmentation.h ͷļ +*/ +#pragma once +#ifdef WIN32 //VC6STLһЩȫ֧ +#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_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[32]={0}; +char msg[100]={0}; \ No newline at end of file diff --git a/部署版本/------HWCVServe/Check.cpp b/部署版本/------HWCVServe/Check.cpp new file mode 100644 index 0000000..81f482d --- /dev/null +++ b/部署版本/------HWCVServe/Check.cpp @@ -0,0 +1,64 @@ +#include "Check.h" + +char* GetTime(); + +/*ܣ鵱ǰľļУȡļɾļ +@ path ļλ +@ֵ ؼ⵽ı +*/ +int CheckFile(char* path, vector& 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()); + } + } 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; +} \ No newline at end of file diff --git a/部署版本/------HWCVServe/Check.h b/部署版本/------HWCVServe/Check.h new file mode 100644 index 0000000..b1131e4 --- /dev/null +++ b/部署版本/------HWCVServe/Check.h @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +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& files); + + diff --git a/部署版本/------HWCVServe/HWCV-exe.exe b/部署版本/------HWCVServe/HWCV-exe.exe new file mode 100644 index 0000000..fe6ed75 Binary files /dev/null and b/部署版本/------HWCVServe/HWCV-exe.exe differ diff --git a/部署版本/------HWCVServe/HWCVServe.dsp b/部署版本/------HWCVServe/HWCVServe.dsp new file mode 100644 index 0000000..765385c --- /dev/null +++ b/部署版本/------HWCVServe/HWCVServe.dsp @@ -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 diff --git a/部署版本/------HWCVServe/HWCVServe.dsw b/部署版本/------HWCVServe/HWCVServe.dsw new file mode 100644 index 0000000..d8ca624 --- /dev/null +++ b/部署版本/------HWCVServe/HWCVServe.dsw @@ -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> +{{{ +}}} + +############################################################################### + diff --git a/部署版本/------HWCVServe/HWCVServe.opt b/部署版本/------HWCVServe/HWCVServe.opt new file mode 100644 index 0000000..c800c25 Binary files /dev/null and b/部署版本/------HWCVServe/HWCVServe.opt differ diff --git a/部署版本/------HWCVServe/HWCVServe.plg b/部署版本/------HWCVServe/HWCVServe.plg new file mode 100644 index 0000000..a21eda5 --- /dev/null +++ b/部署版本/------HWCVServe/HWCVServe.plg @@ -0,0 +1,25 @@ + + +
+

Build Log

+

+--------------------Configuration: HWCVServe - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\˧˧\AppData\Local\Temp\RSPC9C7.tmp" with contents +[ +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 /incremental:yes /pdb:"Debug/HWCVServe.pdb" /debug /machine:I386 /out:"Debug/HWCVServe.exe" /pdbtype:sept +".\Debug\Check.obj" +".\Debug\Main.obj" +] +Creating command line "link.exe @"C:\Users\˧˧\AppData\Local\Temp\RSPC9C7.tmp"" +

Output Window

+Linking... + + + +

Results

+HWCVServe.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/部署版本/------HWCVServe/Main.cpp b/部署版本/------HWCVServe/Main.cpp new file mode 100644 index 0000000..f8749db --- /dev/null +++ b/部署版本/------HWCVServe/Main.cpp @@ -0,0 +1,47 @@ +#include "Main.h" +#include "Check.h" + + +using namespace std; +int main(int argc, char** argv) +{ + //..\Check\·ûļ + char * path = "./Check/"; + vector 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); + + try{ + ShellExecute(NULL,"open", + "HWCV-exe.exe", + (char*)files[iter].c_str(), + NULL, + SW_SHOWNORMAL); + }catch(exception e) + { + + } + } + files.clear(); + + Sleep(SLEEP_TIME); + } + + WriteToLog(GetTime()); + WriteToLog("----\n"); + + return 1; +} diff --git a/部署版本/------HWCVServe/Main.h b/部署版本/------HWCVServe/Main.h new file mode 100644 index 0000000..6187b74 --- /dev/null +++ b/部署版本/------HWCVServe/Main.h @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include +#include +#include +#pragma comment(lib, "Advapi32") + +//#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//ûн + +using namespace std; +/*ȫֱ*/ +#define SLEEP_TIME 1000 //5000ˢһ + + +/*ʱȡu*/ +time_t ltime; +char *srcTime=NULL; +char timeNow[22]={0}; +char msg[100]={0}; \ No newline at end of file diff --git a/部署版本/------HWCVServe/读我.txt b/部署版本/------HWCVServe/读我.txt new file mode 100644 index 0000000..3c2b8b6 --- /dev/null +++ b/部署版本/------HWCVServe/读我.txt @@ -0,0 +1 @@ +˳ʱ̼ CheckļµļʱļݸHWCV-exe.exeִм \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe.sln b/部署版本/主程序/HWCV-exe.sln new file mode 100644 index 0000000..b4b0448 --- /dev/null +++ b/部署版本/主程序/HWCV-exe.sln @@ -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 diff --git a/部署版本/主程序/HWCV-exe/DBop.cpp b/部署版本/主程序/HWCV-exe/DBop.cpp new file mode 100644 index 0000000..a4267f0 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/DBop.cpp @@ -0,0 +1,190 @@ +/* +ʵļDBop.cpp ݿʵļ +*/ +#include "DBop.h" +#include "path.h" + +/*صȫֱ*/ + +_ConnectionPtr p_conn; /*ȫֱ Ӷ*/ +_RecordsetPtr p_recordset; /*ȫֱ ¼*/ +_CommandPtr p_cmd; /*ȫֱ */ +string str_conn; /*ȫֱ ַ*/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& 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<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:"<RecordCount <RecordCount < 1)//Ϊ + { + return 0;//ûϢֱ + } + do{ //vector + string comp = (string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ"))->GetValue()); + if (!strcmp(comp.substr(0, 1).c_str(), "4") || !strcmp(comp.substr(0, 1).c_str(), "9")) //49 ͷĿţͼֱӴ + 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_ZKZ"))->GetValue())); + p_recordset->MoveNext(); + } while (!p_recordset->EndOfFile); + } + catch (_com_error e) + { + return 0; +// printf("%x", e.Error()); +// cout<<"Failed"< dateVec, vector subjectVec, vector stuNum2, vector 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 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; +} \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/DBop.h b/部署版本/主程序/HWCV-exe/DBop.h new file mode 100644 index 0000000..635f605 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/DBop.h @@ -0,0 +1,55 @@ +/* +ͷļDBop.h ݿͷļ +*/ +#pragma once +#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","EndOfFile") +#include +#include +#include +#include +#include +#include + +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*/ +/*****************************************ԭ*************************************/ + + +/** +ܣ stringstu洢ѧšд˵ĿϢ,ֱ洢ڲͬı + +@ stuNum ѧ +@ date ʱ +@ subject ԿĿ +@ stuNum +@ֵ ɹ1 ʧ0 +*/ +int DbImg(string stuNum, vector& dateVec, vector& subjectVec, vector& stuNum2); + + +/** +ܣ ѧݿϢ,ѧļݿ + +@ stuNumѧ +@ subjectԿĿ +@ flagCheatױ +@ֵ ɹ1ʧ0 +*/ +int DbUpdate(string stuNum, vector dateVec, vector subjectVec, vector stuNum2, vector flagVec); \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj b/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj new file mode 100644 index 0000000..7c3ea37 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj @@ -0,0 +1,104 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {FB6A1EE7-710E-424B-A80E-A931EDB7DDBF} + Win32Proj + HWCVexe + + + + Application + true + v120 + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + E:\program files\opencv\build\x86\vc12\staticlib;$(LibraryPath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + 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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + 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) + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj.filters b/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj.filters new file mode 100644 index 0000000..291bae6 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/HWCV-exe.vcxproj.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/HWCV-exe更改前bck.rar b/部署版本/主程序/HWCV-exe/HWCV-exe更改前bck.rar new file mode 100644 index 0000000..79e530b Binary files /dev/null and b/部署版本/主程序/HWCV-exe/HWCV-exe更改前bck.rar differ diff --git a/部署版本/主程序/HWCV-exe/Point.h b/部署版本/主程序/HWCV-exe/Point.h new file mode 100644 index 0000000..dd5b512 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/Point.h @@ -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;} +}; \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/StdAfx.cpp b/部署版本/主程序/HWCV-exe/StdAfx.cpp new file mode 100644 index 0000000..7243d9c --- /dev/null +++ b/部署版本/主程序/HWCV-exe/StdAfx.cpp @@ -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 diff --git a/部署版本/主程序/HWCV-exe/StdAfx.h b/部署版本/主程序/HWCV-exe/StdAfx.h new file mode 100644 index 0000000..aacb72c --- /dev/null +++ b/部署版本/主程序/HWCV-exe/StdAfx.h @@ -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 + +// 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_) diff --git a/部署版本/主程序/HWCV-exe/path.cpp b/部署版本/主程序/HWCV-exe/path.cpp new file mode 100644 index 0000000..71c1212 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/path.cpp @@ -0,0 +1,266 @@ +/* +ʵļ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 &_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> 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; +} \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/path.h b/部署版本/主程序/HWCV-exe/path.h new file mode 100644 index 0000000..4f5af97 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/path.h @@ -0,0 +1,96 @@ +/* +ͷļpath.h ·زĺͷļԼԭ +*/ +#pragma once +#include +#include +#include +#include +#include +#include +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 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 &_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); \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/process.cpp b/部署版本/主程序/HWCV-exe/process.cpp new file mode 100644 index 0000000..7ab14b2 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/process.cpp @@ -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; ig_bi_threshold) ? 255 : 0; + } + + /*ÿһеĺظ*/ + int tempBlackPixel = 0; + + memset(black, 0, 1000); //##ʼڴ棬black + for (i = height - 1; i>0; i--) + { + for (int j = 0; jheight; + 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; + + //ԽDZΪвü뻭 + CvSize jbcjsize = cvSize(835, 165); //DZüĴСΪ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; jimageData[j*step + i*channels] = 255; + } + for (i = 0; iimageData[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; iimageData[(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)Уxheight; + 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; jheight; j++)//ȡֵΧת0--1 + { + for (i = 0; iwidth; i++) + { + if (gjdata[j*imggj->widthStep + i] == 255) + gjdata[j*imggj->widthStep + i] = 1; + } + } + + /*ϸ*/ + ThinnerRosenfeld(imggj->imageData, imggj->height, imggj->width); + + /*ʼͼɫΧתˮƽ*/ + for (j = 0; jheight; j++)//ȡֵΧת0--255,ת + { + for (i = 0; iwidth; 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; i0) + 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; kk0){ + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/部署版本/主程序/HWCV-exe/segmentation.cpp b/部署版本/主程序/HWCV-exe/segmentation.cpp new file mode 100644 index 0000000..960b7ed --- /dev/null +++ b/部署版本/主程序/HWCV-exe/segmentation.cpp @@ -0,0 +1,213 @@ +/* +ļsegmentation.cpp ʵļ +*/ +#include "segmentation.h" +#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )//ûн + +int ComputeImage(vector 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)); + singlefeature((char*)files[i].c_str(), featx); //featx[][50] + featureall = 0; //ͼֵ͵ijʼ + 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 suspict; //¼ͼƬַ + vector suspict_wcd; //ͼƬwcdֵ + vector files; //洢пļ· + vector dateVec, subjectVec, stuNum2; + vector flagVec;//¼鵽ѧпϢ + + /*ȡļø*/ + ReadConfig("D:/HWCV/config/configure.cfg"); +// cout<<"ReadConfig success"< 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); + + if (dateVec.size() == 0) + { + strcat(g_log_rec, "0\n\n"); + SaveLog(g_log_rec, g_log_adr, "a"); + return 0; + } + + //· + int nn = 0; + vector img_exist_vector; + for (int cp_i = 0; cp_i < subjectVec.size(); cp_i++) + { + //ȥ4 9 ͷѧŵѧ + /*if (!strcmp(subjectVec[cp_i].substr(0, 1).c_str(), "4") || !strcmp(subjectVec[cp_i].substr(0, 1).c_str(), "9")) + { + continue; + } + else + */ + files.push_back(CrPath(dateVec[cp_i], subjectVec[cp_i], stuNum2[cp_i])); + } + cout << "·" << endl; + + int size = files.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++) + { + if (wcd[i]>0.12) + { + flagVec.push_back("1");//ɱ1 + xyimgnum++; + suspict.push_back(files[i].c_str()); + suspict_wcd.push_back(wcd[i]); + } + flagVec.push_back("0");//ɱ1 + } + if (xyimgnum < 3) + { + flagVec.clear(); + break; + } + } + + /*ݿ*/ + DbUpdate(stuNum, dateVec, subjectVec, stuNum2, flagVec); + cout << "ݿ" << endl; + + /*logļ*/ +// memset(g_log_rec, 0, sizeof(g_log_rec)); + /*strcat(g_log_rec, "\tţ"); + strcat(g_log_rec, fpname1); + strcat(g_log_rec, "\tͼƬΪ");*/ + char pic_num[20]; + _itoa(size, pic_num, 10); + strcat(g_log_rec, pic_num); + if (xyimgnum > 0) + { + strcat(g_log_rec, "\n"); + for (i = 0; i < xyimgnum; i++) + { + 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, "\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(); + + /*ֵ*/ + return 0; +} + + diff --git a/部署版本/主程序/HWCV-exe/segmentation.h b/部署版本/主程序/HWCV-exe/segmentation.h new file mode 100644 index 0000000..93eca98 --- /dev/null +++ b/部署版本/主程序/HWCV-exe/segmentation.h @@ -0,0 +1,74 @@ +/* +ͷļsegmentation.h ͷļ +*/ +#pragma once +#ifdef WIN32 //VC6STLһЩȫ֧ +#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 ltime; +char *srcTime=NULL; +char timeNow[32]={0}; +char msg[100]={0}; \ No newline at end of file