Linux平台下用OpenCV读取文件夹内图片并显示

这篇博客介绍了如何在Linux环境下利用OpenCV库读取指定文件夹内的图片,并逐个显示出来。通过使用dirent.h库遍历目录,结合OpenCV的imread函数读取图片,然后利用resize方法调整图片大小,最后在窗口上展示。代码示例中展示了如何打开文件夹、获取文件名并转换为Mat对象进行处理。
摘要由CSDN通过智能技术生成

     #include <cv.h>
     #include <highgui.h>
     #include <iostream>
     #include <stdio.h>
     #include <unistd.h>
     #include <dirent.h>
     #include <stdlib.h>
     #include <sys/stat.h>
     #include <string.h>

      //定义文件夹的绝对路径

      const char* dir_name = "/home/zhhangfuqiang/images/";

      struct dirent * filename;    // return value for readdir()

      DIR * dir;                   // return value for opendir()

      //打开文件夹

      dir = opendir( dir_name );

      cout<<"Successfully opened the dir !"<<endl;

      /* 遍历文件夹中的所有文件 */
      while( ( filename = readdir(dir) ) != NULL )
         {
      get rid of "." and ".."
           if( strcmp( filename->d_name , "." ) &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值