-
大小: 7.48MB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-11-08
- 語言: C/C++
- 標(biāo)簽: 訓(xùn)練SVM??
資源簡介
程序一:修改文件名的程序,可以用來批處理文件將文件名修改為數(shù)字命名并寫到文本文件中
程序二:SVM訓(xùn)練程序。

代碼片段和文件信息
#include?“ChangeSamplePath.h“
#include?
#include?
int?ChangeSamplePath::_name_length?=?8;
ChangeSamplePath::ChangeSamplePath()
{
}
ChangeSamplePath::ChangeSamplePath(std::string?path)?:_main_path(path)
{
initial();
}
ChangeSamplePath::~ChangeSamplePath()
{
_neg_out.close();
_pos_out.close();
}
inline?void?ChangeSamplePath::initial()
{
_neg_path?=?_main_path?+?“\\neg“;
_pos_path?=?_main_path?+?“\\pos“;
_neg_txt_path?=?_main_path?+?“\\neg.txt“;
_pos_txt_path?=?_main_path?+?“\\pos.txt“;
_neg_out.open(_neg_txt_path.c_str()?std::ios_base::out);
_ASSERT(_neg_out.is_open());
_pos_out.open(_pos_txt_path.c_str()?std::ios_base::out);
if?(!_pos_out.is_open())?_neg_out.close();
_ASSERT(_pos_out.is_open());
}
void?ChangeSamplePath::setPath(std::string?path)
{
_main_path?=?path;
initial();
}
void?ChangeSamplePath::changeFileName(std::ofstream&?out?std::string?path)
{
long?handler;
_finddata_t?file_finder;
std::string?file_name?=?path?+?“\\*.*“;
_ASSERT((handler?=?_findfirst(file_name.c_str()?&file_finder))?!=?-1);
do{
if?(file_finder.attrib?&?_A_ARCH)
{
std::string?old_file_name(file_finder.name);
int?dot_index?=?old_file_name.find(‘.‘);
std::string?new_file_name?=?old_file_name.substr(0?dot_index)?+?“temp“?+?old_file_name.substr(dot_index?old_file_name.length());
old_file_name?=?path?+?“\\“?+?old_file_name;
new_file_name?=?path?+?“\\“?+?new_file_name;
rename(old_file_name.c_str()?new_file_name.c_str());
}
}?while?(_findnext(handler?&file_finder)?==?0);
_findclose(handler);
_ASSERT((handler?=?_findfirst(file_name.c_str()?&file_finder))?!=?-1);
int?count?=?0;
do{
if?(file_finder.attrib?&?_A_ARCH)
{
count++;
std::string?old_file_name(file_finder.name);
int?dot_index?=?old_file_name.find(‘.‘);
std::string?new_file_name?=?generateName(count)?+?old_file_name.substr(dot_index?old_file_name.length());
old_file_name?=?path?+?“\\“?+?old_file_name;
new_file_name?=?path?+?“\\“?+?new_file_name;
rename(old_file_name.c_str()?new_file_name.c_str());
out?< }
}?while?(_findnext(handler?&file_finder)?==?0);
_findclose(handler);
}
void?ChangeSamplePath::doChange()
{
//neg_samples:
changeFileName(_neg_out?_neg_path);
//pos_samples:
changeFileName(_pos_out?_pos_path);
}
std::string?ChangeSamplePath::generateName(int?num)
{
char*?name?=?new?char[_name_length?+?1];
int?count?=?0;?
do{
count++;
name[_name_length?-?count]?=?num?%?10?+?‘0‘;
num?/=?10;
}?while?(num?!=?0);
for?(int?i?=?0;?i? {
name[i]?=?‘0‘;
}
name[_name_length]?=?‘\0‘;
std::string?new_name(name);
delete?name;
return?new_name;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-17?16:45??訓(xùn)練SVM分類器\
?????目錄???????????0??2018-04-17?16:45??訓(xùn)練SVM分類器\修改文件名程序\
?????目錄???????????0??2018-04-17?16:49??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\
?????目錄???????????0??2018-04-17?16:49??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\
?????文件????????2812??2018-04-17?16:22??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\ChangeSamplePath.cpp
?????文件????????1262??2018-04-17?16:49??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\ChangeSamplePath.h
?????文件????????4221??2018-04-17?14:26??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\ChangeSamplePath.vcxproj
?????文件????????1173??2018-04-17?14:26??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\ChangeSamplePath.vcxproj.filters
?????目錄???????????0??2018-04-17?16:45??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\
?????文件????????1142??2018-04-17?16:17??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.Build.CppClean.log
?????文件????????1501??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.log
?????文件??????353131??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.obj
?????目錄???????????0??2018-04-17?16:45??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\
?????文件?????????174??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\ChangeSamplePath.lastbuildstate
?????文件????????1442??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\cl.command.1.tlog
?????文件???????13764??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\CL.read.1.tlog
?????文件????????1822??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\CL.write.1.tlog
?????文件????????1472??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\li
?????文件????????3002??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\li
?????文件?????????730??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\ChangeSamplePath.tlog\li
?????文件??????355328??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\vc120.idb
?????文件??????372736??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\vc120.pdb
?????文件??????139462??2018-04-17?16:17??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\Debug\源.obj
?????文件?????????192??2018-04-17?14:57??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath\源.cpp
?????文件?????7340032??2018-04-17?16:49??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath.sdf
?????文件?????????994??2018-04-17?11:39??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath.sln
?????文件???????31744??2018-04-17?16:49??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\ChangeSamplePath.v12.suo
?????目錄???????????0??2018-04-17?16:45??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\Debug\
?????文件??????115200??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\Debug\ChangeSamplePath.exe
?????文件??????646104??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\Debug\ChangeSamplePath.ilk
?????文件??????871424??2018-04-17?16:23??訓(xùn)練SVM分類器\修改文件名程序\ChangeSamplePath\Debug\ChangeSamplePath.pdb
............此處省略31個文件信息
評論
共有 條評論