How the motion detection algorithm works?

Previously posted on old Pusu blog:

26 Mar ’05 – 22:06 by  Cahit Güngör

Pusu, does its job in J2ME environment by a motion detection algorithm. Briefly, motion detection algorithm based on frame difference calculation.

After reference image has been shot, the algorithm runs until a motion is detected.

Algorithm has two images to identify whether there is a significant change that can be considered as a motion in the projected vision or not.

The calculation is done in RGB format data of the images in byte arrays.

Initially two images are  processed to see if there is an overall change in the projected vision. This overall change must not effect the image difference calculation since this change might be caused by an environmental effect such as illumination difference, rather than a motion. Overall change effects are stored to be used in pixel difference calculation which is a part of the motion detection algorithm. The overall difference will be called correction hereafter in this text.

Two byte arrays are compared to see if there is considerable change in the pixels. Considerable change is determined by a threshold value which is called pixel threshold. If the difference between two pixels is greater than the pixel threshold, it is then compared with the correction value. Afterwards, according to the result the pixel is labeled as black if it has changed, otherwise the pixel is labeled as white. Now the different pixels can be seen in the real-time image.

The new image which keeps a view of difference is our reference. This image is processed to catch a motion of an entire body rather than individual minor pixels. This process of the motion detection algorithm is called blob calculation.

Blob calculation calculates the entire body of black blob size. This calculation is done by finding the radius of a blob. This radius of the blob is compared with another threshold value which is called blob threshold. This value is determined according to what sensitivity is wanted to be achieved on the motion detection system. In our motion detection system, this sensitivity is defined by the user of the mobile phone and passed as an argument to the algorithm. For example, if the user has a cat, and s/he doesn’t want to be alarmed by its motions, the blob threshold should be assigned accordingly.

Whenever a blob with a greater radius than blob threshold, the algorithm finishes the process telling the upper layer there is a motion in the projected area.

four comments, already:

Any existing prototype/proof of concepts of this exist yet ?
– Vikram

Vikram – 06 April ’05 – 14:02

If you are asking about the full application, the answer is yes. Actually we are testing it, and achieves satisfactory results. “Now Application Detects Motion” log samples some test. (They are not very scientific, sorry :). The images that reflects motions will be send to a database and the results will be published via web. We are planning to finish that reporting side in a week, it will be announced in this blog either.
Thank you very much for your attention…
Cahit G�ng�r

Cahit Güngör (
– 06 April ’05 – 23:22

i m unable to understand correction value and pixel threshold..can u elaborate? and also are u doing the calculation on mobile itself or on some server.

abhinav (
17 June ’05 – 10:28

First of all we aren’t doing any process out of the mobile. Every calculation has been done on the mobile phone.

The purpose of the correction value is to clean out the general differences in two images. For example if the overall light has been changed in the second image; you have to eliminate this difference. This is what correction value is for.

Pixel threshold is a simple threshold value that shows if there is a significant change in two corresponding pixels.

Cahit Gungor – 02 August ’05 – 15:52

Advertisements

17 thoughts on “How the motion detection algorithm works?

  1. hi cahit

    we are doing a project based on this algorithm ,

    i am new to J2ME i need some resources to activate the cam in phone and how to apply this algorithm..?

  2. hi cahit

    i m trying to develop a j2me application for motion detection through camera….can you send me a link or email me the source code of “pusu”?

    i completely understand if you are unable to oblige.

    thnx.

    email: kgirish87@gmail.com

  3. Hi,

    Is it possible to get any source code of your motion detector? I need to create application in J2ME wich could detect X and Y motion.

    • The source code is not open. But the algorithm is fully explained. Actually it was not designed to find the motion vector which you are willing to find out.

    • Algorithm starts with a reference frame, this frame is is compared with the incoming frames. Filters, thresholds and motion diameter option are included. Yes “motion detection” can be done with one frame. If you were interested in “motion trail” it is not the concept in this project.

  4. am also working on the motion detection algorithm. its my final year project. so wioll you please send me the documentations and other helps such as its working, source code applications and whatever you have.
    thanks in advance.

  5. hi , cahit i m final year student & my project is based on object traking. i m not getting how to start with it .u please suggest me basic information about it & from where i should get algorithm……. please do reply1

  6. Hai Sir..

    I have to apply this motion detection algorithm in my Project…
    I need some additional explanation about this algorithms,and i want know how to detect the frame by frame images capture by cam…

  7. motion detection is possible to do for gait analysis.is able to combine the motion detection with virtual sensor calculation based on simulation.

    • Gait analysis is out of scope of this project. The time the pusu project developed, the mobile device capabilities were not sufficient for that kind of analysis, it is not needed neither.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s