Commit 2b766bf0 authored by Patrick Snape's avatar Patrick Snape

Use std::numeric_limits<float>::quiet_NaN()

NAN is a compiler specific constant that does not exist on
visual studio. I also noticed that some NAN instances had been
cast to float, whereas quiet_NaN is both 1) defined by the
standard and 2) templated for the correct type. This is a much
more portable method of getting a NaN value.
parent 6a356286
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
// //
//M*/ //M*/
#include <limits>
#include "precomp.hpp" #include "precomp.hpp"
//TODO delete highgui include //TODO delete highgui include
//#include <opencv2/highgui.hpp> //#include <opencv2/highgui.hpp>
...@@ -81,7 +82,7 @@ bool MotionSaliencyBinWangApr2014::init() ...@@ -81,7 +82,7 @@ bool MotionSaliencyBinWangApr2014::init()
// Since data is even, the median is estimated using two values ​​that occupy // Since data is even, the median is estimated using two values ​​that occupy
// the position (n / 2) and ((n / 2) +1) (choose their arithmetic mean). // the position (n / 2) and ((n / 2) +1) (choose their arithmetic mean).
potentialBackground = Mat( imgSize.height, imgSize.width, CV_32FC2, Scalar( NAN, 0 ) ); potentialBackground = Mat( imgSize.height, imgSize.width, CV_32FC2, Scalar( std::numeric_limits<float>::quiet_NaN(), 0 ) );
backgroundModel.resize( K + 1 ); backgroundModel.resize( K + 1 );
...@@ -89,7 +90,7 @@ bool MotionSaliencyBinWangApr2014::init() ...@@ -89,7 +90,7 @@ bool MotionSaliencyBinWangApr2014::init()
{ {
Mat* tmpm = new Mat; Mat* tmpm = new Mat;
tmpm->create( imgSize.height, imgSize.width, CV_32FC2 ); tmpm->create( imgSize.height, imgSize.width, CV_32FC2 );
tmpm->setTo( Scalar( NAN, 0 ) ); tmpm->setTo( Scalar( std::numeric_limits<float>::quiet_NaN(), 0 ) );
Ptr<Mat> tmp = Ptr<Mat>( tmpm ); Ptr<Mat> tmp = Ptr<Mat>( tmpm );
backgroundModel[i] = tmp; backgroundModel[i] = tmp;
} }
...@@ -479,7 +480,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask, ...@@ -479,7 +480,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
/////////////////// REPLACEMENT of backgroundModel template /////////////////// /////////////////// REPLACEMENT of backgroundModel template ///////////////////
//replace TA with current TK //replace TA with current TK
backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j ); backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j );
potentialBackground.at<Vec2f>( i, j )[0] = (float)NAN; potentialBackground.at<Vec2f>( i, j )[0] = std::numeric_limits<float>::quiet_NaN();
potentialBackground.at<Vec2f>( i, j )[1] = 0; potentialBackground.at<Vec2f>( i, j )[1] = 0;
break; break;
...@@ -489,7 +490,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask, ...@@ -489,7 +490,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
else else
{ {
backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j ); backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j );
potentialBackground.at<Vec2f>( i, j )[0] = (float)NAN; potentialBackground.at<Vec2f>( i, j )[0] = std::numeric_limits<float>::quiet_NaN();
potentialBackground.at<Vec2f>( i, j )[1] = 0; potentialBackground.at<Vec2f>( i, j )[1] = 0;
} }
} // close if of EVALUATION } // close if of EVALUATION
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment