You are on page 1of 5

Full Paper

Proc. of Int. Conf. on Advances in Electrical & Electronics 2012

Real-Time Vehicle Speed Detection Algorithm using

Motion Vector Technique
S. S. S. Ranjit, 1S. A. Anas, 2S. K. Subramaniam, 1K. C. Lim, 1A. F. I. Fayeez, 1A. R. Amirah
Universiti Teknikal Malaysia Melaka, Faculty of Electronics and Computer Engineering,
Department of Computer Engineering,
Department of Electronics Industry,
Hang Tuah Jaya, 76100 Durian Tunggal, Melaka, Malaysia.

Abstract Surveillance video camera monitoring system has II. BACKGROUND STUDY
gained a lot of interest among the research community
especially in monitoring vehicle speed. Apart from vehicle Numerous researches have been conducted in order to
speed detection, this algorithm can be used to monitor the detect or estimate the speed of a moving vehicle using the
traffic condition along the road or highway. The existing image processing technique. Research such as [1-4] presents
surveillance video cameras are rarely used to measure the various papers on the real-time vehicle detection and speed
vehicle speed and estimate the vehicle. A MATLAB algorithm estimation. Existing methods applied into vehicle speed
is proposed and developed to associate the developed algorithm detection, including speed detection based on digital aerial
with real-time video sequence and images. Development of images [5], combination value [6] and frame differencing [7]
vehicle speed detection algorithm is based on the vector-valued
to produce the most successful outcome. Digital aerial images
function and motion vector technique that estimates the
velocity of moving vehicle. [5, 8] or camera UltraCamd [9] is used in image processing
using the image extraction and detection visually and
Index Terms Speed Detection, Vehicle Detection, Vector- automated extraction and detection [5, 9]. The computed result
Valued Function, Vehicle Speed, Moving Vehicle is also compared with each other and is presented in [5, 9].


Block extraction and subtraction technique is known as
one of the simplest motion detection technique. This
technique has been adopted into video sequence coding for
vehicle speed detection based on current and previous
images. Each of the image is divided into non-overlapping
square blocks to compare with the respective blocks in the
current frame and previous image, each blocks are subtracted
to estimate the vehicle speed.

Figure 1. Motion detection block diagram

Fig. 1 system comprises of three elements for vehicle
speed detection and output is the estimated speed calculated.
Surveillance video camera is used as an input for this system
to capture the video and saved into a designated folder in
the hard drive. MATLAB is the main platform to develop the
vehicle speed detection algorithm. The vector-valued
function is used to analyze the changes in the block division
based on two consecutive images.
This paper presents a new vehicle speed detection
Figure 2. Algorithm development architecture for vehicle speed
MATLAB algorithm. This algorithm is to detect the vehicle detection
speed based on real-time video sequence through an offline
Video consists sequence of static images representing
based algorithm to reduce the elapsed processing time.
scenes in motion at one time [9]. The video encoding process
includes the transformation of the video into sequence of
static images. Two extracted images are selected to apply the

2012 ACEEE 67
DOI: 02.AETAEE.2012.3.37
Full Paper
Proc. of Int. Conf. on Advances in Electrical & Electronics 2012

motion estimation process in the developed MATLAB

algorithm. Fig. 2 describe the development process of vehicle
speed detection algorithm. Standalone images is segmented
into 16 16 small blocks using the division technique. Each
segmented block is extracted in the video coding to be
compared with respective to blocks in current image and
previous image. This blocks are compared to detect the
changes in pixels which is used to estimate the velocity of
the respective moving vehicle.
A. Video Image Processing
Figure 4. Block segmentation and extraction between two
respective images
Block subtraction = Block 2 Block 1 (1)

B. Vehicle Velocity Estimation

In image processing processes a video is extracted into
sequences of still images. The images are segmented into
region of interest known as 16 16 blocks. The motion vector
technique is applied after the block extraction and subtraction
is use to estimate the pixels changes among the two blocks
to measure the speed of the moving vehicle. The vector-
valued function is applied into the motion vector to
demonstrate the vehicle speed detection algorithm for the
video from surveillance cameras.

Figure 5. Two blocks A(r, s) and A (r, s) with motion vector MV

Figure 3. Vehicle speed detection algorithm organization (r, s) and MV (r, s) in current image
The algorithm ccomputational and elapsed processing Assume that the block size 16 16 simplified as below:
time to process the images increases, block extraction and Let A(r, s) denotes the block size W W in the r column and
subtraction technique [10] is applied into region of interest s row of the current frame.
which is block based estimate is concentrated instead the Let MV(r, s) = [MVx (r, s), MVy (r, s)]t denotes the motion
complete video sequence or images. vector of A(r, s).
Two blocks A(r, s) and A(r, s) in the current frame illustrated
in Fig. 5 when both lie on the same object.
Based on Fig. 5, the two blocks with motion vector is
(r W r W) [MVx (r, s)] [MVx (r, s)] + (s W s W) [MVy (r,
s)] [MVy (r, s)] = 0 (2)
2012 ACEEE 68
DOI: 02.AETAEE.2012.3.37
Full Paper
Proc. of Int. Conf. on Advances in Electrical & Electronics 2012

which can be further simplified as follows

[r r, ss] [MV (r,s) [MV(r,s)] = 0 (3)
The method denotes the general motion vector function.
This method is applied to analyze the moving vehicle from
Point A to Point B. The average motion velocity, V of moving
object through a displacement (d) during a time interval
(t) is described by the formula, V = (d) / (t) where:
V - the velocity
d - the change in displacement and
t - the change in time

Figure 7. Overview of vector-valued function to estimation

velocity of moving vehicle

Figure 6. Estimation of moving vehicle from point A to point B

If a moving vehicle travels from Point A to Point B at
distance of 30 meters in 3 seconds, the motion velocity is
calculated as following.
t0 = 0 seconds; t1 = 3 second (s)
t = t1-t0 = (3-0) second (s)
= 3second (s)
d = 30 meter (s)
V = (d)/(t) = 30 meter (s) / 3 second (s)
= 10 meter/second Figure 8. Vector velocity calculation and estimation
C. Vector-valued function for vehicle motion velocity Velocity, VR = (V1)2 + (V2)2
estimation = (V12 + V2)2
The vector-valued function is an important element in D. Digital Video Recorder (DVR) card setting
motion vector technique. One or more vector variables can In order to associate the sequence images with vector-
be verify using vector-valued function. The vector-valued valued function algorithms, a digital video recorder (DVR)
function is to verify the respective number of changes in card is required. The DVR card installation is to capture the
blocks within two consecutive images. The input of a vector- video from the surveillance cameras and save into a
valued function could be a scalar or a vector while the output designated folder in the hard drive. DVR cards come in
of vector-valued function is a vector. The vector-valued variations of up to 32 channels with various frame rates
function comprises of n scalar functions for each of the
depending on the record frames. Other than that, DVR card
coordinates in the image. The vehicle velocity calculation
has high compression rates and real-time video recording.
and estimation of the moving vehicle is achieved when vector-
DVR card can support recording qualities up to 60 frames per
valued function is applied.
seconds (fps).
The vector-valued function formula is described as r(t) =
1) Calculation for (DVR) card: Time for (DVR) card can
f (t) i + g(t) j + h(t) k where:
capture for 1 frame.
f, g and h are called scalar function
1 frame = 1 / 60 fps
r(t) is component function and
= 0.0167 second (s)
i, j and k are called unit vectors

60 frames per seconds (fps) 1 frame = 0.0167 seconds (s)

2012 ACEEE 69
DOI: 02.AETAEE.2012.3. 37
Full Paper
Proc. of Int. Conf. on Advances in Electrical & Electronics 2012

Velocity vector is divided by its length to obtain the tangent

vector. Tangent vector formula can be described as;


To further analyze these coordinates, time t needs to be

declared as a real symbolic variable. Next, define r, and take
its derivative. The equation differential equation is defined
by differentiating each coordinate with respect to the
parameter to obtain the vehicle velocity.
>> t=syms (t, real);
Figure 9. Motion of moving vehicle from Point A to Point B >> r=[t,t^2]
2) Distance estimation: Assume the velocity of moving >> rp=diff(r)
vehicle is at 110 kilometer per hour (km/h). Based on Fig. 11, the tangent vector unit is examined in
MATLAB. The vector-value function path is considered as
110 km/h = 110 1000 meter (m) r(t) = < t, t2 > and the time interval for tangent vector unit is [1,
60 60 seconds (s) 5].
= 110 000 meter (m) This following condition is associated with MATLAB
3600 seconds (s) commands;
= 30.56 meter per seconds (m/s) >> t=linspace(1,5);
Distance, d = 30.56 m/s 0.0167 s >> x=t; y=t.^2;
= 0.51 meter (m) >> plot(x,y)
In order to measure and estimate vehicle velocity, the
derivation of r(t) is calculated and the magnitude of the vehicle
velocity is obtained through calculations as shown.

In order to find the tangent vector unit, the vehicle velocity

is divided by the magnitude.
Figure 10. Moving vehicle from Point A to Point B at 0.51 meters

Vector-valued function can measure and estimate the
vehicle velocity as well as the magnitude of moving vehicle.
Velocity is known as vector while magnitude is an
instantaneous speed at magnitude of each point that has
direction of motion.
The following MATLAB commands are:
>> t=1:1:5;
>> x=t; y=t.^2;
>> xT=2./sqrt(4+16*t.^2);
>> yT=4*t./sqrt(4+16*t.^2);
>> quiver(x,y,xT,yT,0)

Motion vector technique can be involve into video-based
algorithm to measure and estimate moving vehicle velocity
as well as vehicle speed estimation can be determined through
video image processing. Existing algorithms and systems
involves come complicated computational processes which
are time consuming and required rapid maintenance for
operation. The existing surveillance cameras are not used to
analyze the images or estimate the vehicle speed and velocity.
Developing and integrating a MATLAB based algorithm to
Figure 11. Moving vehicle position and velocity vector from
process the video images to measure as well as estimate the
Point A to Point B
velocity of vehicles would reduce the previously developed
2012 ACEEE 70
DOI: 02.AETAEE.2012.3.37
Full Paper
Proc. of Int. Conf. on Advances in Electrical & Electronics 2012

algorithm shortfalls. [4] T. Kowsari, S. S. Beauchemin, J. Cho, Real-time Vehicle

Detection and Tracking Using Stereo Vision and Multi-View
ACKNOWLEDGMENT AdaBoost, 14th International IEEE Conference on Intelligent
Transportation Systems, pp. 1255-1260, 2011.
This research is funded by the Fundamental Research [5] Y. Fumio, L. Wen and T. V. Thuy, Vehicle Extraction And
Grant Scheme (FRGS) - Grant No: FRGS/1/2011/FKEKK/TK02/ Speed Detection From Digital Aerial Images IEEE
1 F00114, Malaysia. This research is conducted at Universiti International Geosciences and Remote Sensing Symposium,
Teknikal Malaysia Melaka. We would like to express our pp. 1134-1137, 2008.
gratitude to the Malaysia of Higher Education (MOHE) as [6] G. R. Arash, D. Abbas and R. K Mohamed, Vehicle speed
detection in video image sequence using CVS method
well as Universiti Teknikal Malaysia Melaka (UTeM) for the
International Journal of the Physical Sciences, Volume 5 (17),
funding. pp. 2555-2563, 2010.
[7] H. A. Rahim, U. U. Sheikh, R. B. Ahmad, A. S. M. Zain and
REFERENCES W. N. F. W. Ariffin, Vehicle Speed Detection Using Frame
Differencing for Smart Surveillance System 10th International
[1] Y. Zhang, C. Geng, D. Yao, L. Peng, Real-time Traffic Object
Conference on Information Science, Signal Processing and
Detection Technique Based on Improved Background
their Applications, 2010.
Differencing Algorithm, The 12 thWorld Conference on
[8] Y. Fumio, S. Daisuki and M. Yoshihisa, Use of Digital Aerial
Transportation Research, pp. 1-11, July 2010.
Images to Detect Damages Due to Earthquakes The 14th
[2] L. A. Alexandre, Aurlio C. Campilho, A 2D Image Motion
World Conference on Earthquake Engineering, October 2008.
Detection Method Using a Stationary Camera.
[9] Y. Fumio, L. Wen and T. V. Thuy, Automated Extraction of
[3] M. S. Temiz , S. Kulur, S. Dogan, Real Time Speed Estimation
Vehicle and their Speed from Digital Aerial Images, Proceeding
from Monocular Video, International Archives of the
27th Asian Conference on Remote Sensing, 6p, 2007.
Photogrammetry, Remote Sensing and Spatial Information
[10] S. S. S Ranjit, H. S. D. S. Jitvinder, K. C. Lim and A. J. Salim,
Sciences, pp. 427-432, 2012.
Motion Analysis for Real-Time Surveillance Video via Block
Pixel Analysis Technique Proceedings of 2011 International
Conference on Signal, Image Processing and Applications,
pp. 60-64, 2011.

2012 ACEEE 71
DOI: 02.AETAEE.2012.3.37