-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[GSoC 2017]Photometric Calibration. #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Changes from 8 commits
b962353
ef6cebe
d4d89c6
e42de3a
a8cb141
a3cb3d9
b34ec27
5ef6a78
1a94d7e
0456657
de6d4a8
616c25e
b933912
b1ee858
5c04c02
bb415db
80c227d
7c55a71
09b1767
5ff47e5
54d2c93
c077ecc
1bc6800
4d48aee
d787654
345f7fe
a89e952
2473675
2556e8c
a981654
b223312
12d64fe
044bb5e
d0ec626
62f76a4
1cda043
f248779
15ca7a9
78f3e56
7d9de8f
6772932
5a5ed6b
ceb2af6
c1d3f5c
ff2187c
963b29b
3e41953
ff5a312
6e97cc2
16ea96b
d7375e6
9653dde
3763355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set(the_description "Photometric Calibration") | ||
ocv_define_module(photometric_calib opencv_core opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui WRAP python) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Photometric Calibration | ||
================================================ | ||
|
||
Implementation of non-parametric photometric calibration algorithm proposed by J. Engel et al.: | ||
|
||
1. Camera Response Function Calibration | ||
2. Vignette Calibration | ||
3. Photometric Distortion Remover |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@InProceedings{engel2016monodataset, | ||
author = "J. Engel and V. Usenko and D. Cremers", | ||
title = "A Photometrically Calibrated Benchmark For Monocular Visual Odometry", | ||
booktitle = "arXiv:1607.02555", | ||
arXiv = " arXiv:1607.02555", | ||
year = "2016", | ||
month = "July", | ||
keywords={mono-ds,dso} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef __OPENCV_PHOTOMETRIC_CALIB_HPP__ | ||
#define __OPENCV_PHOTOMETRIC_CALIB_HPP__ | ||
|
||
#include "opencv2/core.hpp" | ||
#include "opencv2/imgproc.hpp" | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <iostream> | ||
#include <fstream> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. most of those includes are useless in the header and should be in the .cpp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
/** @defgroup photometric_calib Photometric Calibration | ||
*/ | ||
|
||
namespace cv { namespace photometric_calib{ | ||
|
||
//! @addtogroup photometric_calib | ||
//! @{ | ||
|
||
class CV_EXPORTS PhotometricCalibrator : public Algorithm | ||
{ | ||
public: | ||
bool validImgs(const std::vector <Mat> &inputImgs, const std::vector<double> &exposureTime); | ||
}; | ||
|
||
//! @} | ||
|
||
}} // namespace photometric_calib, cv | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef _OPENCV_READER_HPP | ||
#define _OPENCV_READER_HPP | ||
|
||
#include "opencv2/photometric_calib.hpp" | ||
|
||
namespace cv { namespace photometric_calib{ | ||
|
||
//! @addtogroup photometric_calib | ||
//! @{ | ||
|
||
class Reader | ||
{ | ||
public: | ||
Reader(const std::string &folderPath, const std::string ×Path); | ||
|
||
unsigned long getNumImages() const; | ||
|
||
double getTimestamp(unsigned long id) const; | ||
|
||
float getExposureTime(unsigned long id) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe getExposureDuration would be more explicit ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
|
||
private: | ||
inline void loadTimestamps(const std::string ×File); | ||
|
||
std::vector<String> files; | ||
std::vector<double> timeStamps; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the format should be explained in the doc: what is that double ? Time since when ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Vincent, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I thought timestamps always means the Unix Timestamp since Jan 01 1970? |
||
std::vector<float> exposureTimes; | ||
|
||
int width, height; | ||
|
||
String path; | ||
}; | ||
|
||
//! @} | ||
|
||
}} // namespace cv photometric_calib | ||
#endif //_OPENCV_READER_HPP |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#include "precomp.hpp" | ||
#include "opencv2/photometric_calib/Reader.hpp" | ||
|
||
namespace cv { namespace photometric_calib{ | ||
|
||
unsigned long Reader::getNumImages() const | ||
{ | ||
return (unsigned long)files.size(); | ||
} | ||
|
||
void Reader::loadTimestamps(const std::string ×File) | ||
{ | ||
CV_Assert(timesFile.substr(timesFile.find_last_of(".") + 1) == "yaml" || timesFile.substr(timesFile.find_last_of(".") + 1) == "yml"); | ||
|
||
FileStorage timeFile; | ||
timeFile.open(timesFile, FileStorage::READ); | ||
timeStamps.clear(); | ||
exposureTimes.clear(); | ||
|
||
CV_Assert(timeFile.isOpened()); | ||
|
||
FileNode timeStampNode = timeFile["times"]; | ||
FileNode exposureTimeNode = timeFile["exposures"]; | ||
|
||
CV_Assert(timeStampNode.type() == FileNode::SEQ && exposureTimeNode.type() == FileNode::SEQ); | ||
|
||
FileNodeIterator itTs = timeStampNode.begin(), itTsEnd = timeStampNode.end(); | ||
FileNodeIterator itEt = exposureTimeNode.begin(), itEtEnd = exposureTimeNode.end(); | ||
|
||
for (; itTs != itTsEnd; ++itTs) | ||
timeStamps.push_back((double)*itTs); | ||
for (; itEt != itEtEnd; ++itEt) | ||
exposureTimes.push_back((float)*itEt); | ||
|
||
timeFile.release(); | ||
|
||
CV_Assert(timeStamps.size() == getNumImages() && exposureTimes.size() == getNumImages()); | ||
} | ||
|
||
Reader::Reader(const std::string &folderPath, const std::string ×Path) | ||
{ | ||
String cvFolderPath(folderPath); | ||
glob(cvFolderPath, files); | ||
CV_Assert(files.size() > 0); | ||
std::sort(files.begin(), files.end()); | ||
loadTimestamps(timesPath); | ||
|
||
width = 0; | ||
height = 0; | ||
|
||
for(size_t i = 0; i < files.size(); ++i) | ||
{ | ||
Mat img = imread(files[i]); | ||
CV_Assert(img.type() == CV_8U); | ||
if(i == 0) | ||
{ | ||
width = img.cols; | ||
height = img.rows; | ||
} | ||
else | ||
{ | ||
CV_Assert(width == img.cols && height == img.rows); | ||
} | ||
} | ||
} | ||
|
||
double Reader::getTimestamp(unsigned long id) const | ||
{ | ||
CV_Assert(id < timeStamps.size()); | ||
return timeStamps[id]; | ||
} | ||
|
||
float Reader::getExposureTime(unsigned long id) const | ||
{ | ||
CV_Assert(id < exposureTimes.size()); | ||
return exposureTimes[id]; | ||
} | ||
|
||
}} // namespace photometric_calib, cv |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#include "precomp.hpp" | ||
#include "opencv2/photometric_calib.hpp" | ||
|
||
namespace cv{ namespace photometric_calib{ | ||
|
||
using namespace std; | ||
|
||
bool PhotometricCalibrator::validImgs(const std::vector <Mat> &inputImgs, const std::vector<double> &exposureTime) | ||
{ | ||
if(inputImgs.empty() || exposureTime.empty() || inputImgs.size() != exposureTime.size()) | ||
return false; | ||
|
||
int width = 0, height = 0; | ||
for(size_t i = 0; i < inputImgs.size(); ++ i) | ||
{ | ||
Mat img; | ||
img = inputImgs[i]; | ||
if(img.type() != CV_8U) | ||
{ | ||
cout<<"The type of the image should be CV_8U!"<<endl; | ||
return false; | ||
} | ||
if((width!=0 && width != img.cols) || img.cols==0) | ||
{ | ||
cout<<"Width mismatch!"<<endl; | ||
return false; | ||
}; | ||
if((height!=0 && height != img.rows) || img.rows==0) | ||
{ | ||
cout<<"Height mismatch!"<<endl; | ||
return false; | ||
}; | ||
width = img.cols; | ||
height = img.rows; | ||
} | ||
return true; | ||
} | ||
|
||
}} // namespace photometric_calib, cv |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef __OPENCV_PRECOMP_H__ | ||
#define __OPENCV_PRECOMP_H__ | ||
|
||
#include "opencv2/core.hpp" | ||
#include "opencv2/imgproc.hpp" | ||
#include "opencv2/highgui.hpp" | ||
#include <vector> | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the documentation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Thanks a lot for your comment!