I want to read all the images having extension ".jpg" in ordered form using glob and filesystems. I am able to read the files but they are not in ordered form. My images names are 1.jpg,2.jpg,....100.jpg. But my code reads the files 1.jpg,10.jpg,11.jpg,..... (I am writing my code in Visual Studio)
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <filesystem>
using namespace std;
using namespace cv;
namespace fs = std::filesystem;
string frame_dir = "Task2_Resources/FrameImages/";
int main(){
vector<cv::String> filenames;
glob(frame_dir + "*.jpg", filenames,true);
Mat fimg,rimg;
for (size_t i = 0; i < filenames.size(); ++i)
{
fimg = imread(filenames[i]);
cout << filenames[i] <<endl;
}
return 0;
}