opencv中的filesystem

c++中缺乏对文件的相关操作,以前用的是stlplus中的文件操作,无意中发现opencv中也有相关实现,记录一下方便查询。


#include <iostream>

#include <opencv2/opencv.hpp>
#include <opencv2/core/utils/filesystem.hpp>

using namespace std;
using namespace cv::utils::fs;


int main()
{
    cout << "Hello World!" << endl;
    std::string path = "/Users/han/Company/left";
    std::string output_path = cv::utils::fs::canonical(path);
    std::cout << "canonical path: " << output_path << std::endl;

    std::string save = "/Users/han/Company/save";
    std::cout << "创建目录: " << cv::utils::fs::createDirectory(save) << std::endl;

    if(cv::utils::fs::exists(path))
    {
        std::cout << "该文件夹存在---" << path << std::endl;
    }

    std::cout << "当前文件目录:" << cv::utils::fs::getcwd() << std::endl;

    // 获取当前文件夹下指定格式的文件
    std::vector<cv::String> img_lists;
    cv::utils::fs::glob(path , "*.jpg" , img_lists);
//    cv::gl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值