Detector

Detector allows programmers to access an easy to use yet rich API to detect motion between two  frames, these frames could be the current frame of a camera and a dynamic background or simply just the current and previous frame, such images are supplied by the programmer and is not pre built into Detector. Detector also has inbuilt removal of bogus targets, maximum distance between targets until a new one is created, even supply a bitmap with white pixels to ignore motion in these regions. Using bitmaps for these regions allows us developers to create an easy to use interface where a user could “paint” onto the image and this bitmap is created without the user knowing…

The API

The API is so easy to use that nearly all programmers who code with C# should be able to use it. Some example usage follows.

// Inside of class outside of functions
private Detector detector = new Detector();

// Form Load or similar
// Set the image up to ignore motion
detector.IgnoreMotion = myIgnoreMotionImage;
// this defaults to 30, here for demonstration purposes
detector.MaxJoinDistance = 30;
// How much the image must change for the pixel to detect motion
detector.Diffrence = 60; 
// Remove any targets smaller than this size (often noise)
detector.NoiseReduction = 5;


// Where ever the new frame is captured
detector.SetNextImages(currentFrame, previousFrame);
foreach(Target t in detector.GetTargets())
{
    /*
    Draw your box over the image or what ever you wish to do with these variables:
        t.X // Position t starts on X axis
        t.Y // Position t starts on Y axis
        t.SizeX // The size of the target on the X axis
        t.SizeY // The size of the target on the Y axis
    */
}

Video

(please note the algorithm has been improved by far from when this video was made)

Download

Includes Detector.cs and a demo project with it. (the demo project is not written very well and just serves as an example)
GitHub