zoukankan      html  css  js  c++  java
  • 读取解析数据

    clc 
    clear all
    load imdb.mat
    [age,~]=datevec(datenum(imdb.photo_taken,7,1)-imdb.dob); 
    fid = fopen('imdb.txt','wt');
    
    for i = 1:length(imdb.photo_taken)
        fprintf(fid, '%s,', char(imdb.full_path(i)));
        fprintf(fid, '%d,',age(i));
        fprintf(fid,'%d
    ',imdb.gender(i));
    end
    
    fclose(fid)
    int main()
    {
        std::ifstream fin("D:\数据\年龄性别\imdb_crop\0.txt");//打开原始样本图片文件列表  
        string readImgPartDir = "D:\数据\年龄性别\imdb_crop\";
        string saveImgPartDir = "D:\数据\年龄性别\imdb_corect\";
        string creatDirName;//文件夹名
        string imgName;//图片名
        string readLineName;//从txt中读取,每行是一个字符串
        string readImg;//图片名完整路径
        string saveImgDirImg;
        string saveImgDir;
    while (getline(fin, readLineName))
        {
            cout << readLineName << endl;
            /*istringstream iss;
            iss.str(readLineName);
    
            iss >> creatDirName;
            iss >> imgName;*/
    
            creatDirName = readLineName.substr(0, readLineName.find_first_of("\"));
    
            //cout << "creatDirName=" << creatDirName << endl;
    
            imgName = readLineName.substr(readLineName.find_last_of("\") + 1);
    
            //cout << "imgName=" << imgName << endl;
    
            readImg = readImgPartDir + creatDirName + "\" + imgName;//输入图片
            saveImgDirImg = saveImgPartDir + creatDirName + "\" + imgName;//保存图片
            saveImgDir = saveImgPartDir + creatDirName;//需要创建的文件夹
    
            if (_access(saveImgDir.c_str(), 0) == -1)
            {
    
                int flag = _mkdir(saveImgDir.c_str());
    
                if (flag == 0)
                {
                    cout << "make successfully" << endl;
                }
                else
                {
                    cout << "make failed" << endl;
                }
            }
    
            cout << "image path: " << readImg << endl;
    
            Mat image = imread(readImg);
            if (image.empty())
            {
                printf("no image!");
                continue;
            }
            else
            {
               
                cv::imwrite(saveImgDirImg, alignFace);
            }
        }//end while
    
        return 0;
    }
  • 相关阅读:
    ASP.NET MVC 学习之路由(URL Routing)
    Linux 部署ASP.NET SQLite 应用 的坎坷之旅 附demo及源码
    linux解压zip文件
    /bin/sh^M:解释器错误:没有那个文件或目录
    mysql查看连接情况
    linux编译qt
    没有可用的软件包 xxx,但是它被其它的软件包引用了
    什么是人月
    qt linux 打包
    linux里安装使用svn
  • 原文地址:https://www.cnblogs.com/crazybird123/p/10132538.html
Copyright © 2011-2022 走看看