Skip to content

Commit 7d9de8f

Browse files
committed
Code reformat.
1 parent 78f3e56 commit 7d9de8f

File tree

13 files changed

+610
-416
lines changed

13 files changed

+610
-416
lines changed

modules/photometric_calib/include/opencv2/photometric_calib.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include "opencv2/photometric_calib/ResponseCalib.hpp"
1212
#include "opencv2/photometric_calib/VignetteCalib.hpp"
1313

14-
namespace cv { namespace photometric_calib{
15-
}} // namespace photometric_calib, cv
14+
namespace cv {
15+
namespace photometric_calib {
16+
} // namespace photometric_calib
17+
} // namespace cv
1618

1719
#endif

modules/photometric_calib/include/opencv2/photometric_calib/GammaRemover.hpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
#include "opencv2/core.hpp"
99

10-
namespace cv { namespace photometric_calib {
10+
namespace cv {
11+
namespace photometric_calib {
1112

1213
//! @addtogroup photometric_calib
1314
//! @{
@@ -46,29 +47,34 @@ class CV_EXPORTS GammaRemover
4647
* @brief get gamma function.
4748
* @return
4849
*/
49-
inline float* getG()
50+
inline float *getG()
5051
{
51-
if(!validGamma) return 0;
52-
else return G;
52+
if (!validGamma)
53+
{ return 0; }
54+
else
55+
{ return G; }
5356
};
5457

5558
/*!
5659
* @brief get inverse gamma function
5760
* @return
5861
*/
59-
inline float* getGInv()
62+
inline float *getGInv()
6063
{
61-
if(!validGamma) return 0;
62-
else return GInv;
64+
if (!validGamma)
65+
{ return 0; }
66+
else
67+
{ return GInv; }
6368
};
6469

6570
private:
6671
float G[256];
6772
float GInv[256];
68-
int w,h;
73+
int w, h;
6974
bool validGamma;
7075
};
7176

72-
}}
77+
} // namespace photometric_calib
78+
} // namespace cv
7379

7480
#endif //_OPENCV__GAMMAREMOVER_HPP

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#include <vector>
1111
#include <string>
1212

13-
namespace cv { namespace photometric_calib{
13+
namespace cv {
14+
namespace photometric_calib {
1415

1516
//! @addtogroup photometric_calib
1617
//! @{
@@ -66,8 +67,11 @@ class CV_EXPORTS Reader
6667
float getExposureDuration(unsigned long id) const;
6768

6869
int getWidth() const;
70+
6971
int getHeight() const;
72+
7073
const std::string &getFolderPath() const;
74+
7175
const std::string &getTimeFilePath() const;
7276

7377
private:
@@ -89,5 +93,7 @@ class CV_EXPORTS Reader
8993

9094
//! @}
9195

92-
}} // namespace cv photometric_calib
96+
} // namespace photometric_calib
97+
} // namespace cv
98+
9399
#endif //_OPENCV_READER_HPP

modules/photometric_calib/include/opencv2/photometric_calib/ResponseCalib.hpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,36 @@
77

88
#include "opencv2/photometric_calib/Reader.hpp"
99

10-
namespace cv { namespace photometric_calib {
10+
namespace cv {
11+
namespace photometric_calib {
1112

1213
class CV_EXPORTS ResponseCalib
1314
{
1415
public:
1516
ResponseCalib(std::string folderPath, std::string timePath, std::string imageFormat);
16-
ResponseCalib(std::string folderPath, std::string timePath, int leakPadding, int nIts, int skipFrames, std::string imageFormat);
1717

18-
void plotE(const double* E, int w, int h, const std::string &saveTo);
18+
ResponseCalib(std::string folderPath, std::string timePath, int leakPadding, int nIts, int skipFrames,
19+
std::string imageFormat);
1920

20-
Vec2d rmse(const double* G, const double* E, const std::vector<double> &exposureVec, const std::vector<unsigned char*> &dataVec, int wh);
21+
void plotE(const double *E, int w, int h, const std::string &saveTo);
2122

22-
void plotG(const double* G, const std::string &saveTo);
23+
Vec2d rmse(const double *G, const double *E, const std::vector<double> &exposureVec,
24+
const std::vector<unsigned char *> &dataVec, int wh);
25+
26+
void plotG(const double *G, const std::string &saveTo);
2327

2428
void calib();
2529

26-
inline const std::string& getImageFolderPath () const
30+
inline const std::string &getImageFolderPath() const
2731
{
2832
CV_Assert(imageReader);
29-
return imageReader -> getFolderPath();
33+
return imageReader->getFolderPath();
3034
}
31-
inline const std::string& getTimeFilePath () const
35+
36+
inline const std::string &getTimeFilePath() const
3237
{
3338
CV_Assert(imageReader);
34-
return imageReader -> getTimeFilePath();
39+
return imageReader->getTimeFilePath();
3540
}
3641

3742
private:
@@ -41,6 +46,7 @@ class CV_EXPORTS ResponseCalib
4146
Reader *imageReader;
4247
};
4348

44-
}}
49+
} // namespace photometric_calib
50+
} // namespace cv
4551

4652
#endif //_OPENCV_RESPONSECALIB_HPP

modules/photometric_calib/include/opencv2/photometric_calib/VignetteCalib.hpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,35 @@
99
#include "opencv2/photometric_calib/Reader.hpp"
1010
#include "opencv2/photometric_calib/GammaRemover.hpp"
1111

12-
namespace cv { namespace photometric_calib {
12+
namespace cv {
13+
namespace photometric_calib {
1314

1415

1516
class CV_EXPORTS VignetteCalib
1617
{
1718
public:
18-
VignetteCalib(std::string folderPath, std::string timePath, std::string cameraFile, std::string gammaFile, std::string imageFormat, bool silent);
19-
VignetteCalib(std::string folderPath, std::string timePath, std::string cameraFile, std::string gammaFile, std::string imageFormat, bool silent, int imageSkip, int maxIterations, int outlierTh,
19+
VignetteCalib(std::string folderPath, std::string timePath, std::string cameraFile, std::string gammaFile,
20+
std::string imageFormat, bool silent);
21+
22+
VignetteCalib(std::string folderPath, std::string timePath, std::string cameraFile, std::string gammaFile,
23+
std::string imageFormat, bool silent, int imageSkip, int maxIterations, int outlierTh,
2024
int gridWidth, int gridHeight, float facW, float facH, int maxAbsGrad);
2125

2226
virtual ~VignetteCalib();
2327

2428
//EIGEN_ALWAYS_INLINE float getInterpolatedElement(const float* const mat, const float x, const float y, const int width)
25-
float getInterpolatedElement(const float* const mat, const float x, const float y, const int width);
29+
float getInterpolatedElement(const float *const mat, const float x, const float y, const int width);
30+
2631
float calMeanExposureTime();
27-
void displayImage(float* I, int w, int h, std::string name);
28-
void displayImageV(float* I, int w, int h, std::string name);
29-
bool preCalib(unsigned long id, float*& image, float*& plane2imgX, float*& plane2imgY);
32+
33+
void displayImage(float *I, int w, int h, std::string name);
34+
35+
void displayImageV(float *I, int w, int h, std::string name);
36+
37+
bool preCalib(unsigned long id, float *&image, float *&plane2imgX, float *&plane2imgY);
38+
3039
void calib();
40+
3141
void calibFast();
3242

3343
private:
@@ -58,7 +68,7 @@ class CV_EXPORTS VignetteCalib
5868
bool _silent;
5969
};
6070

61-
}}
62-
71+
} // namespace photometric_calib
72+
} // namespace cv
6373

6474
#endif //_OPENCV_VIGNETTECALIB_HPP

modules/photometric_calib/include/opencv2/photometric_calib/VignetteRemover.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
#include "opencv2/core.hpp"
99

10-
namespace cv { namespace photometric_calib {
10+
namespace cv {
11+
namespace photometric_calib {
1112

1213
//! @addtogroup photometric_calib
1314
//! @{
@@ -27,6 +28,7 @@ class CV_EXPORTS VignetteRemover
2728
* @param h_ the height of input image
2829
*/
2930
VignetteRemover(const std::string &vignettePath, int w_, int h_);
31+
3032
~VignetteRemover();
3133

3234
/*!
@@ -44,13 +46,13 @@ class CV_EXPORTS VignetteRemover
4446
void getUnVignetteImageVec(const std::vector<float> &unGammaImVec, std::vector<float> &outImVec);
4547

4648
private:
47-
float* vignetteMap;
48-
float* vignetteMapInv;
49-
int w,h;
49+
float *vignetteMap;
50+
float *vignetteMapInv;
51+
int w, h;
5052
bool validVignette;
5153
};
5254

53-
}}
54-
55+
} // namespace photometric_calib
56+
} // namespace cv
5557

5658
#endif //_OPENCV_VIGNETTEREMOVER_HPP

modules/photometric_calib/src/GammaRemover.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "precomp.hpp"
66
#include "opencv2/photometric_calib/GammaRemover.hpp"
77

8-
namespace cv { namespace photometric_calib {
8+
namespace cv {
9+
namespace photometric_calib {
910

1011
GammaRemover::GammaRemover(const std::string &gammaPath, int w_, int h_)
1112
{
@@ -14,7 +15,8 @@ GammaRemover::GammaRemover(const std::string &gammaPath, int w_, int h_)
1415
h = h_;
1516

1617
// check the extension of the time file.
17-
CV_Assert(gammaPath.substr(gammaPath.find_last_of(".") + 1) == "yaml" || gammaPath.substr(gammaPath.find_last_of(".") + 1) == "yml");
18+
CV_Assert(gammaPath.substr(gammaPath.find_last_of(".") + 1) == "yaml" ||
19+
gammaPath.substr(gammaPath.find_last_of(".") + 1) == "yml");
1820

1921
FileStorage gammaFile;
2022
gammaFile.open(gammaPath, FileStorage::READ);
@@ -25,45 +27,47 @@ GammaRemover::GammaRemover(const std::string &gammaPath, int w_, int h_)
2527
FileNodeIterator itS = gammaNode.begin(), itE = gammaNode.end();
2628
std::vector<float> GInvVec;
2729
for (; itS != itE; ++itS)
28-
GInvVec.push_back((float)*itS);
30+
{
31+
GInvVec.push_back((float) *itS);
32+
}
2933
CV_Assert(GInvVec.size() == 256);
3034

31-
for(int i=0;i<256;i++) GInv[i] = GInvVec[i];
32-
for(int i=0;i<255;i++)
35+
for (int i = 0; i < 256; i++) GInv[i] = GInvVec[i];
36+
for (int i = 0; i < 255; i++)
3337
{
34-
CV_Assert(GInv[i+1] > GInv[i]);
38+
CV_Assert(GInv[i + 1] > GInv[i]);
3539
}
3640
float min = GInv[0];
3741
float max = GInv[255];
38-
for(int i=0;i<256;i++) GInv[i] = (float) (255.0 * (GInv[i] - min) / (max - min));
39-
for(int i=1;i<255;i++)
42+
for (int i = 0; i < 256; i++) GInv[i] = (float) (255.0 * (GInv[i] - min) / (max - min));
43+
for (int i = 1; i < 255; i++)
4044
{
41-
for(int s=1;s<255;s++)
45+
for (int s = 1; s < 255; s++)
4246
{
43-
if(GInv[s] <= i && GInv[s+1] >= i)
47+
if (GInv[s] <= i && GInv[s + 1] >= i)
4448
{
45-
G[i] = s+(i - GInv[s]) / (GInv[s+1]-GInv[s]);
49+
G[i] = s + (i - GInv[s]) / (GInv[s + 1] - GInv[s]);
4650
break;
4751
}
4852
}
4953
}
5054
G[0] = 0;
5155
G[255] = 255;
5256
gammaFile.release();
53-
validGamma=true;
57+
validGamma = true;
5458
}
5559

5660
Mat GammaRemover::getUnGammaImageMat(Mat inputIm)
5761
{
5862
CV_Assert(validGamma);
5963
uchar *inputImArr = inputIm.data;
60-
float *outImArr = new float[w*h];
64+
float *outImArr = new float[w * h];
6165
for (int i = 0; i < w * h; ++i)
6266
{
6367
outImArr[i] = GInv[inputImArr[i]];
6468
}
6569
Mat _outIm(h, w, CV_32F, outImArr);
66-
Mat outIm = _outIm * (1/255.0f);
70+
Mat outIm = _outIm * (1 / 255.0f);
6771
delete[] outImArr;
6872
return outIm;
6973
}
@@ -72,8 +76,9 @@ void GammaRemover::getUnGammaImageVec(Mat inputIm, std::vector<float> &outImVec)
7276
{
7377
CV_Assert(validGamma);
7478
uchar *inputImArr = inputIm.data;
75-
CV_Assert(outImVec.size() == (unsigned long)w * h);
76-
for(int i = 0; i < w * h; i++) outImVec[i] = GInv[inputImArr[i]];
79+
CV_Assert(outImVec.size() == (unsigned long) w * h);
80+
for (int i = 0; i < w * h; i++) outImVec[i] = GInv[inputImArr[i]];
7781
}
7882

79-
}}
83+
} // namespace photometric_calib
84+
} // namespace cv

0 commit comments

Comments
 (0)