首页 文章 精选 留言 我的

精选列表

搜索[Tree-like算法],共10000篇文章
优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(5)

CStringExportListToExcel(CStringsExcelFile,CListCtrl*pList,CStringstrTitle) { CStringwarningStr; if(pList->GetItemCount()>0){ CDatabasedatabase; CStringsSql; CStringtableName=strTitle; //检索是否安装有Excel驱动"MicrosoftExcelDriver(*.xls)" CStringsDriver; sDriver=GetExcelDriver(); if(sDriver.IsEmpty()) { //没有发现Excel驱动 AfxMessageBox("没有安装Excel!\n请先安装Excel软件才能使用导出功能!"); returnNULL; } ///默认文件名 /*CStringsExcelFile; if(!GetDefaultXlsFileName(sExcelFile)) returnNULL;*/ //创建进行存取的字符串 sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s",sDriver,sExcelFile,sExcelFile); //创建数据库(既Excel表格文件) if(database.OpenEx(sSql,CDatabase::noOdbcDialog)) { //创建表结构 inti; LVCOLUMNcolumnData; CStringcolumnName; intcolumnNum=0; CStringstrH; CStringstrV; sSql=""; strH=""; columnData.mask=LVCF_TEXT; columnData.cchTextMax=100; columnData.pszText=columnName.GetBuffer(100); for(i=0;pList->GetColumn(i,&columnData);i++) { if(i!=0) { sSql=sSql+","; strH=strH+","; } sSql=sSql+""+columnData.pszText+"TEXT"; strH=strH+""+columnData.pszText+""; } columnName.ReleaseBuffer(); columnNum=i; sSql="CREATETABLE"+tableName+"("+sSql+")"; database.ExecuteSQL(sSql); //插入数据项 intnItemIndex; for(nItemIndex=0;nItemIndex<pList->GetItemCount();nItemIndex++){ strV=""; for(i=0;i<columnNum;i++) { if(i!=0) { strV=strV+","; } strV=strV+"'"+pList->GetItemText(nItemIndex,i)+"'"; } sSql="INSERTINTO"+tableName +"("+strH+")" +"VALUES("+strV+")"; database.ExecuteSQL(sSql); } } //关闭数据库 database.Close(); returnsExcelFile; } } 图像处理生成了结果,如果需要保存为报表文件,或者想进一步存入数据库中,Excel都是非常好的选择。在这里集成了vc知识库中提供的代码。版权为 ////////////////////////////////////////////////////////////////////////////// //名称:GetExcelDriver //功能:获取ODBC中Excel驱动 //作者:徐景周(jingzhou_xu@163.net) //组织:未来工作室(FutureStudio) //日期:2002.9.1 ///////////////////////////////////////////////////////////////////////////// 使用的时候,只需要将生成的结果填入 CListCtrl 控件中,而后直接到处就可以。也就是把excel输出的问题变成了向 CListCtrl 控件输出的问题。同时代码中还提供了能够直接写到两个sheet中的方法,可供参考 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(2)

//创建或续写目录下的csv文件,填写“文件位置-分类”对 intwriteCsv(conststring&filename,constVector<pair<string,string>>srcVect,charseparator){ ofstreamfile(filename.c_str(),ofstream::app); if(!file) return0; for(inti=0;i<srcVect.size();i++){ file<<srcVect[i].first<<separator<<srcVect[i].second<<endl; } returnsrcVect.size(); } //读取目录下的csv文件,获得“文件位置-分类”对 vector<pair<string,string>>readCsv(conststring&filename,charseparator){ pair<string,string>apair; stringline,path,classlabel; vector<pair<string,string>>retVect; ifstreamfile(filename.c_str(),ifstream::in); if(!file) returnretVect; while(getline(file,line)){ stringstreamliness(line); getline(liness,path,separator); getline(liness,classlabel); if(!path.empty()&&!classlabel.empty()){ apair.first=path; apair.second=classlabel; retVect.push_back(apair); } } returnretVect; } csv文件是最为简单的带格式文件。这种格式在opencv的人脸识别教程中得到了使用,这里是扣的它的代码。 //获得ini文件中的值 CStringGetInitString(CStringName1,CStringName2){ charc[100]; memset(c,0,100); CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); csCfgFilePath+="\\Config"; BOOLbr=GetPrivateProfileString(Name1,Name2,"0",c,100,csCfgFilePath); CStringrstr; rstr.Format("%s",c); returnrstr; } //写入ini问价中的值 voidWriteInitString(CStringName1,CStringName2,CStringstrvalue){ CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); csCfgFilePath+="\\Config"; BOOLbr=WritePrivateProfileString(Name1,Name2,strvalue,csCfgFilePath); if(!br) TRACE("savewrong"); } 这两个函数主要是用来保存和修改配置文件的。通过直接将配置文件写入.ini中达到这个目标。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(3)

//获得当前目录路径 staticCStringGetLocalPath(){ CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); returncsCfgFilePath; } //获得.exe路径 staticCStringGetExePath() { CStringstrPath; GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); strPath.ReleaseBuffer(); returnstrPath; } MFC程序涉及的时候存在一个问题,就是某些操作会修改自动"当前路径"的值。这两个函数能够获得当前的路径。 //开机自动运行 staticBOOLSetAutoRun(CStringstrPath,boolflag) { CStringstr; HKEYhRegKey; BOOLbResult; str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE,str,&hRegKey)!=ERROR_SUCCESS) bResult=FALSE; else { _splitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL); strPath.ReleaseBuffer(); str.ReleaseBuffer();//str是键的名字 if(flag){ if(::RegSetValueEx(hRegKey,str,0,REG_SZ,(CONSTBYTE*)strPath.GetBuffer(0),strPath.GetLength())!=ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; }else{ if(::RegDeleteValue(hRegKey,str)!=ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; } strPath.ReleaseBuffer(); } returnbResult; } 这个无需更多说明。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(4)

//string替换 voidstring_replace(string&strBig,conststring&strsrc,conststring&strdst) { string::size_typepos=0; string::size_typesrclen=strsrc.size(); string::size_typedstlen=strdst.size(); while((pos=strBig.find(strsrc,pos))!=string::npos) { strBig.replace(pos,srclen,strdst); pos+=dstlen; } } 字符串操作一直都是重要的基础操作。在图像处理的过程中,涉及到文件名等变换都需要字符串操作。string_replace中能够成块地换字符。虽然在std中可能已经有相关函数,不过既然我自己的这个用的比较熟悉,就是使用了。 //C++的spilt函数 voidSplitString(conststring&s,vector<string>&v,conststring&c){ std::string::size_typepos1,pos2; pos2=s.find(c); pos1=0; while(std::string::npos!=pos2){ v.push_back(s.substr(pos1,pos2-pos1)); pos1=pos2+c.size(); pos2=s.find(c,pos1); } if(pos1!=s.length()) v.push_back(s.substr(pos1)); } 依然是增强了std中的相关功能,实际使用的时候非常有用。 //!通过文件夹名称获取文件名,不包括后缀 voidgetFileName(conststring&filepath,string&name,string&lastname){ vector<string>spilt_path; SplitString(filepath,spilt_path,"\\"); intspiltsize=spilt_path.size(); stringfilename=""; if(spiltsize!=0){ filename=spilt_path[spiltsize-1]; vector<string>spilt_name; SplitString(filename,spilt_name,"."); intname_size=spilt_name.size(); if(name_size!=0) name=spilt_name[0]; lastname=spilt_name[name_size-1]; } } 前面的函数getfiles能够获得文件的真实路径。那么getFileName能够进一步处理,直接获得图片的名称。很多时候,图片读取了,需要处理一下,这个都是需要的。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册