System information (version)
- OpenCV => 4.3, 4.4
- Operating System / Platform => Windows 64 Bit with pre-built library
- Compiler => Visual Studio 2019
Detailed description
void patchNaNs(InputOutputArray a, double val = 0)
https://docs.opencv.org/4.4.0/d2/de8/group__core__array.html#ga62286befb7cde3568ff8c7d14d5079da
converts the values in input matrix that is NaN or -NaN to val.
However, the documentation doesn't say that the input matrix should be of type float.
It will be caught in debug build with an assert, and crash the program in release build. My bad, it doesn't crash the program. But rather not handled properly in my program.
Steps to reproduce
uint64_t temp64 = 0x7FF0000000000001u;
double not_a_number_double = *((double*)(&temp64));
std::cout << "not_a_number_double: " << not_a_number_double << std::endl;
temp64 = 0xFFF0000000000001u;
double negative_not_a_number_double = *((double*)(&temp64));
std::cout << "negative_not_a_number_double: " << negative_not_a_number_double << std::endl;
Mat mu3(Size(3, 3), CV_64FC1, Scalar(not_a_number_double));
std::cout << "mu3 before patchNaNs: " << mu3 << std::endl;
cv::patchNaNs(mu3, 0.0); // error occurred at here
std::cout << "mu3 after patchNaNs: " << mu3 << std::endl;
Mat mu4(Size(3, 3), CV_64FC1, Scalar(negative_not_a_number_double));
std::cout << "mu4 before patchNaNs: " << mu4 << std::endl;
cv::patchNaNs(mu4, 0.0);
std::cout << "mu4 after patchNaNs: " << mu4 << std::endl;
Issue submission checklist
System information (version)
Detailed description
void patchNaNs(InputOutputArray a, double val = 0)
https://docs.opencv.org/4.4.0/d2/de8/group__core__array.html#ga62286befb7cde3568ff8c7d14d5079da
converts the values in input matrix that is NaN or -NaN to val.
However, the documentation doesn't say that the input matrix should be of type float.
It will be caught in debug build with an assert,
and crash the program in release build.My bad, it doesn't crash the program. But rather not handled properly in my program.Steps to reproduce
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution