@@ -121,7 +121,7 @@ void ResponseCalib::plotG(const double *G, const std::string &saveTo)
121
121
{
122
122
if (val < k)
123
123
{
124
- GImg.at <float >(k, i) = (float ) (k - val);
124
+ GImg.at <float >(255 - k, i) = (float ) (k - val);
125
125
}
126
126
}
127
127
}
@@ -132,14 +132,15 @@ void ResponseCalib::plotG(const double *G, const std::string &saveTo)
132
132
std::cout << " Saved: " << saveTo << std::endl;
133
133
}
134
134
135
- void ResponseCalib::calib ()
135
+ void ResponseCalib::calib (bool debug )
136
136
{
137
137
int w = 0 , h = 0 ;
138
138
size_t n = 0 ;
139
139
140
140
std::vector<double > exposureDurationVec;
141
141
std::vector<uchar *> dataVec;
142
142
143
+ std::cout << " Preprocessing for response calibration... " << std::endl;
143
144
for (unsigned long i = 0 ; i < imageReader->getNumImages (); i += _skipFrames)
144
145
{
145
146
cv::Mat img = imageReader->getImage (i);
@@ -235,8 +236,11 @@ void ResponseCalib::calib()
235
236
logFile.precision (15 );
236
237
237
238
std::cout << " Initial RMSE = " << rmse (G, E, exposureDurationVec, dataVec, w * h)[0 ] << " !" << std::endl;
238
- plotE (E, w, h, " photoCalibResult/E-0" );
239
- cv::waitKey (100 );
239
+ if (debug)
240
+ {
241
+ plotE (E, w, h, " photoCalibResult/E-0" );
242
+ cv::waitKey (100 );
243
+ }
240
244
241
245
bool optE = true ;
242
246
bool optG = true ;
@@ -270,9 +274,12 @@ void ResponseCalib::calib()
270
274
delete[] GNum;
271
275
printf (" optG RMSE = %f! \t " , rmse (G, E, exposureDurationVec, dataVec, w * h)[0 ]);
272
276
273
- char buf[1000 ];
274
- snprintf (buf, 1000 , " photoCalibResult/G-%02d.png" , it + 1 );
275
- plotG (G, buf);
277
+ if (debug)
278
+ {
279
+ char buf[1000 ];
280
+ snprintf (buf, 1000 , " photoCalibResult/G-%02d.png" , it + 1 );
281
+ plotG (G, buf);
282
+ }
276
283
}
277
284
278
285
if (optE)
@@ -302,9 +309,12 @@ void ResponseCalib::calib()
302
309
delete[] ESum;
303
310
printf (" OptE RMSE = %f! \t " , rmse (G, E, exposureDurationVec, dataVec, w * h)[0 ]);
304
311
305
- char buf[1000 ];
306
- snprintf (buf, 1000 , " photoCalibResult/E-%02d" , it + 1 );
307
- plotE (E, w, h, buf);
312
+ if (debug)
313
+ {
314
+ char buf[1000 ];
315
+ snprintf (buf, 1000 , " photoCalibResult/E-%02d" , it + 1 );
316
+ plotE (E, w, h, buf);
317
+ }
308
318
}
309
319
310
320
// rescale such that maximum response is 255 (fairly arbitrary choice).
@@ -314,9 +324,9 @@ void ResponseCalib::calib()
314
324
E[i] *= rescaleFactor;
315
325
if (i < 256 ) G[i] *= rescaleFactor;
316
326
}
317
- // Eigen::Vector2d err = rmse(G, E, exposureVec, dataVec, w*h );
327
+
318
328
Vec2d err = rmse (G, E, exposureDurationVec, dataVec, w * h);
319
- printf (" Rescaled RMSE = %f! \t rescale with %f!\n " , err[0 ], rescaleFactor);
329
+ printf (" Rescaled RMSE = %f! \t rescale with %f!\n\n " , err[0 ], rescaleFactor);
320
330
321
331
logFile << it << " " << n << " " << err[1 ] << " " << err[0 ] << " \n " ;
322
332
0 commit comments