Skip to content

Commit b1ee858

Browse files
committed
Read image with IMREAD_GRAYSCALE and add getImage() method
1 parent b933912 commit b1ee858

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class CV_EXPORTS Reader
4141
unsigned long getNumImages() const;
4242

4343

44+
/*!
45+
* @brief Given the id of the image and return the image. id is in fact just the index of the image in the
46+
* vector contains all the images.
47+
* @param id
48+
* @return Mat of the id^th image.
49+
*/
50+
Mat getImage(unsigned long id) const;
51+
4452
/*!
4553
* @brief Given the id of the image and return its timestamp value. id is in fact just the index of the image in the
4654
* vector contains all the images.

modules/photometric_calib/src/Reader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Reader::Reader(const std::string &folderPath, const std::string &timesPath)
5656
// images should be of CV_8U and same size
5757
for(size_t i = 0; i < images.size(); ++i)
5858
{
59-
Mat img = imread(images[i]);
59+
Mat img = imread(images[i], IMREAD_GRAYSCALE);
6060
CV_Assert(img.type() == CV_8U);
6161
if(i == 0)
6262
{
@@ -72,6 +72,12 @@ Reader::Reader(const std::string &folderPath, const std::string &timesPath)
7272
_folderPath = folderPath;
7373
}
7474

75+
Mat Reader::getImage(unsigned long id) const
76+
{
77+
CV_Assert(id < images.size());
78+
return imread(images[id], IMREAD_GRAYSCALE);
79+
}
80+
7581
double Reader::getTimestamp(unsigned long id) const
7682
{
7783
CV_Assert(id < timeStamps.size());

0 commit comments

Comments
 (0)