Mayank
Mayank

Reputation: 45

Multiple image reading in a given naming method in openCV and c++

I have a series of images with names like "alpha-beta-0", "alpha-beta-1",......."alpha-beta-20". I have to read these images and give output as one image after process them.

How can I do that in OpenCV and C++.

Upvotes: 2

Views: 140

Answers (2)

Werkov
Werkov

Reputation: 616

You can use universal cv::VideoCapture class that is able to load regularly named images as a video sequence (see docs).

cv::VideoCapture cap("alpha-beta-%d");
cv::Mat img;
while (cap.read(img)) {
    // process image
}

Upvotes: 6

Yang Kui
Yang Kui

Reputation: 548

You need to write some codes like this:

for(int i = 0; i <= 20 ; i++)
{
     std::stringstream str;
     str << "alpha-beta" << i;
     cv::Mat img = cv::imread(str.str());
     ////  process and show output ...
}

Upvotes: 1

Related Questions