Skip to content

Commit 49646df

Browse files
committed
Add sample code for response calibration.
1 parent 5a5ed6b commit 49646df

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <string>
2+
#include <iostream>
3+
#include <iomanip>
4+
#include <vector>
5+
6+
#include <opencv2/opencv.hpp>
7+
#include <opencv2/core.hpp>
8+
#include <opencv2/highgui.hpp>
9+
#include <opencv2/photometric_calib.hpp>
10+
11+
#include <opencv2/imgproc/imgproc.hpp>
12+
13+
using namespace std;
14+
using namespace cv;
15+
16+
int main(int argc, char **argv)
17+
{
18+
// Please down load the sample dataset from:
19+
// https://www.dropbox.com/s/5x48uhc7k2bgjcj/GSoC2017_PhotometricCalib_Sample_Data.zip?dl=0
20+
// By unzipping the file, you would get a folder named /GSoC2017_PhotometricCalib_Sample_Data which contains 4 subfolders:
21+
// response_calib, response remover, vignette_calib, vignette_remover
22+
// in this sample, we will use the data in the folder response_calib and response_remover
23+
24+
// Prefix for the data, e.g. /Users/Yelen/GSoC2017_PhotometricCalib_Sample
25+
string userPrefix = "/Users/Yelen/GSoC2017_PhotometricCalib_Sample_Data/";
26+
// The path for the images used for response calibration
27+
string imageFolderPath = userPrefix + "response_calib/images";
28+
// The yaml file which contains the timestamps and exposure times for each image used for camera response calibration
29+
string timePath = userPrefix + "response_calib/times.yaml";
30+
31+
// Construct a photometric_calib::ResponseCalib object by giving path of image, path of time file and specify the format of images
32+
photometric_calib::ResponseCalib resCal(imageFolderPath, timePath, "jpg");
33+
34+
// Debug mode will generate some temporary data
35+
bool debug = true;
36+
// Calibration of camera response function begins
37+
resCal.calib(debug);
38+
39+
// The result and some intermediate data are stored in the folder ./photoCalibResult in which
40+
// pcalib.yaml is the camera response function file
41+
// Since we are using debug mode, we can visualize the response function:
42+
Mat invRes = imread("./photoCalibResult/G-10.png", CV_LOAD_IMAGE_UNCHANGED);
43+
// As shown as Fig.3 in the paper from J.Engel, et al. in the paper A Photometrically Calibrated Benchmark For Monocular Visual Odometry
44+
imshow("Inverse Response Function", invRes);
45+
waitKey(0);
46+
47+
// To see the response-calibrated image, we can use GammaRemover
48+
Mat oriImg = imread(imageFolderPath + "/00480.jpg", CV_LOAD_IMAGE_UNCHANGED);
49+
photometric_calib::GammaRemover gammaRemover("./photoCalibResult/pcalib.yaml", oriImg.cols, oriImg.rows);
50+
Mat caliImg = gammaRemover.getUnGammaImageMat(oriImg);
51+
imshow("Original Image", oriImg);
52+
waitKey(0);
53+
imshow("Gamma Removed Image", caliImg);
54+
waitKey(0);
55+
56+
return 0;
57+
}

0 commit comments

Comments
 (0)