Average Speed Calculator (A quick Plan)

Posted: February 25, 2012 in Kreeps
Tags: , , , ,

So when i read the rule book I already got a plan in mind about this task.

Since my aim was not to participate in the event I will keep work till calculating speed using Image Processing.

Glowing LEDs or displaying Speed in a small LCD could be easily done using Arduino Processor.

I used following things:1) Camera : Axis 207

2) Eclipse IDE (c++ developer)  with OpenCV

3) Platform : Ubuntu 10.04

This was what i thought first:

—>Read frames from Axis cam     —>   For the first frame segment Red And Green lines    —>    know the position of each pixel that represent Red line and same for Green line    —>    Now in next few frames check it there is any change in Red line    —>    As the change occurs note the system time    —>    Now check for any change in Green line    —>    As the change occurs again note the system time    —>    Now the time difference between above two times will give the time that objects take crossing the two lines    —>    now as we know the time and distance we can calculate the SPEED

The above was some random plan. obviously i would not have worked due to many reasons like a small mechanical vibrations of cam can even give wrong output.

then i came up with another plan (a little similar ):

—>Read frames from Axis cam     —>   For the first frame segment Red And Green lines    —>    Count the number of pixels each  that represent Red line and same for Green line  separately   —>    Now in next few frames check it there is any change in the count of pixels that represent  Red line    —>    As the change occurs note the system time    —>    Now check for any change in count of pixels that represent Green line    —>    As the change occurs again note the system time    —>    Now the time difference between above two times will give the time that objects take crossing the two lines    —>    now as we know the time and distance we can calculate the SPEED.

know for the change in number of pixels assume change to be large enough like around 100 pixels worked for me.

this would eliminate wrong output due to any small mechanical vibrations.

Now other challenge was to calculate time with accuracy. Using Time.h was good option for knowing the system time.

But i noticed  lags existed may be a millisecond small. But definitely these lags would result in wrong output for time (even if the time error in time is of few second or milisecond- it is wrong since we can have a better way out)

So i thought of another way for calculating time, since we know the fps (frame per second ) of the camera, we can simply calculate the number of frames recorded when object travels from Red line to Green line.

Now to know the time we can simple divide total frame by fps.

and so this is what i finally implemented.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s