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