Skip to content

Commit de6d4a8

Browse files
committed
changed some properties names and added some getters and setters
1 parent 0456657 commit de6d4a8

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

modules/photometric_calib/include/opencv2/photometric_calib/Reader.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,20 @@ class Reader
2626

2727
float getExposureDuration(unsigned long id) const;
2828

29+
int getWidth() const;
30+
int getHeight() const;
31+
const std::string &getFolderPath() const;
2932

3033
private:
3134
inline void loadTimestamps(const std::string &timesFile);
3235

33-
std::vector<String> files;
34-
std::vector<double> timeStamps;
36+
std::vector<String> images; //All the names/paths of images
37+
std::vector<double> timeStamps; //All the Unix Time Stamps of images
3538
std::vector<float> exposureDurations;//All the exposure duration for images
3639

37-
int width, height;
40+
int _width, _height;//The image width and height. All the images should be of the same size.
3841

39-
String path;
42+
std::string _folderPath;
4043
};
4144

4245
//! @}

modules/photometric_calib/src/Reader.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ namespace cv { namespace photometric_calib{
99

1010
unsigned long Reader::getNumImages() const
1111
{
12-
return (unsigned long)files.size();
12+
return (unsigned long)images.size();
1313
}
1414

1515
void Reader::loadTimestamps(const std::string &timesFile)
1616
{
17+
// check the extension of the time file.
1718
CV_Assert(timesFile.substr(timesFile.find_last_of(".") + 1) == "yaml" || timesFile.substr(timesFile.find_last_of(".") + 1) == "yml");
1819

1920
FileStorage timeFile;
@@ -44,28 +45,31 @@ void Reader::loadTimestamps(const std::string &timesFile)
4445
Reader::Reader(const std::string &folderPath, const std::string &timesPath)
4546
{
4647
String cvFolderPath(folderPath);
47-
glob(cvFolderPath, files);
48-
CV_Assert(files.size() > 0);
49-
std::sort(files.begin(), files.end());
48+
glob(cvFolderPath, images);
49+
CV_Assert(images.size() > 0);
50+
std::sort(images.begin(), images.end());
5051
loadTimestamps(timesPath);
5152

52-
width = 0;
53-
height = 0;
53+
_width = 0;
54+
_height = 0;
5455

55-
for(size_t i = 0; i < files.size(); ++i)
56+
// images should be of CV_8U and same size
57+
for(size_t i = 0; i < images.size(); ++i)
5658
{
57-
Mat img = imread(files[i]);
59+
Mat img = imread(images[i]);
5860
CV_Assert(img.type() == CV_8U);
5961
if(i == 0)
6062
{
61-
width = img.cols;
62-
height = img.rows;
63+
_width = img.cols;
64+
_height = img.rows;
6365
}
6466
else
6567
{
66-
CV_Assert(width == img.cols && height == img.rows);
68+
CV_Assert(_width == img.cols && _height == img.rows);
6769
}
6870
}
71+
72+
_folderPath = folderPath;
6973
}
7074

7175
double Reader::getTimestamp(unsigned long id) const
@@ -79,6 +83,17 @@ float Reader::getExposureDuration(unsigned long id) const
7983
CV_Assert(id < exposureDurations.size());
8084
return exposureDurations[id];
8185
}
86+
87+
int Reader::getWidth() const {
88+
return _width;
89+
}
90+
91+
int Reader::getHeight() const {
92+
return _height;
93+
}
94+
95+
const std::string &Reader::getFolderPath() const {
96+
return _folderPath;
8297
}
8398

8499
}} // namespace photometric_calib, cv

0 commit comments

Comments
 (0)