zoukankan      html  css  js  c++  java
  • 【20160924】GOCVHelper MFC增强算法(2)

    //创建或续写目录下的csv文件,填写“文件位置-分类”对
        int writeCsv(const stringfilename,const Vector<pair<string,string>>srcVect,char separator ){
            ofstream file(filename.c_str(),ofstream::app);
            if (!file)
                return 0;
            for (int i=0;i<srcVect.size();i++){
                file<<srcVect[i].first<<separator<<srcVect[i].second<<endl;
            }
            return srcVect.size();
        }
    //读取目录下的csv文件,获得“文件位置-分类”对
        vector<pair<string,string>> readCsv(const stringfilenamechar separator) {
            pair<string,stringapair;
            string linepathclasslabel;
            vector<pair<string,string>> retVect;
            ifstream file(filename.c_str(), ifstream::in);
            if (!file
                return retVect;
            while (getline(fileline)) {
                stringstream liness(line);
                getline(linesspathseparator);
                getline(linessclasslabel);
                if(!path.empty() && !classlabel.empty()) {
                    apair.first = path;
                    apair.second = classlabel;
                    retVect.push_back(apair);
                }
     
            }
            return retVect;

        }

    csv文件是最为简单的带格式文件。这种格式在opencv的人脸识别教程中得到了使用,这里是扣的它的代码。
    //获得ini文件中的值
         CString  GetInitStringCString Name1 ,CString Name2){
            char c[100] ;
            memsetc ,0 ,100) ;
            CString csCfgFilePath;
            GetModuleFileName(NULLcsCfgFilePath.GetBufferSetLength(MAX_PATH+1), MAX_PATH); 
            csCfgFilePath.ReleaseBuffer(); 
            int nPos = csCfgFilePath.ReverseFind ('\');
            csCfgFilePath = csCfgFilePath.Left (nPos);
            csCfgFilePath += "\Config" ;
            BOOL br = GetPrivateProfileString(Name1,Name2 ,"0",c, 100 , csCfgFilePath) ;
            CString rstr ;
            rstr .Format("%s" , c) ;
            return rstr ;
        }
         //写入ini问价中的值
         void WriteInitStringCString Name1 ,CString Name2 ,CString strvalue){
            CString csCfgFilePath;
            GetModuleFileName(NULLcsCfgFilePath.GetBufferSetLength(MAX_PATH+1), MAX_PATH); 
            csCfgFilePath.ReleaseBuffer(); 
            int nPos = csCfgFilePath.ReverseFind ('\');
            csCfgFilePath = csCfgFilePath.Left (nPos);
            csCfgFilePath += "\Config" ;
            BOOL br = WritePrivateProfileString(Name1 ,Name2 ,strvalue ,csCfgFilePath) ;
            if ( !br)
                TRACE("savewrong") ;
        }
    这两个函数主要是用来保存和修改配置文件的。通过直接将配置文件写入.ini中达到这个目标。
     
     





  • 相关阅读:
    [笔记] Duke
    foxmail配置office365邮箱
    bootstrap-select and selectpicker 修改下拉框的宽度或者下方留白
    项目技术沉淀0
    alibaba开发手册
    关于fastjson
    org.springframework.jdbc.UncategorizedSQLException: ### Error updating database. Cause: java.sql.SQLException: Incorrect string value: 'xE2x80x8BxE2x80x8B...' for column 'pro_backgroud' at row
    datatable某列不排序、和自定义搜索、给数据里面加属性
    19.10.30笔记-文件下载
    没有图片的freemarker下载,备份
  • 原文地址:https://www.cnblogs.com/jsxyhelu/p/5907502.html
Copyright © 2011-2022 走看看