1 | initial version |
this is an "aliasing" problem. if you assign like Mat b; Mat a=b;
, this is only a "shallow" copy, both Mat's now point to the same pixels.
if ( cnt<= 5) stat_backgnd = small_raw_frame.clone();
(btw, 5 seems to be far too small)
UMat stat_backgnd;
capture.read(stat_backgnd);
for(;;){
UMat small_raw_frame, fgmask;
capture.read(small_raw_frame);
pMOG2->apply(small_raw_frame, fgmask); // say what you mean, mean what you say ..
int cnt =countNonZero(fgmask);
if ( cnt<= 5000 ) stat_backgnd = small_raw_frame;
imshow("fg", fgmask);
imshow("back", stat_backgnd);
if (waitKey(10) == 27) break;
}