From 21e698053fb97f755846269e3db6d9800466693d Mon Sep 17 00:00:00 2001 From: Fernando Iglesias Garcia Date: Wed, 12 Apr 2017 10:11:50 +0200 Subject: [PATCH] Initialize background model in background subtraction KNN. The method does cvCheckPixelBackgroundNP (which reads bgmodel) before it is ever updated (in cvUpdatePixelBackgroundNP). This initialization is thus needed to avoid reads of unitialized values. --- modules/video/src/bgfg_KNN.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/video/src/bgfg_KNN.cpp b/modules/video/src/bgfg_KNN.cpp index 66be34a00f..9dcfe37e78 100755 --- a/modules/video/src/bgfg_KNN.cpp +++ b/modules/video/src/bgfg_KNN.cpp @@ -122,7 +122,7 @@ public: //! computes a background image which are the mean of all background gaussians virtual void getBackgroundImage(OutputArray backgroundImage) const; - //! re-initiaization method + //! re-initialization method void initialize(Size _frameSize, int _frameType) { frameSize = _frameSize; @@ -137,6 +137,7 @@ public: // for each sample of 3 speed pixel models each pixel bg model we store ... // values + flag (nchannels+1 values) bgmodel.create( 1,(nN * 3) * (nchannels+1)* size,CV_8U); + bgmodel = Scalar::all(0); //index through the three circular lists aModelIndexShort.create(1,size,CV_8U); -- GitLab