Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to read sequentially image files in OpenCv and C++

Suppose I have 7 numbers of ".jpg" files in a folder. All the names are numeric that is 0.jpg, 4.jpg, 1.jpg etc. How to read the files sequentially according to there name incrementally. That is first 0.jpg then 1.jpg then 4.jpg will be read.

How to read sequentially image files in OpenCv and C++

Suppose I have 7 numbers of ".jpg" files in a folder. All the names are numeric that is 0.jpg, 4.jpg, 1.jpg etc. How to read the files sequentially according to there name incrementally. That is first 0.jpg then 1.jpg then 4.jpg will be read.

I have tried with glob( ) function but image read is not sequentially..

#include <opencv2/opencv.hpp>
#include<iostream>
#include <dirent.h> 
using namespace std;
using namespace cv;
int main()
{
String folder = "*.jpg";
 vector<String> filenames;
 glob(folder, filenames);
 cout<<filenames.size90<<endl;//to read no of files

  for(size_t i=0; i<filenames.size(),++i)
  {
  cout<<filenames[i]<<endl;
   }

}

and the output is as follows 7 // no of files in the folder ./0.jpg ./11.jpg ./14.jpg ./2.jpg ./6.jpg ./8.jpg ./9.jpg

How to read sequentially image files in OpenCv and C++

Suppose I have 7 numbers of ".jpg" files in a folder. All the names are numeric that is 0.jpg, 4.jpg, 1.jpg etc. How to read the files sequentially according to there name incrementally. That is first 0.jpg then 1.jpg then 4.jpg will be read.

I have tried with glob( ) function but image read is not sequentially..

#include <opencv2/opencv.hpp>
#include<iostream>
#include <dirent.h> 
using namespace std;
using namespace cv;
int main()
{
String folder = "*.jpg";
 vector<String> filenames;
 glob(folder, filenames);
 cout<<filenames.size90<<endl;//to cout<<filenames.size()<<endl;//to read no of files

  for(size_t i=0; i<filenames.size(),++i)
  {
  cout<<filenames[i]<<endl;
   }

}

and the output is as follows 7 // no of files in the folder ./0.jpg ./11.jpg ./14.jpg ./2.jpg ./6.jpg ./8.jpg ./9.jpg

How to read sequentially image files in OpenCv and C++

Suppose I have 7 numbers of ".jpg" files in a folder. All the names are numeric that is 0.jpg, 4.jpg, 1.jpg etc. How to read the files sequentially according to there name incrementally. That is first 0.jpg then 1.jpg then 4.jpg will be read.

I have tried with glob( ) function but image read is not sequentially..

#include <opencv2/opencv.hpp>
#include<iostream>
#include <dirent.h> 
using namespace std;
using namespace cv;
int main()
{
String folder = "*.jpg";
 vector<String> filenames;
 glob(folder, filenames);
 cout<<filenames.size()<<endl;//to read display no of files

  for(size_t i=0; i<filenames.size(),++i)
  {
  cout<<filenames[i]<<endl;
   }

}

and the output is as follows 7 // no of files in the folder ./0.jpg ./11.jpg ./14.jpg ./2.jpg ./6.jpg ./8.jpg ./9.jpg