result += times.at<float>((int)i) * w.mul(im);
wsum += times.at<float>((int)i) * times.at<float>((int)i) * w;
}
- result = result.mul(1 / wsum);
+ result = result.mul(1 / (wsum + Scalar::all(DBL_EPSILON)));
}
void process(InputArrayOfArrays src, OutputArray dst, InputArray times) CV_OVERRIDE
checkEqual(expected, response, 1e-1f, "CalibrateRobertson");
}
+TEST(Photo_CalibrateRobertson, bug_18180)
+{
+ vector<Mat> images;
+ vector<cv::String> fn;
+ string test_path = cvtest::TS::ptr()->get_data_path() + "hdr/exposures/bug_18180/";
+ for(int i = 1; i <= 4; ++i)
+ images.push_back(imread(test_path + std::to_string(i) + ".jpg"));
+ vector<float> times {15.0f, 2.5f, 0.25f, 0.33f};
+ Mat response, expected;
+ Ptr<CalibrateRobertson> calibrate = createCalibrateRobertson(2, 0.01f);
+ calibrate->process(images, response, times);
+ Mat response_no_nans = response.clone();
+ patchNaNs(response_no_nans);
+ // since there should be no NaNs, original response vs. response with NaNs patched should be identical
+ EXPECT_EQ(0.0, cv::norm(response, response_no_nans, NORM_L2));
+}
+
}} // namespace