mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Added displaying of the mean background image in the bgfg_segm sample (ticket #317).
This commit is contained in:
parent
04ebfc0a02
commit
5d4afe81e0
@ -31,12 +31,14 @@ int main(int argc, char** argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
namedWindow("BG", 1);
|
namedWindow("image", CV_WINDOW_NORMAL);
|
||||||
namedWindow("FG", 1);
|
namedWindow("foreground mask", CV_WINDOW_NORMAL);
|
||||||
|
namedWindow("foreground image", CV_WINDOW_NORMAL);
|
||||||
|
namedWindow("mean background image", CV_WINDOW_NORMAL);
|
||||||
|
|
||||||
BackgroundSubtractorMOG2 bg_model;
|
BackgroundSubtractorMOG2 bg_model;
|
||||||
Mat img, fgmask;
|
Mat img, fgmask, fgimg;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
cap >> img;
|
cap >> img;
|
||||||
@ -44,10 +46,24 @@ int main(int argc, char** argv)
|
|||||||
if( img.empty() )
|
if( img.empty() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if( fgimg.empty() )
|
||||||
|
fgimg.create(img.size(), img.type());
|
||||||
|
|
||||||
|
//update the model
|
||||||
bg_model(img, fgmask, update_bg_model ? -1 : 0);
|
bg_model(img, fgmask, update_bg_model ? -1 : 0);
|
||||||
|
|
||||||
|
fgimg = Scalar::all(0);
|
||||||
|
img.copyTo(fgimg, fgmask);
|
||||||
|
|
||||||
|
Mat bgimg;
|
||||||
|
bg_model.getBackgroundImage(bgimg);
|
||||||
|
|
||||||
imshow("image", img);
|
imshow("image", img);
|
||||||
imshow("foreground mask", fgmask);
|
imshow("foreground mask", fgmask);
|
||||||
|
imshow("foreground image", fgimg);
|
||||||
|
if(!bgimg.empty())
|
||||||
|
imshow("mean background image", bgimg );
|
||||||
|
|
||||||
char k = (char)waitKey(30);
|
char k = (char)waitKey(30);
|
||||||
if( k == 27 ) break;
|
if( k == 27 ) break;
|
||||||
if( k == ' ' )
|
if( k == ' ' )
|
||||||
|
Loading…
Reference in New Issue
Block a user