-
Notifications
You must be signed in to change notification settings - Fork 63
/
load_image_3.cpp
46 lines (39 loc) · 1.18 KB
/
load_image_3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
void loadImage3()
{
// load images
vector<cv::Mat> imgList;
for (int i = 5; i <= 9; i++)
{
// create file name
ostringstream imgNumber; // #include <sstream>
imgNumber << setfill('0') << setw(4) << i; // #include <iomanip>
string filename = "../images/img" + imgNumber.str() + ".jpg";
// load image and store it into a vector
cv::Mat img;
img = cv::imread(filename);
imgList.push_back(img); // store pointer to current image in list
}
// display images from the vector
string windowName = "First steps in OpenCV";
cv::namedWindow(windowName, 1); // create window
for (auto it = imgList.begin(); it != imgList.end(); ++it)
{
// STUDENT TASK : Prevent image 7 from being displayed
if (it == (imgList.begin() + 2)) continue;
// display image
cv::imshow(windowName, *it);
cv::waitKey(0); // wait for keyboard input before continuing
}
}
int main()
{
loadImage3();
return 0;
}