mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
HDR test changes
This commit is contained in:
parent
833f8d16fa
commit
9f9873017c
@ -206,9 +206,6 @@ public:
|
|||||||
|
|
||||||
CV_WRAP virtual int getSamples() const = 0;
|
CV_WRAP virtual int getSamples() const = 0;
|
||||||
CV_WRAP virtual void setSamples(int samples) = 0;
|
CV_WRAP virtual void setSamples(int samples) = 0;
|
||||||
|
|
||||||
CV_WRAP virtual bool getTest() const = 0;
|
|
||||||
CV_WRAP virtual void setTest(bool val) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 50, float lambda = 10.0f);
|
CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 50, float lambda = 10.0f);
|
||||||
|
@ -55,8 +55,7 @@ public:
|
|||||||
samples(samples),
|
samples(samples),
|
||||||
lambda(lambda),
|
lambda(lambda),
|
||||||
name("CalibrateDebevec"),
|
name("CalibrateDebevec"),
|
||||||
w(tringleWeights()),
|
w(tringleWeights())
|
||||||
test(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,9 +83,6 @@ public:
|
|||||||
for(int i = 0; i < samples; i++) {
|
for(int i = 0; i < samples; i++) {
|
||||||
|
|
||||||
int pos = 3 * (rand() % images[0].total()) + channel;
|
int pos = 3 * (rand() % images[0].total()) + channel;
|
||||||
if(test) {
|
|
||||||
pos = 3 * i + channel;
|
|
||||||
}
|
|
||||||
for(size_t j = 0; j < images.size(); j++) {
|
for(size_t j = 0; j < images.size(); j++) {
|
||||||
|
|
||||||
int val = (images[j].ptr() + pos)[0];
|
int val = (images[j].ptr() + pos)[0];
|
||||||
@ -113,9 +109,6 @@ public:
|
|||||||
exp(result, result);
|
exp(result, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getTest() const { return test; }
|
|
||||||
void setTest(bool val) { test = val; }
|
|
||||||
|
|
||||||
int getSamples() const { return samples; }
|
int getSamples() const { return samples; }
|
||||||
void setSamples(int val) { samples = val; }
|
void setSamples(int val) { samples = val; }
|
||||||
|
|
||||||
@ -141,7 +134,6 @@ protected:
|
|||||||
String name;
|
String name;
|
||||||
int samples;
|
int samples;
|
||||||
float lambda;
|
float lambda;
|
||||||
bool test;
|
|
||||||
Mat w;
|
Mat w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times = DE
|
|||||||
void loadResponseCSV(String path, Mat& response)
|
void loadResponseCSV(String path, Mat& response)
|
||||||
{
|
{
|
||||||
response = Mat(256, 1, CV_32FC3);
|
response = Mat(256, 1, CV_32FC3);
|
||||||
ifstream resp_file(path.c_str());
|
ifstream resp_file(path);
|
||||||
for(int i = 0; i < 256; i++) {
|
for(int i = 0; i < 256; i++) {
|
||||||
for(int c = 0; c < 3; c++) {
|
for(int c = 0; c < 3; c++) {
|
||||||
resp_file >> response.at<Vec3f>(i)[c];
|
resp_file >> response.at<Vec3f>(i)[c];
|
||||||
resp_file.ignore(1);
|
resp_file.ignore(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp_file.close();
|
resp_file.close();
|
||||||
@ -101,31 +101,31 @@ TEST(Photo_Tonemap, regression)
|
|||||||
linear->process(img, result);
|
linear->process(img, result);
|
||||||
loadImage(test_path + "linear.png", expected);
|
loadImage(test_path + "linear.png", expected);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(result, expected, 0);
|
checkEqual(result, expected, 3);
|
||||||
|
|
||||||
Ptr<TonemapDrago> drago = createTonemapDrago(gamma);
|
Ptr<TonemapDrago> drago = createTonemapDrago(gamma);
|
||||||
drago->process(img, result);
|
drago->process(img, result);
|
||||||
loadImage(test_path + "drago.png", expected);
|
loadImage(test_path + "drago.png", expected);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(result, expected, 0);
|
checkEqual(result, expected, 3);
|
||||||
|
|
||||||
Ptr<TonemapDurand> durand = createTonemapDurand(gamma);
|
Ptr<TonemapDurand> durand = createTonemapDurand(gamma);
|
||||||
durand->process(img, result);
|
durand->process(img, result);
|
||||||
loadImage(test_path + "durand.png", expected);
|
loadImage(test_path + "durand.png", expected);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(result, expected, 0);
|
checkEqual(result, expected, 3);
|
||||||
|
|
||||||
Ptr<TonemapReinhardDevlin> reinhard_devlin = createTonemapReinhardDevlin(gamma);
|
Ptr<TonemapReinhardDevlin> reinhard_devlin = createTonemapReinhardDevlin(gamma);
|
||||||
reinhard_devlin->process(img, result);
|
reinhard_devlin->process(img, result);
|
||||||
loadImage(test_path + "reinharddevlin.png", expected);
|
loadImage(test_path + "reinharddevlin.png", expected);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(result, expected, 0);
|
checkEqual(result, expected, 3);
|
||||||
|
|
||||||
Ptr<TonemapMantiuk> mantiuk = createTonemapMantiuk(gamma);
|
Ptr<TonemapMantiuk> mantiuk = createTonemapMantiuk(gamma);
|
||||||
mantiuk->process(img, result);
|
mantiuk->process(img, result);
|
||||||
loadImage(test_path + "mantiuk.png", expected);
|
loadImage(test_path + "mantiuk.png", expected);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(result, expected, 0);
|
checkEqual(result, expected, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Photo_AlignMTB, regression)
|
TEST(Photo_AlignMTB, regression)
|
||||||
@ -169,7 +169,7 @@ TEST(Photo_MergeMertens, regression)
|
|||||||
loadImage(test_path + "merge/mertens.png", expected);
|
loadImage(test_path + "merge/mertens.png", expected);
|
||||||
merge->process(images, result);
|
merge->process(images, result);
|
||||||
result.convertTo(result, CV_8UC3, 255);
|
result.convertTo(result, CV_8UC3, 255);
|
||||||
checkEqual(expected, result, 0);
|
checkEqual(expected, result, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Photo_MergeDebevec, regression)
|
TEST(Photo_MergeDebevec, regression)
|
||||||
@ -188,7 +188,7 @@ TEST(Photo_MergeDebevec, regression)
|
|||||||
loadImage(test_path + "merge/debevec.exr", expected);
|
loadImage(test_path + "merge/debevec.exr", expected);
|
||||||
merge->process(images, result, times, response);
|
merge->process(images, result, times, response);
|
||||||
imwrite("test.exr", result);
|
imwrite("test.exr", result);
|
||||||
checkEqual(expected, result, 1e-3f);
|
checkEqual(expected, result, 1e-2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Photo_CalibrateDebevec, regression)
|
TEST(Photo_CalibrateDebevec, regression)
|
||||||
@ -197,11 +197,11 @@ TEST(Photo_CalibrateDebevec, regression)
|
|||||||
|
|
||||||
vector<Mat> images;
|
vector<Mat> images;
|
||||||
vector<float> times;
|
vector<float> times;
|
||||||
Mat expected, response;
|
Mat response, expected;
|
||||||
loadExposureSeq(test_path + "exposures/", images, times);
|
loadExposureSeq(test_path + "exposures/", images, times);
|
||||||
loadResponseCSV(test_path + "calibrate/debevec.csv", expected);
|
loadResponseCSV(test_path + "calibrate/debevec.csv", expected);
|
||||||
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
|
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
|
||||||
calibrate->setTest(true);
|
srand(1);
|
||||||
calibrate->process(images, response, times);
|
calibrate->process(images, response, times);
|
||||||
checkEqual(expected, response, 1e-3f);
|
checkEqual(expected, response, 1e-3f);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user