TIEVisionBackgroundSubtractor.selectMethodMOG
Declaration
procedure selectMethodMOG(history: int32_t = 200; nmixtures: int32_t = 5; backgroundRatio: double = 0.7; noiseSigma: double = 0); safecall;
Description
Select the mixture-of-gaussian background subtractor algorithm.
Parameter | Description |
history | Length of the history |
nmixtures | Number of Gaussian mixtures |
backgroundRatio | Background ratio |
noiseSigma | Noise strength (standard deviation of the brightness or each color channel) |
| Demos\IEVision\BackgroundSubtract\BackgroundSubtract.dpr |
// Demo TImageEnViews:
// ImageEnView1: Captured video
// ImageEnView4: Image to use as background
// ImageEnView2: Foreground Mask
// ImageEnView3: Output with replaced background
// Capture button
procedure TMainForm.CaptureButtonClick(Sender: TObject);
var
w, h: integer;
f: AnsiString;
begin
VideoInputForm.Connect;
// start capture
ImageEnView1.IO.DShowParams.Run;
// set up background subtractor
m_backgroundSubtractor.selectMethodMOG();
end;
// We have a new frame
procedure TMainForm.ImageEnView1DShowNewFrame(Sender: TObject);
var
fgmask: TIEVisionImage;
learningRate: double;
begin
// copy current sample to ImageEnView bitmap
ImageEnView1.IO.DShowParams.GetSample(ImageEnView1.IEBitmap);
// get foreground mask
if CheckBoxLearning.Checked then
learningRate := -1
else
learningRate := 0;
fgmask := m_backgroundSubtractor.apply(ImageEnView1.IEBitmap.GetIEVisionImage(), learningRate);
ImageEnView2.IEBitmap.AssignIEVisionImage(fgmask);
// replace background using foreground mask
ImageEnView4.Proc.ResampleTo(ImageEnView3.IEBitmap, ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height, rfNone);
ImageEnView3.Proc.Merge(ImageEnView1.IEBitmap, ImageEnView2.IEBitmap);
// refresh viewers
ImageEnView1.Update();
ImageEnView2.Update();
ImageEnView3.Update();
end;