Sunday, December 18, 2016

Motion Detection using C# and Accrod.Net

This blog shows how to perform Motion Detection using C# and Accord .Net.I assume you already installed accord .net in your system if not click here to know how to install and setup accord.net.Let's create a new new windows C# application project and add the following references to "Accord .Imaging.dll","Accord.Video.dll","Accord.Vision.dll","Accord.Video.Directshow.dll","Accord.dll".

Output:


Motion Detection Code:


 private Bitmap ProcessImage(Bitmap bSourceImage)
        {
            try
            {
                double th = cMotionDetector.ProcessFrame(bSourceImage);
                Graphics _graphics = Graphics.FromImage(bSourceImage);
                if (th > 0.02)
                {
                    _graphics.DrawString("Motion Level"+th.ToString("{0.0,00}"),cFont,cSolidBrush,cPointF);
                    return bSourceImage;
                }
                return bSourceImage;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:"+ex.ToString());
                return bSourceImage;
            }
        }


Download Source Code

Source Code






No comments:

Post a Comment