unfortunately, nan
and ìnf
are the result of "undefined behaviour", and will just get propagated as is.
// let's make one :)
float inf = 1.0/0.0;
cerr << inf << endl;
float nan = 0.0*inf;
cerr << nan << endl;
from here:
General note about OpenCV implementations: Using of NaN values
will provide undefined behavior and
should be avoided if there is no
special NaN-related note in
function/algorithm documentation.
to find out, if your Mat contains NaN's, compare it to itself:
Mat m = ...
Mat mask = (m != m);
int numNaNs = countNonZero(mask);
if you find any, you should remove them, using patchNaNs() before the next step of your algorithm.
If a number is equal to NaN It means that you have problem. Processing NaN is dangerous.
Better way is to insert some test in your algorithm to process indeterminate form.
Thank you.