人脸识别CSV文件(c++实现)

本文分享了使用C++而非Python实现人脸识别CSV文件的方法,基于ORL库。文章提供了ORL库的下载链接,并简单提及代码实现及效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近看人脸识别,用的orl库,看网上人脸识别的csv文件都是用python实现的,但是我也懒得装python环境,所以用c++实现了,虽然不难,也和大家分享一下。
顺便提下orl库下载地址,csdn下载有点慢。。。。
orl地址;http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html
代码实现:

#include<iostream>
#include<vector>
#include<io.h>
#include<fstream>

using namespace std;

void getFiles(string path, vector<string>& files)
{
    //文件句柄  
    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);
    }
}

int main(){
    char* filepath = "F:\\opencv\\DATA\\orl";
    vector<string> files;
    ofstream off("csv.txt",ios::out);
    getFiles(filepath,files);
    char str[30];
    int size = files.size();
    for (int i = 1; i < size; i++){
        off << files[i].c_str();
        off << "\n";
    }
    off.close();
    return 0;
}

效果图
这里写图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值