private void buApplySettings_Click(object sender, EventArgs e) { AForge.Vision.Motion.IMotionDetector detector = null; AForge.Vision.Motion.IMotionProcessing processor = null; detector = new AForge.Vision.Motion.SimpleBackgroundModelingDetector(cbSuppressNoise.Checked) { DifferenceThreshold = (int)numDifferenceThreshold.Value, FramesPerBackgroundUpdate = (int)numPerBackgroundUpdate.Value, KeepObjectsEdges = true, MillisecondsPerBackgroundUpdate = (int)numMsPerBackgroupUpdate.Value }; processor = new AForge.Vision.Motion.BlobCountingObjectsProcessing() { HighlightColor = System.Drawing.Color.Red, HighlightMotionRegions = true, MinObjectsHeight = 20, MinObjectsWidth = 20 }; var x = new AForge.Vision.Motion.MotionDetector(detector, processor); motionDetector = x; mouseClickTime = (int)numericUpDown1.Value; }
public static AForge.Vision.Motion.MotionDetector GetDefaultMotionDetector() { AForge.Vision.Motion.IMotionDetector detector = null; AForge.Vision.Motion.IMotionProcessing processor = null; AForge.Vision.Motion.MotionDetector motionDetector = null; //detector = new AForge.Vision.Motion.TwoFramesDifferenceDetector() //{ // DifferenceThreshold = 15, // SuppressNoise = true //}; //detector = new AForge.Vision.Motion.CustomFrameDifferenceDetector() //{ // DifferenceThreshold = 15, // KeepObjectsEdges = true, // SuppressNoise = true //}; // This is currently the best one. detector = new AForge.Vision.Motion.SimpleBackgroundModelingDetector() { DifferenceThreshold = 15, FramesPerBackgroundUpdate = 5, KeepObjectsEdges = true, MillisecondsPerBackgroundUpdate = 5, SuppressNoise = true }; //processor = new AForge.Vision.Motion.GridMotionAreaProcessing() //{ // HighlightColor = System.Drawing.Color.Red, // HighlightMotionGrid = true, // GridWidth = 100, // GridHeight = 100, // MotionAmountToHighlight = 100F //}; processor = new AForge.Vision.Motion.BlobCountingObjectsProcessing() { HighlightColor = System.Drawing.Color.Red, HighlightMotionRegions = true, MinObjectsHeight = 20, MinObjectsWidth = 20 }; motionDetector = new AForge.Vision.Motion.MotionDetector(detector, processor); return(motionDetector); }