-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageFiles.cpp
58 lines (43 loc) · 1.58 KB
/
ImageFiles.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
47
48
49
50
51
52
53
54
/*---------------------------------------------------------------------------*\
This program is free software. It comes without any warranty, to the extent
permitted by applicable law. You can redistribute it and/or modify it under
the terms of the Do What The Fuck You Want To Public License, Version 2, as
published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
Copyright © 2014 Luiz Gustavo M. Sampaio www.lgmsampaio.com
\*---------------------------------------------------------------------------*/
#include "ImageFiles.h"
#include <iomanip>
using namespace cv;
using namespace std;
// Implementation of ImageFiles class, loading chessboard images from disk
ImageFiles::ImageFiles(int totalImages)
: nrImages(totalImages), currentImage(0)
{
type = SourceType::IMAGE_FILE;
deviceName = "Images from disk";
// Load all images into a vector
for (int i = 0; i < nrImages; i++)
{
stringstream str;
// TODO: Make this input more generic in order to load different files
// from different places
str << "chessboards/chessboard" << std::setw(2) << std::setfill('0')
<< i << ".jpg";
// Simple output just to know what's happenning
//cout << str.str() << std::endl;
filelist.push_back(str.str());
}
}
ImageFiles::~ImageFiles(void) {}
bool ImageFiles::isConnected()
{
return true;
}
// In case of cameras, we can deliver infinite images while the camera is
// working. Here we have a limit of loaded images
Mat ImageFiles::getNextImage()
{
if(currentImage < (nrImages - 1))
return imread(filelist[++currentImage]);
return imread(filelist[currentImage]);
}