private void defineMotionregionsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (videoSourcePlayer.VideoSource != null)
{
Bitmap currentVideoFrame = videoSourcePlayer.GetCurrentVideoFrame();
if (currentVideoFrame != null)
{
MotionRegionsForm form = new MotionRegionsForm();
form.VideoFrame = currentVideoFrame;
form.MotionRectangles = detector.MotionZones;
// show the dialog
if (form.ShowDialog(this) == DialogResult.OK)
{
Rectangle[] rects = form.MotionRectangles;
if (rects.Length == 0)
rects = null;
detector.MotionZones = rects;
}
return;
}
}
MessageBox.Show("It is required to start video source and receive at least first video frame before setting motion zones.",
"Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}