Substituted the NaN check with OpenCV's implementation.
Substituted the NaN check with OpenCV's implementation.

opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv