Internet of Smart-Cameras for Traffic Lights Optimization in Smart Cities

Abstract: Smart and decentralized control systems have recently been proposed to handle the growing traffic congestion in urban cities. Proposed smart traffic light solutions based on Wireless Sensor Network and Vehicular Ad-hoc NETwork are either unreliable and inflexible or complex and costly. Furthermore, the handling of special vehicles such as emergency is still not viable, especially during busy hours. Inspired by the emergence of distributed smart cameras, we present a novel approach to traffic control at intersections. Our approach uses smart cameras at intersections along with image understanding for real-time traffic monitoring and assessment. Besides understanding the traffic flow, the cameras can detect and track special vehicles and help prioritize emergency cases. Traffic violations can be identified as well and traffic statistics collected. In this paper, we introduce a flexible, adaptive and distributed control algorithm that uses the information provided by distributed smart cameras to efficiently control traffic signals. Experimental results show that our collision-free approach outperforms the state-of-the-art of the average user's waiting time in the queue and improves the routing of emergency vehicles in a cross congestion area.

\section{}

  \bibliographystyle{elsarticle-num}

\section{}
\label{}

\section{}
\label{}

\section{Introduction}

\file{elsarticle.cls} is a thoroughly re-written document class
for formatting \LaTeX{} submissions to Elsevier journals.
The class uses the environments and commands defined in \LaTeX{} kernel
without any change in the signature so that clashes with other
contributed \LaTeX{} packages such as \file{hyperref.sty},
\file{preview-latex.sty}, etc., will be minimal.
\file{elsarticle.cls} is primarily built upon the default
\file{article.cls}.  This class depends on the following packages
for its proper functioning:

\begin{enumerate}
\item \file{natbib.sty} for citation processing;
\item \file{geometry.sty} for margin settings;
\item \file{fleqn.clo} for left aligned equations;
\item \file{graphicx.sty} for graphics inclusion;
\item \file{txfonts.sty} optional font package, if the document is to
  be formatted with Times and compatible math fonts;
\item \file{hyperref.sty} optional packages if hyperlinking is
  required in the document;
\item \file{endfloat.sty} optional packages if floats to be placed at
 end of the PDF.
\end{enumerate}

All the above packages (except some optional packages) are part of any
standard \LaTeX{} installation. Therefore, the users need not be
bothered about downloading any extra packages.  Furthermore, users are
free to make use of \textsc{ams} math packages such as
\file{amsmath.sty}, \file{amsthm.sty}, \file{amssymb.sty},
\file{amsfonts.sty}, etc., if they want to.  All these packages work in
tandem with \file{elsarticle.cls} without any problems.

\section{Major Differences}

Following are the major differences between \file{elsarticle.cls}
and its predecessor package, \file{elsart.cls}:

\begin{enumerate}[\textbullet]
\item \file{elsarticle.cls} is built upon \file{article.cls}
while \file{elsart.cls} is not. \file{elsart.cls} redefines
many of the commands in the \LaTeX{} classes/kernel, which can
possibly cause surprising clashes with other contributed
\LaTeX{} packages;

\item provides preprint document formatting by default, and
optionally formats the document as per the final
style of models $1+$, $3+$ and $5+$ of Elsevier journals;

\item some easier ways for formatting \verb+list+ and
\verb+theorem+ environments are provided while people can still
use \file{amsthm.sty} package;

\item \file{natbib.sty} is the main citation processing package
  which can comprehensively handle all kinds of citations and
works perfectly with \file{hyperref.sty} in combination with
\file{hypernat.sty};

\item long title pages are processed correctly in preprint and
  final formats.

\end{enumerate}

\section{Installation}

The package is available at author resources page at Elsevier
(\url{http://www.elsevier.com/locate/latex}).
It can also be found in any of the nodes of the Comprehensive
\TeX{} Archive Network (\textsc{ctan}), one of the primary nodes
being
\url{http://tug.ctan.org/tex-archive/macros/latex/contrib/elsarticle/}.
Please download the \file{elsarticle.dtx} which is a composite
class with documentation and \file{elsarticle.ins} which is the
\LaTeX{} installer file. When we compile the
\file{elsarticle.ins} with \LaTeX{} it provides the class file,
\file{elsarticle.cls} by
stripping off all the documentation from the \verb+*.dtx+ file.
The class may be moved or copied to a place, usually,
\verb+$TEXMF/tex/latex/elsevier/+,
or a folder which will be read
by \LaTeX{} during document compilation.  The \TeX{} file
database needs updation after moving/copying class file.  Usually,
we use commands like \verb+mktexlsr+ or \verb+texhash+ depending
upon the distribution and operating system.

\section{Usage}\label{sec:usage}
The class should be loaded with the command:

\begin{vquote}
 \documentclass[<options>]{elsarticle}
\end{vquote}

\noindent where the \verb+options+ can be the following:

\begin{description}

\item [{\tt\color{verbcolor} preprint}]  default option which format the
  document for submission to Elsevier journals.

\item [{\tt\color{verbcolor} review}]  similar to the \verb+preprint+
option, but increases the baselineskip to facilitate easier review
process.

\item [{\tt\color{verbcolor} 1p}]  formats the article to the look and
feel of the final format of model 1+ journals. This is always single
column style.

\item [{\tt\color{verbcolor} 3p}] formats the article to the look and
feel of the final format of model 3+ journals. If the journal is a two
column model, use \verb+twocolumn+ option in combination.

\item [{\tt\color{verbcolor} 5p}] formats for model 5+ journals. This
is always of two column style.

\item [{\tt\color{verbcolor} authoryear}] author-year citation style of
\file{natbib.sty}. If you want to add extra options of
\file{natbib.sty}, you may use the options as comma delimited strings
as arguments to \verb+\biboptions+ command. An example would be:
\end{description}

\begin{vquote}
 \biboptions{longnamesfirst,angle,semicolon}
\end{vquote}

\begin{description}
\item [{\tt\color{verbcolor} number}] numbered citation style. Extra options
  can be loaded with\linebreak \verb+\biboptions+ command.

\item [{\tt\color{verbcolor} sort\&compress}] sorts and compresses the
numbered citations. For example, citation [1,2,3] will become [1--3].

\item [{\tt\color{verbcolor} longtitle}] if front matter is unusually long, use
  this option to split the title page across pages with the correct
placement of title and author footnotes in the first page.

\item [{\tt\color{verbcolor} times}] loads \file{txfonts.sty}, if
available in the system to use Times and compatible math fonts.

\item [{\tt\color{verbcolor} reversenotenum}] Use alphabets as
author--affiliation linking labels and use numbers for author
footnotes. By default, numbers will be used as author--affiliation
linking labels and alphabets for author footnotes.

\item [{\tt\color{verbcolor} lefttitle}] To move title and
author/affiliation block to flushleft. \verb+centertitle+ is the
default option which produces center alignment.

\item [{\tt\color{verbcolor} endfloat}] To place all floats at the end
of the document.

\item [{\tt\color{verbcolor} nonatbib}] To unload natbib.sty.

\item [{\tt\color{verbcolor} doubleblind}] To hide author name,
affiliation, email address etc. for double blind refereeing purpose.

\item[] All options of \file{article.cls} can be used with this
  document class.

\item[] The default options loaded are \verb+a4paper+, \verb+10pt+,
  \verb+oneside+, \verb+onecolumn+ and \verb+preprint+.

\end{description}

\section{Frontmatter}

There are two types of frontmatter coding:
\begin{enumerate}[(1)]
\item each author is
connected to an affiliation with a footnote marker; hence all
authors are grouped together and affiliations follow;
\pagebreak
\item authors of same affiliations are grouped together and the
relevant affiliation follows this group.
\end{enumerate}

An example of coding the first type is provided below.

\begin{vquote}
 \title{This is a specimen title\tnoteref{t1,t2}}
 \tnotetext[t1]{This document is the results of the research
    project funded by the National Science Foundation.}
 \tnotetext[t2]{The second title footnote which is a longer
    text matter to fill through the whole text width and
    overflow into another line in the footnotes area of the
    first page.}
\end{vquote}

\begin{vquote}
\author[1]{Jos Migchielsen\corref{cor1}%
  \fnref{fn1}}
\ead{J.Migchielsen@elsevier.com}

\author[2]{CV Radhakrishnan\fnref{fn2}}
\ead{cvr@sayahna.org}

\author[3]{CV Rajagopal\fnref{fn1,fn3}}
\ead[url]{www.stmdocs.in}
\end{vquote}

\begin{vquote}
 \cortext[cor1]{Corresponding author}
 \fntext[fn1]{This is the first author footnote.}
 \fntext[fn2]{Another author footnote, this is a very long
   footnote and it should be a really long footnote. But this
   footnote is not yet sufficiently long enough to make two
   lines of footnote text.}
 \fntext[fn3]{Yet another author footnote.}

 \address[1]{Elsevier B.V., Radarweg 29, 1043 NX Amsterdam,
   The Netherlands}
 \address[2]{Sayahna Foundations, JWRA 34, Jagathy,
   Trivandrum 695014, India}
 \address[3]{STM Document Engineering Pvt Ltd., Mepukada,
   Malayinkil, Trivandrum 695571, India}
\end{vquote}

The output of the above \TeX{} source is given in Clips~\ref{clip1} and
\ref{clip2}. The header portion or title area is given in
Clip~\ref{clip1} and the footer area is given in Clip~\ref{clip2}.

\deforange{blue!70}
\src{Header of the title page.}
\includeclip{1}{130 612 477 707}{1psingleauthorgroup.pdf
\deforange{orange}

\deforange{blue!70}
\src{Footer of the title page.}
\includeclip{1}{93 135 499 255}{1pseperateaug.pdf
\deforange{orange}

Most of the commands such as \verb+\title+, \verb+\author+,
\verb+\address+ are self explanatory.  Various components are
linked to each other by a label--reference mechanism; for
instance, title footnote is linked to the title with a footnote
mark generated by referring to the \verb+\label+ string of
the \verb=\tnotetext=.  We have used similar commands
such as \verb=\tnoteref= (to link title note to title);
\verb=\corref= (to link corresponding author text to
corresponding author); \verb=\fnref= (to link footnote text to
the relevant author names).  \TeX{} needs two compilations to
resolve the footnote marks in the preamble part.
Given below are the syntax of various note marks and note texts.

\begin{vquote}
  \tnoteref{<label(s)>}
  \corref{<label(s)>}
  \fnref{<label(s)>}
  \tnotetext[<label>]{<title note text>}
  \cortext[<label>]{<corresponding author note text>}
  \fntext[<label>]{<author footnote text>}
\end{vquote}

\noindent where \verb=<label(s)>= can be either one or more comma
delimited label strings. The optional arguments to the
\verb=\author= command holds the ref label(s) of the address(es)
to which the author is affiliated while each \verb=\address=
command can have an optional argument of a label. In the same
manner, \verb=\tnotetext=, \verb=\fntext=, \verb=\cortext= will
have optional arguments as their respective labels and note text
as their mandatory argument.

The following example code provides the markup of the second type
of author-affiliation.

\begin{vquote}
\author{Jos Migchielsen\corref{cor1}%
  \fnref{fn1}}
\ead{J.Migchielsen@elsevier.com}
 \address{Elsevier B.V., Radarweg 29, 1043 NX Amsterdam,
          The Netherlands}

\author{CV Radhakrishnan\fnref{fn2}}
\ead{cvr@sayahna.org}
 \address{Sayahna Foundations, JWRA 34, Jagathy,
    Trivandrum 695014, India}

\author{CV Rajagopal\fnref{fn1,fn3}}
\ead[url]{www.stmdocs.in}
  \address{STM Document Engineering Pvt Ltd., Mepukada,
    Malayinkil, Trivandrum 695571, India}
\end{vquote}

\vspace*{-.5pc}

\begin{vquote}
\cortext[cor1]{Corresponding author}
\fntext[fn1]{This is the first author footnote.}
\fntext[fn2]{Another author footnote, this is a very long
  footnote and it should be a really long footnote. But this
  footnote is not yet sufficiently long enough to make two lines
  of footnote text.}
\end{vquote}

The output of the above \TeX{} source is given in Clip~\ref{clip3}.

\deforange{blue!70}
\src{Header of the title page..}
\includeclip{1}{119 563 468 709}{1pseperateaug.pdf
\deforange{orange}
\pagebreak

Clip~\ref{clip4} shows the output after giving \verb+doubleblind+ class option.

\deforange{blue!70}
\src{Double blind article}
\includeclip{1}{124 567 477 670}{elstest-1pdoubleblind.pdf
\deforange{orange}

\vspace*{-.5pc}
The frontmatter part has further environments such as abstracts and
keywords.  These can be marked up in the following manner:

\begin{vquote}
 \begin{abstract}
  In this work we demonstrate the formation of a new type of
  polariton on the interface between a ....
 \end{abstract}
\end{vquote}

\vspace*{-.5pc}
\begin{vquote}
 \begin{keyword}
  quadruple exiton \sep polariton \sep WGM
 \end{keyword}
\end{vquote}

\noindent Each keyword shall be separated by a \verb+\sep+ command.
\textsc{msc} classifications shall be provided in
the keyword environment with the commands
\verb+\MSC+. \verb+\MSC+ accepts an optional
argument to accommodate future revisions.
eg., \verb=\MSC[2008]=. The default is 2000.\looseness=-1

\subsection{New page}
Sometimes you may need to give a page-break and start a new page after
title, author or abstract. Following commands can be used for this
purpose.

\begin{vquote}
  \newpageafter{title}
  \newpageafter{author}
  \newpageafter{abstract}
\end{vquote}

\begin{itemize}
\leftskip-2pc
\item [] {\tt\color{verbcolor} \verb+\newpageafter{title}+} typeset the title alone on one page.

\item [] {\tt\color{verbcolor} \verb+\newpageafter{author}+}  typeset the title
and author details on one page.

\item [] {\tt\color{verbcolor} \verb+\newpageafter{abstract}+}
typeset the title,
author details and abstract \& keywords one one page.

\end{itemize}

\section{Floats}
{Figures} may be included using the command, \verb+\includegraphics+ in
combination with or without its several options to further control
graphic. \verb+\includegraphics+ is provided by \file{graphic[s,x].sty}
which is part of any standard \LaTeX{} distribution.
\file{graphicx.sty} is loaded by default. \LaTeX{} accepts figures in
the postscript format while pdf\LaTeX{} accepts \file{*.pdf},
\file{*.mps} (metapost), \file{*.jpg} and \file{*.png} formats.
pdf\LaTeX{} does not accept graphic files in the postscript format.

The \verb+table+ environment is handy for marking up tabular
material. If users want to use \file{multirow.sty},
\file{array.sty}, etc., to fine control/enhance the tables, they
are welcome to load any package of their choice and
\file{elsarticle.cls} will work in combination with all loaded
packages.

\section[Theorem and ...]{Theorem and theorem like environments}

\file{elsarticle.cls} provides a few shortcuts to format theorems and
theorem-like environments with ease. In all commands the options that
are used with the \verb+\newtheorem+ command will work exactly in the same
manner. \file{elsarticle.cls} provides three commands to format theorem or
theorem-like environments:

\begin{vquote}
 \newtheorem{thm}{Theorem}
 \newtheorem{lem}[thm]{Lemma}
 \newdefinition{rmk}{Remark}
 \newproof{pf}{Proof}
 \newproof{pot}{Proof of Theorem \ref{thm2}}
\end{vquote}

The \verb+\newtheorem+ command formats a
theorem in \LaTeX's default style with italicized font, bold font
for theorem heading and theorem number at the right hand side of the
theorem heading.  It also optionally accepts an argument which
will be printed as an extra heading in parentheses.

\begin{vquote}
  \begin{thm}
   For system (8), consensus can be achieved with
   $\|T_{\omega z}$
   ...
     \begin{eqnarray}\label{10}
     ....
     \end{eqnarray}
  \end{thm}
\end{vquote}

Clip~\ref{clip5} will show you how some text enclosed between the
above code\goodbreak \noindent looks like:

\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newtheorem}}
\includeclip{2}{1 1 453 120}{jfigs.pdf}
\deforange{orange}

The \verb+\newdefinition+ command is the same in
all respects as its\linebreak \verb+\newtheorem+ counterpart except that
the font shape is roman instead of italic.  Both
\verb+\newdefinition+ and \verb+\newtheorem+ commands
automatically define counters for the environments defined.

\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newdefinition}}
\includeclip{1}{1 1 453 105}{jfigs.pdf}
\deforange{orange}

The \verb+\newproof+ command defines proof environments with
upright font shape.  No counters are defined.

\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newproof}}
\includeclip{3}{1 1 453 65}{jfigs.pdf}
\deforange{orange}

Users can also make use of \verb+amsthm.sty+ which will override
all the default definitions described above.

\section[Enumerated ...]{Enumerated and Itemized Lists}
\file{elsarticle.cls} provides an extended list processing macros
which makes the usage a bit more user friendly than the default
\LaTeX{} list macros.   With an optional argument to the
\verb+\begin{enumerate}+ command, you can change the list counter
type and its attributes.

\begin{vquote}
 \begin{enumerate}[1.]
 \item The enumerate environment starts with an optional
   argument `1.', so that the item counter will be suffixed
   by a period.
 \item You can use `a)' for alphabetical counter and '(i)' for
   roman counter.
  \begin{enumerate}[a)]
    \item Another level of list with alphabetical counter.
    \item One more item before we start another.
\end{vquote}

\deforange{blue!70}
\src{List -- Enumerate}
\includeclip{4}{1 1 453 185}{jfigs.pdf}
\deforange{orange}

Further, the enhanced list environment allows one to prefix a
string like `step' to all the item numbers.

\begin{vquote}
 \begin{enumerate}[Step 1.]
  \item This is the first step of the example list.
  \item Obviously this is the second step.
  \item The final step to wind up this example.
 \end{enumerate}
\end{vquote}

\deforange{blue!70}
\src{List -- enhanced}
\includeclip{5}{1 1 313 83}{jfigs.pdf}
\deforange{orange}

\section{Cross-references}
In electronic publications, articles may be internally
hyperlinked. Hyperlinks are generated from proper
cross-references in the article.  For example, the words
\textcolor{black!80}{Fig.~1} will never be more than simple text,
whereas the proper cross-reference \verb+\ref{tiger}+ may be
turned into a hyperlink to the figure itself:
\textcolor{blue}{Fig.~1}.  In the same way,
the words \textcolor{blue}{Ref.~[1]} will fail to turn into a
hyperlink; the proper cross-reference is \verb+\cite{Knuth96}+.
Cross-referencing is possible in \LaTeX{} for sections,
subsections, formulae, figures, tables, and literature
references.

\section[Mathematical ...]{Mathematical symbols and formulae}

Many physical/mathematical sciences authors require more
mathematical symbols than the few that are provided in standard
\LaTeX. A useful package for additional symbols is the
\file{amssymb} package, developed by the American Mathematical
Society. This package includes such oft-used symbols as
$\lesssim$ (\verb+\lesssim+), $\gtrsim$ (\verb+\gtrsim+)  or
$\hbar$ (\verb+\hbar+). Note that your \TeX{}
system should have the \file{msam} and \file{msbm} fonts installed. If
you need only a few symbols, such as $\Box$ (\verb+\Box+), you might try the
package \file{latexsym}.

Another point which would require authors' attention is the
breaking up of long equations.  When you use
\file{elsarticle.cls} for formatting your submissions in the
\verb+preprint+ mode, the document is formatted in single column
style with a text width of 384pt or 5.3in.  When this document is
formatted for final print and if the journal happens to be a double column
journal, the text width will be reduced to 224pt at for 3+
double column and 5+ journals respectively. All the nifty
fine-tuning in equation breaking done by the author goes to waste in
such cases.  Therefore, authors are requested to check this
problem by typesetting their submissions in final format as well
just to see if their equations are broken at appropriate places,
by changing appropriate options in the document class loading
command, which is explained in section~\ref{sec:usage},
\nameref{sec:usage}. This allows authors to fix any equation breaking
problem before submission for publication.
\file{elsarticle.cls} supports formatting the author submission
in different types of final format.  This is further discussed in
section \ref{sec:final}, \nameref{sec:final}.

\subsection*{Displayed equations and double column journals}

Many Elsevier journals print their text in two columns. Since
the preprint layout uses a larger line width than such columns,
the formulae are too wide for the line width in print. Here is an
example of an equation  (see equation 6) which is perfect in a
single column preprint format:

\bigskip
\setlength\Sep{6pt}
\src{See equation (6)}
\deforange{blue!70}
\includeclip{4}{105 500 500 700}{1psingleauthorgroup.pdf}
\deforange{orange}

\noindent When this document is typeset for publication in a
model 3+ journal with double columns, the equation will overlap
the second column text matter if the equation is not broken at
the appropriate location.

\vspace*{6pt}
\deforange{blue!70}
\src{See equation (6) overprints into second column}
\includeclip{3}{59 421 532 635}{elstest-3pd.pdf}
\deforange{orange}
\vspace*{6pt}

\noindent The typesetter will try to break the equation which
need not necessarily be to the liking of the author or as it
happens, typesetter's break point may be semantically incorrect.
Therefore, authors may check their submissions for the incidence
of such long equations and break the equations at the correct
places so that the final typeset copy will be as they wish.

\section{Bibliography}

Three bibliographic style files (\verb+*.bst+) are provided ---
\file{elsarticle-num.bst}, \file{elsarticle-num-names.bst} and
\file{elsarticle-harv.bst} --- the first one can be used for the
numbered scheme, second one for numbered with new options of
\file{natbib.sty}. The third one is for the author year
scheme.

In \LaTeX{} literature, references are listed in the
\verb+thebibliography+ environment.  Each reference is a
\verb+\bibitem+ and each \verb+\bibitem+ is identified by a label,
by which it can be cited in the text:

\verb+\bibitem[Elson et al.(1996)]{ESG96}+ is cited as
\verb+\citet{ESG96}+.

\noindent In connection with cross-referencing and
possible future hyperlinking it is not a good idea to collect
more that one literature item in one \verb+\bibitem+.  The
so-called Harvard or author-year style of referencing is enabled
by the \LaTeX{} package \file{natbib}. With this package the
literature can be cited as follows:

\begin{enumerate}[\textbullet]
\item Parenthetical: \verb+\citep{WB96}+ produces (Wettig \& Brown, 1996).
\item Textual: \verb+\citet{ESG96}+ produces Elson et al. (1996).
\item An affix and part of a reference:
\verb+\citep[e.g.][Ch. 2]{Gea97}+ produces (e.g. Governato et
al., 1997, Ch. 2).
\end{enumerate}

In the numbered scheme of citation, \verb+\cite{<label>}+ is used,
since \verb+\citep+ or \verb+\citet+ has no relevance in the numbered
scheme.  \file{natbib} package is loaded by \file{elsarticle} with
\verb+numbers+ as default option.  You can change this to author-year
or harvard scheme by adding option \verb+authoryear+ in the class
loading command.  If you want to use more options of the \file{natbib}
package, you can do so with the \verb+\biboptions+ command, which is
described in the section \ref{sec:usage}, \nameref{sec:usage}.  For
details of various options of the \file{natbib} package, please take a
look at the \file{natbib} documentation, which is part of any standard
\LaTeX{} installation.

In addition to the above standard \verb+.bst+ files, there are 10
journal-specific \verb+.bst+ files also available.
Instruction for using these \verb+.bst+ files can be found at
\href{http://support.stmdocs.in/wiki/index.php?title=Model-wise_bibliographic_style_files}
{http://support.stmdocs.in}

\section{Graphical abstract and highlights}
A template for adding graphical abstract and highlights are available
now. This will appear as the first two pages of the PDF before the
article content begins.

\pagebreak
Please refer below to see how to code them.

\begin{vquote}
....
....

\end{abstract}

\begin{graphicalabstract}
\end{graphicalabstract}

\begin{highlights}
\item Research highlight 1
\item Research highlight 2
\end{highlights}

\begin{keyword}
....
....
\end{vquote}

\section{Final print}\label{sec:final}

The authors can format their submission to the page size and margins
of their preferred journal.  \file{elsarticle} provides four
class options for the same. But it does not mean that using these
options you can emulate the exact page layout of the final print copy.

\lmrgn=3em
\begin{description}
\item [\texttt{1p}:] $1+$ journals with a text area of
384pt $\times$ 562pt or 13.5cm $\times$ 19.75cm or 5.3in $\times$
7.78in, single column style only.

\item [\texttt{3p}:] $3+$ journals with a text area of 468pt
$\times$ 622pt or 16.45cm $\times$ 21.9cm or 6.5in $\times$
8.6in, single column style.

\item [\texttt{twocolumn}:] should be used along with 3p option if the
journal is $3+$ with the same text area as above, but double column
style.

\item [\texttt{5p}:] $5+$ with text area of 522pt $\times$
682pt or 18.35cm $\times$ 24cm or 7.22in $\times$ 9.45in,
double column style only.
\end{description}

Following pages have the clippings of different parts of
the title page of different journal models typeset in final
format.

Model $1+$ and $3+$  will have the same look and
feel in the typeset copy when presented in this document. That is
also the case with the double column $3+$ and $5+$ journal article
pages. The only difference will be wider text width of
higher models.  Therefore we will look at the
different portions of a typical single column journal page and
that of a double column article in the final format.

\begin{center}
\hypertarget{bsc}{}
\hyperlink{sc}{
{\bf [Specimen single column article -- Click here]}
}

\hypertarget{bsc}{}
\hyperlink{dc}{
{\bf [Specimen double column article -- Click here]}
}
\end{center}

\src{}\hypertarget{sc}{}
\deforange{blue!70}
\hyperlink{bsc}{\includeclip{1}{88 120 514 724}{elstest-1p.pdf}}
\deforange{orange}

\src{}\hypertarget{dc}{}
\deforange{blue!70}
\hyperlink{bsc}{\includeclip{1}{27 61 562 758}{elstest-5p.pdf}}
\deforange{orange}

\end{document}

\section{Introduction}
\label{sec:introduction}
The rapid growth in urbanization is leading to a tremendous increase in automobiles in cities\cite{hopkins2019investigating}. Unfortunately, infrastructure development has not kept up with the growth in transportation. With lack and limited availability of public transportation, traffic congestion on public roads during rush hours has become a critical problem in many countries. This problem will be unmanageable if no effort is undertaken \cite{Wan2017}\cite{Pattanaik2016}. Congestion results from traffic demand that approaches or exceeds the capacity of the available infrastructure. There are essentially two categories of traffic congestion: 1) \textbf{recurring} traffic congestion that appears at the same place and the same time every day and 2) \textbf{non-recurring} traffic congestion caused by a random unplanned event or temporary disruptions that take away part of the roadway.
The US Federal Highway Administration defines six sources of congestion\cite{fhwa20132013} as shown in Table \ref{SourceCongestion}. Figure \ref{sourceCongestionByType} shows the sources of congestion and their contribution to congestion in percent on y-axes.

\begin{table}[!h]
\scriptsize
\caption{Congestion sources and terms.}
\label{SourceCongestion}
\centering
\begin{tabular}{@{}ll@{}}
\toprule
\textbf{Termed} & \textbf{Source } \\ \midrule
Bottlenecks & \begin{tabular}[c]{@{}l@{}}Road with inadequate physical capacity   \\ (roadway narrows, enclave).\end{tabular} \\ \\
Traffic incidents & Vehicles crashes and stalls. \\ \\
Work area & \begin{tabular}[c]{@{}l@{}} Road repairs, building of new roads and \\ maintenance activities. \end{tabular} \\ \\
Bad weather & Flood, snowfall and fog. \\ \\
Rare Events & Strikes and marathons. \\ \\
Poor signal timings & \begin{tabular}[c]{@{}l@{}}Empty lane with green light \cite{srivastava2013intelligent} and time allocated \\  with respect to the volume of the traffic on the  lane.\end{tabular} \\ \bottomrule
\end{tabular}
\end{table}
Recurring and non-recurring traffic congestion
contribute to urban traffic congestion at almost the same rate. Heavy traffic congestion leads to waste of time, increase pollution, waste of fuel, increased cost of transportation and driving-related stress, inefficient supply chains \cite{hopkins2014alleviating}, with an adverse effect on the economy \cite{fhwa20132013}\cite{emo2016slow}\cite{loong2017time}.
Intelligent Traffic Management System can alleviate traffic congestion by 1) collecting traffic data in real-time at intersection, for instance through the use of Wireless Sensor Networks (WSNs) \cite{Sherif2014}, RFIDs, ZigBee \cite{zigbee2010}, Vehicular ad-hoc NETwork(VANETs) \cite{VANET2019}, Bluetooth devices and cameras and infrared signals, whereas WSNs have gained increasing attention in traffic detection and avoiding road congestion \cite{nellore2016survey}; 2) using adaptive algorithm to control traffic with the goal of minimizing the average waiting time in queues of users; 3) incorporating a mechanism to allow emergency vehicles to easily cross congestion areas.

  \begin{figure}[!h]
\centering
 \captionsetup{justification=centering}
\includegraphics[width=0.8\linewidth]{images/trafficType.png}
\caption{Traffic congestion contribution as a percentage of congestion source.}
\label{sourceCongestionByType}
\end{figure}

\begin{comment}
\begin{minipage}[c]{.6\textwidth}

  \captionof{table}{Congestion sources and terms.}
  \label{SourceCongestion}
\tiny
 \begin{tabular}{@{}ll@{}}
\toprule
\textbf{Termed} & \textbf{Source } \\ \midrule
Bottlenecks & \begin{tabular}[c]{@{}l@{}}Road with inadequate physical capacity   \\ (roadway narrows, enclave).\end{tabular} \\
Traffic incidents & Vehicles crashes and stalls. \\
Work area & \begin{tabular}[c]{@{}l@{}} Road repairs, building of new roads and \\ maintenance activities. \end{tabular} \\
Bad weather & Flood, snowfall and fog. \\
Rare Events & Strikes and marathons. \\
Poor signal timings & \begin{tabular}[c]{@{}l@{}}Empty lane with green light \cite{srivastava2013intelligent} and time allocated \\  with respect to the volume of the traffic on the  lane.\end{tabular} \\ \bottomrule
\end{tabular}
\end{minipage}%
\begin{minipage}[c]{0.4\textwidth}
  \centering
   \captionsetup{justification=centering}
  \includegraphics[width=0.8\linewidth]{images/trafficType.png}

  \captionof{figure}{Traffic congestion contribution as a percentage of congestion source.\\}\label{sourceCongestionByType}
\end{minipage}
\end{comment}

Despite various techniques and research for alleviating traffic congestion including "anywhere working" \cite{hopkins2019investigating}, "Markov chain traffic assignment" \cite{salman2018alleviating}, and government's policies such as congestion pricing, driving restrictions, vehicle purchase restrictions, and public transit investment, the Intelligent Traffic Management System (ITMS) \cite{ITMS2014} continues to face  significant challenges  namely:
\begin{itemize}
\item  Congestion : can ITMS  react quickly to non-recurring congestion problem.
\item  Traffic incident notification (Traffic violations, traffic rules) : can  ITMS  send real-time information to police  to act upon the situation.
\item How to maintain coordination between intersections for a safety smart city.
\end{itemize}

Table \ref{summaryWSN} presents several technologies used for traffic control. Most of those systems rely  on Wireless Sensor Network (WSN) for traffic control coupled with cameras for video surveillance \cite{Franceschinis2009}. These methods are tedious and involve a large amount of hardware.

In this paper, we propose a new and versatile method that uses distributed smart cameras along with advance image understanding to supply the waiting queue in real-time with traffic data (vehicles count, types, density, etc...). This information can then be used by a central authority to control the whole traffic infrastructure. Figure \ref{smartCity} shows an example of smart city with multiple connected infrastructure, including traffic light.

\begin{figure}[!h]
\centering
 \captionsetup{justification=centering}
\includegraphics[width=0.8\linewidth]{images/smartCity.jpg}
\caption{Smart city configuration with smart infrastructure, cloud-based data collection and decision making.}
\label{smartCity}
\end{figure}

Data collected from those infrastructures are sent to the could for analysis and decision making. In the specific case of traffic, data collected from all traffic light can be used for inter-intersection control, tracking of special vehicles, traffic offenders and address the non-recurring congestion area by changing traffic rules of the adjacent intersections. The current paper focuses on smart control at road-intersections. The global management of the infrastructure and decision making in the whole context of a smart city is not in the scope of this work and will be addressed in future research.

The rest of the paper is organized as follows. Section \ref{sec:related} discusses the related work. In section \ref{sec:design}, we describe our modeling system. In sections \ref{sec:algorithm}, \ref{sec:wait}, and \ref{sec:distributed}, we explain our implemented algorithm, and the simulation and results in section \ref{sec:simulation}.

\section{ Related Works}\label{sec:related}
In this section, we discuss related work on smart traffic control. We divide the work in two categories: data collection and traffic control solutions.

\subsection{Traffic Data Collection Technologies}
In \cite{padmavathi2010study}, a review of technologies for traffic data at the intersections is performed. For each technology, the authors consider the ability to count vehicles, detect vehicles, detect the speed of vehicles and the ability to distinguish different vehicle types. The authors also consider whether the technology could be used in a  multi-lane scenario, and the bandwidth required to communicate the information to a central control. The summary of the survey is shown in table  \ref{summaryWSN}.

\begin{table*}[!h]
\caption{Technology along with traffic data collected \cite{padmavathi2010study}.}
\centering
\scriptsize
\begin{tabular}{@{}llllllll@{}}
\toprule
\multicolumn{1}{c}{\textbf{Technology}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Vehicle \\ Count\end{tabular}}} & \multicolumn{1}{c}{\textbf{Presence}} & \multicolumn{1}{c}{\textbf{Speed}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Output \\ Data\end{tabular}}} & \multicolumn{1}{c}{\textbf{Classification}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Multiple Lane, \\ Multiple Detection\\  Zone Data\end{tabular}}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Communication\\  Bandwidth\end{tabular}}} \\ \midrule
\textbf{Inductive loop} & $\surd$ & $\surd$ & $\surd$ * & $\surd$ & $\surd$ \& &  & Low to modest \\
\textbf{Magnetometer} & $\surd$ & $\surd$ & $\surd$ * & $\surd$ &  &  & Low \\
\textbf{Magnetic induction coil} & $\surd$ & $\surd$ \$ & $\surd$ * & $\surd$ &  &  & Low \\
\textbf{Microwave radar} & $\surd$ & $\surd$  \# & $\surd$ & $\surd$ \# & $\surd$ \# & $\surd$ \# & Moderate \\
\textbf{Active infrared} & $\surd$ & $\surd$ & $\surd$ @ & $\surd$ & $\surd$ & $\surd$ & Low to modest \\
\textbf{Passive infrared} & $\surd$ & $\surd$ & $\surd$ @ & $\surd$ &  &  & Low to modest \\
\textbf{Ultrasonic} & $\surd$ & $\surd$ &  & $\surd$ &  &  & Low \\
\textbf{Acoustic array} & $\surd$ & $\surd$ & $\surd$ & $\surd$ &  & $\surd$  \textasciicircum{} & Low to modest \\
\textbf{Video image processor} & $\surd$ & $\surd$ & $\surd$ & $\surd$ & $\surd$ & $\surd$ & Low to high \\
 &  &  &  &  &  &  &  \\
\multicolumn{8}{c}{\begin{tabular}[c]{@{}c@{}}* Two sensors can be used to measure speed; \& With specific electronics device that categorizes vehicles;\\  \$ By using distinct sensor layouts and data processing software; \# By using a microwave radar sensor and suitable signal processing unit; \\ @ With multi detection region; \textasciicircum By suitable beam forming models and data processing unit\end{tabular}.} \\ \bottomrule
\end{tabular}
\label{summaryWSN}
\end{table*}

 The presented technologies are not suitable to detect special vehicles such as emergency and police cars. Furthermore, to detect the entire intersection, multiple sensor nodes must be deployed to increase coverage. As a result, efficient coordination with the central system becomes very challenging. Our approach in this work is base on video, which is free of the previous-mentioned challenges.

\subsection{Traffic Control Algorithm }
There is a large amount of literature on the subject of traffic control algorithms. We provide an overview of the representative examples. \par In \cite{faye2012distributed}, the authors propose WSN architecture and an algorithm for controlling green lights on a single intersection. Their solution is designed for an isolated intersection and reduces waiting times without introducing congestion.
 \par  The approach has been extended in \cite{faye2012distributed2} to an algorithm called TAPIOCA
\textit{(distribuTed and Adaptative IntersectiOns Control Algorithm)} that considers multiple adjacent intersections that communicate with adjacent intersections using WSN. \par In \cite{faye2014multiple}, an improvement of TAPIOCA was proposed for the multi-intersection case by defining mechanisms to ease offloading between close intersections and to create green waves. In \cite{wu2015distributed}, a novel approach to traffic control at the intersection was proposed. Rather than solving the optimization problem of green light scheduling, vehicles compete for the privilege of passing by exchanging messages. In this case, the vehicles must have an extra device that allows them to communicate. \par In \cite{wongpiromsarn2012distributed}, an adaptive algorithm was proposed from the back-pressure routing, which has been mainly applied to communication and power networks. In \cite{yousef2010intelligent}, an adaptive traffic control for both single and multiples intersections was proposed. \par In \cite{nellore2016survey} a survey has been made on adaptive algorithms for traffic control. However, these approaches haven't considered the priority for emergency vehicles, and in case of changing traffic rules or maintenance at the intersection, the algorithm fails to adapt.

In general, algorithms that rely on WSN for collection of traffic data are not resilient to certain critical scenarios such as changing the highway code at the intersection, maintenance work on pavement. Furthermore, they do not provide a safety gateway to act under certain critical cases occurring at the intersection remotely. The approach we present in this work is resilient capable of withstanding several critical cases that the existing approach cannot handle.

\section{Design and Modeling}
\label{sec:design}
In this section, we will first describe the component of traffic light system we intend to optimize. A description of our overall control architecture will follow.

\subsection{Ecosystem}
The intersections considered in this way are 4-way right-side driving intersections. Each way has the three-color traffic light located at the right top and a smart camera installed in the face of the road. All possible movements are allowed.  An intersection is where multiple roads cross. A road is a set of lanes.
\begin{figure*}[!h]

\centering
 \captionsetup{justification=centering}
\includegraphics[width=1\linewidth]{images/Drawing6125.jpg}
\caption{Distributed Smart-Camera based ITMS.}
\label{Eco}
\end{figure*}
Figure \ref{Eco} shows an intersection with four lanes marked N (North), S(South), W (West) and E (East) that intersect. Each path has three lanes in the incoming direction, which are turn-left(L), go-forward (F) and turn-right(R). A passing vehicle can have a path P of $\{E,S,N,W\}$ and a direction D of $\{L,F,R\}$. Thus, a lane that has a vehicle can be determined by a pair of $\{P,D\}$. There are twelve lanes with labels pair $(P,D):\{WR, WF, WL, ER, EF, EL, NR, NF, NL, SR, SF, SL\}$.
Modeling the intersection to comply with road regulations is provided in the following table.
\begin{table}[!h]
\scriptsize
\caption{Matrix of conflict.}
\label{table:conflictMatrix}
\centering
\begin{adjustbox}{width=.5\textwidth}
\begin{tabular}{ccccccccccccc}
\hline
\multicolumn{1}{|c|}{\textbf{}} & \multicolumn{1}{c|}{\textbf{WR}} & \multicolumn{1}{c|}{\textbf{WF}} & \multicolumn{1}{c|}{\textbf{WL}} & \multicolumn{1}{c|}{\textbf{ER}} & \multicolumn{1}{c|}{\textbf{EF}} & \multicolumn{1}{c|}{\textbf{EL}} & \multicolumn{1}{c|}{\textbf{NR}} & \multicolumn{1}{c|}{\textbf{NF}} & \multicolumn{1}{c|}{\textbf{NL}} & \multicolumn{1}{c|}{\textbf{SR}} & \multicolumn{1}{c|}{\textbf{SF}} & \multicolumn{1}{c|}{\textbf{SL}} \\ \hline
\multicolumn{1}{|c|}{\textbf{WR}} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\ \hline
\multicolumn{1}{|c|}{\textbf{WF}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{WL}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{ER}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} \\ \hline
\multicolumn{1}{|c|}{\textbf{EF}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{EL}} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{NR}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{NF}} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} \\ \hline
\multicolumn{1}{|c|}{\textbf{NL}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} \\ \hline
\multicolumn{1}{|c|}{\textbf{SR}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\ \hline
\multicolumn{1}{|c|}{\textbf{SF}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} & \multicolumn{1}{c|}{} \\ \hline
\multicolumn{1}{|c|}{\textbf{SL}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{$\otimes$} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor[HTML]{FE0000}} \\ \hline
\textbf{} &  &  &  &  &  &  &  &  &  &  &  &  \\
\textbf{} &  & $\otimes$ & \multicolumn{2}{l}{\textit{\textbf{Not Allowed}}} &  &  &  & \cellcolor[HTML]{FE0000} & \multicolumn{3}{c}{\textit{\textbf{Illegal Case}}} &
\end{tabular}
\end{adjustbox}
\label{MatrixCon}
\end{table}

Table \ref{MatrixCon}  shows  conflict direction matrix \cite{yousef2010intelligent} . An empty box $\{ blank\}$  means that both lanes can proceed without a possibility of collision. A crossed circle $\{ \otimes\}$ means that a collision may occur if both lanes are allowed to proceed. Because of this possibility of collision, lanes that have a crossed circle will not be allowed to proceed simultaneously.

\begin{figure}[!h]
        \centering
        \includegraphics[width=0.5\linewidth]{images/smart-camera-setup.PNG}
        \caption{Smart camera setup. The ultra96 MPSoC with the camera connected to the extension board.}
        \label{fig:edge-device}
\end{figure}

\subsection{Proposed Architecture}
Our proposed architecture system is shown on Figure \ref{centralizeArch}. The proposed framework comprises two components: the intersection unit and the cloud center. Within the intersection, there are three sub-components namely the controller, calibrated smart cameras, and the traditional traffic signal control unit. We designed each smart camera by connecting a MIPI CSI-2 camera to a Zynq UltraScale+ MPSoC board (ZU3EG) \cite{xilinxMPSoC}. The MPSoC board hosts a 64-bit Arm Cortex-A53 processor infused within the programmable logic. We designed the video pipeline on the programmable logic to receive image frames on the processor. Within the programmable logic, image data is transmitted through an AXI stream link. The embedded processor performs video traffic analyzer algorithm on image frame for extracting traffic-related knowledge (number and type of vehicles) within its calibrated space (waiting queues) in real-time. This information is sent to the controller unit through the communication medium (i.e. Wi-Fi). The edge module within the controller unit which is implemented on a similar 64-bit arm processor receives the information from different calibrated smart cameras and relies on traffic rules(matrix of conflict see table \ref{table:conflictMatrix}) for optimizing the traffic light through the traffic signal control.  The layered architecture of our controller unit indicating the data flow from the bottom external modules to the application layer is shown in figure \ref{centralizeArch}. It shows how the intersection can be remotely controlled by changing traffic rules from the cloud.

\begin{figure*}[!h]
        \centering
        \includegraphics[width=1\linewidth]{images/newArchitectureDesign.png}
        \caption{Proposed architecture system.}
        \label{centralizeArch}
\end{figure*}

\section{Image Processing Module }\label{sec:algorithm}
In this section, we discuss the image processing used for traffic analytics. This module is embedded within the smart cameras at intersections and perform processing in-situ. The advantage of this approach is reducing data transport. This section describes algorithms within the camera needed to extract knowledge such as number, types, and direction of cars in each lane as well as the density of traffic.

\subsection{Detecting Vehicles}
The goal is to identify the lanes separated by the white lines on the road and to detect and count the number of vehicles in each lane. Upon installing cameras at the intersection, calibration is first performed to define the regions of the pictures corresponding to the different lanes. While this detection could be done automatically, without calibration, the computation overhead is too high for run-time in-situ computation.

Camera calibration is spatial and consists of determining what parts of the scene are viewed by each camera at the intersection \cite{bobda2014distributed}.

The algorithm works on the set of lines $Q =\{l_0, l_1,...,$$l_{2p-1} \}$ used to determine the $p$ Waiting Queues (WQ). Each line is represented by two random points $(x_1,y_1)$ and $(x_2,y_2)$ on that line: $(l_i) ~:~ a_ix+b_iy+c_i=0$ where $a_i=y_2-y_1$, $b_i=x_1-x_2$,  and  $c_i=-a_ix_1-b_iy_1.$ Each lane $L_p = (l_{2i},L_{2i+1})$ is bounded by two lines left $l_{2i}$ and right $L_{2i+1}$. Furthermore, for each lane $L_p$ we assign a unique color $C_p.$ Algorithm \ref{AlgoDetecVehicles} provides details on the vehicle counting in the lanes for the purpose of building the waiting queue.

\begin{algorithm}[!ht]
\scriptsize
\caption{Algorithm for Counting Vehicles in Waiting lines}
 \label{AlgoDetecVehicles}
 \caption{Algorithm Count Number Vehicle on each Waiting Queue}
\SetAlgoLined
\tcp{The input of this algorithm in a frame  or a picture }
 \KwData{Frame $F$ or image}
 \tcp{The output  is the number of vehicle on each Waiting queue }
\KwResult{Number of vehicle in each Lane }
 \tcp{For each frame $F$, use Mask-RCNN to detect objects and return the set of rectangles where vehicles have been detected }
 $ObjectDetect \longleftarrow Net.setInput(F)$\;
 \tcp{Initialize the Number of vehicles to zero }
 $NumVehicle[0,...,p-1] \longleftarrow 0 $\;
 \tcp{ Classify Objects with respect to lanes}
  \For{$rect(x_0,y_0,width,height) \in ObjectDetect$}{
  \tcp{find the center of the rectangle }
   $A(x_c,y_c) \longleftarrow (x_0+\frac{width}{2},y_0-\frac{height}{2})$\;
   \tcp{find the nearest line in $Q$ to $p$ by computing the distance }
   $j \longleftarrow \smash{\displaystyle\argmin_{i \in \{0,...,p-1\}}}d(A,l_i),~ \text{ where } d(A,l_i)=\frac{\|a_ix_c+b_iy_c+c_i \|}{\sqrt{a_i^2+b_i^2}}, ~~ l_i \in Q $\;
   \tcp{ localize the Lane of the vehicle $L_k$ }
    $k \longleftarrow quotion(j/2) $ \;
    assign the color $C_k$ to the vehicle\;
    \tcp{Increase the number of vehicle of the Lane $L_k$ }
    $NumVehicle[k] \longleftarrow NumVehicle[k] +1 $ \;
 }
\end{algorithm}

\subsection{Density Measurement}
In this section, we measure in real-time the density of a queue by performing simple background subtraction.\\
\textbf{Density of a queue:} We define the density $d_a$ of a queue $\{a\}$  as the proportions of space occupied by the vehicles in $\{a\}$.
Background Subtraction(BS) technique \cite{bradski2008learning} is used to compute the foreground mask and measure the density from the mask as shown in Figure \ref{densityModeling}
\begin{figure}[!h]
\centering
 \captionsetup{justification=centering}
\begin{tikzpicture}[scale=1.4, auto,swap, line/.style     = { draw, thick, ->, shorten >=4pt }]

 \node [text centered](labelmask) at (0,3.3) {\textsf{(a) Static Background Model}};
 \node (mask) at (0,2) {\includegraphics[width=1in]{images/rsz_mask.png}};
\node (tTest) at (2,2.2) {\textsf{Threshold}};
 \node [circle,draw,fill=blue!50](subtract) at (1.2,1) {$-$};
 \node  [circle,draw,fill=blue!50](tSign) at (2,1){$>$};
  \node [text centered](labelmask) at (3.2,-0.2) {\textsf{(c) Foreground Mask }};
  \node  (foreground) at (3.2,1) {\includegraphics[width=1in]{images/rsz_foreground.png}};
   \node [text centered](labelmask) at (0,-1.3) {\textsf{(b) Current Frame}};
   \node  (currentFrame) at (0,0){\includegraphics[width=1in]{images/rsz_currentframe.png}};

 \begin{scope} [every path/.style=line]
    \path (tSign)        --    (foreground);
    \path (subtract)      --    (tSign);
    \path (tTest)      --    (tSign);
     \draw[->] (mask) -- (1.1,2) -- (subtract);
     \draw[->] (currentFrame) -- (1.1,0) -- (subtract);
  \end{scope}

\end{tikzpicture}
\caption{Density modeling. Figure (a) shows the static background model generated during the calibration step. (b) shows a test frame at any time t. (c) illustrates the foreground mask extracted from the image.}
\label{densityModeling}
\end{figure}
In the first step, the background model is computed when the road is free. In the second step, we are comparing the current frame to the background model in order to detect the objects(vehicles, truck, etc.)  on the scene. Since the foreground mask is a binary image $\{0=\text{Black}, 1=\text{White}\}$, we can compute the density by counting the proportion of white over that area of ROI.
\begin{equation}
 d = \frac{countNonZero()}{Area_{ROI}}
 \label{density}
\end{equation}

Because the focus of the work is on the infrastructure for efficient control of the traffic, we will not dive into the details of the machine learning algorithms for car detection. Those algorithms are part of the available machine learning package and can be integrated into any framework.

\subsection{Implementation}
We implemented our algorithm based on the Region based Convolution Neural Network  \cite{MASKRCNN} to output an object label, bounding box, and the mask.  We  have used open-source OpenCV  \cite{opencv_library} version 4.0.0 in C++ language. Figure \ref{calibration} presents the flowchart of our implantation for density measurement and counting vehicles.
\begin{figure}[!ht]
\centering
 \captionsetup{justification=centering}
\includegraphics[width=2.5in]{images/calibration.jpg}
\caption{Design implementation.}
\label{calibration}
\end{figure}
We calibrated the camera in space in order to set the set of foreground mask and bounded of a lane for a future  feature classification \cite{bobda2014distributed}. The results of implementation are shown on Figure  \ref{result1} and \ref{result2} as snapshot from the video processing.
\begin{figure}[!h]
    \begin{subfigure}{.5\textwidth}
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.7\linewidth]{images/result2before.png}
        \caption{Frame captured before applying the algorithm.}
        \label{result1}
    \end{subfigure}

    \begin{subfigure}{.5\textwidth}
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.7\linewidth]{images/result2.png}
        \caption{Output frame after applying the algorithm.}
        \label{result2}
    \end{subfigure}
     \caption{Result  produced from recorded traffic data.}
        \label{result}
\end{figure}

Having completed the first components of our control infrastructure, namely extracting knowledge from images to supply waiting queues in real-time, we first perform some analysis of performance before devoting the rest of the paper to the remaining modules of our architecture.

\subsection{Performance Analysis}
We measured the computation time of our model as illustrated in Table \ref{tab:perf}. We tested our model as a single-core implementation on a 64-bit x86 processor with a clock frequency of 3.60GHz. The total computation time does not include the calibration time since this will be only performed once only at the beginning of the computation. For calibration and testing purposes, We used a 4-minutes video clip of a 4 -way transaction as input. The results suggest that the model can achieve close to 4 frames per second. This can be improved by trading the detection model with a lighter one. We were able to achieve 13 frames per second by using the YOLO-V3-tiny model to detect vehicles. However, this reduces the accuracy of the model as well.

\begin{table}[H]
\scriptsize
\centering
 \caption{Performance Analysis}
 \label{tab:perf}
\begin{tabular}{@{}lc@{}}
\toprule
\multicolumn{1}{c}{\textbf{-}} & \multicolumn{1}{l}{\textbf{Computation time (ms)}} \\ \midrule
\textbf{Detection time} & 224ms \\
\textbf{Calculating traffic density} & 40ms \\
\textbf{Total Computation time} & 262ms \\
\textbf{Frames per second} & 3.82fps \\ \bottomrule
\end{tabular}
\end{table}

\section{Waiting Queue}\label{sec:wait}
Our algorithm operates on waiting queues, which are updated using knowledge gained from the image processing module. This section provides details of the various waiting queues (WQ) used in our model.

A waiting queue represents vehicles in a given lane. We consider two types of waiting queues in the target system: Entry queues and exit queues:

\subsection{ Exit Queue}
An Exit Queue noted $Q_O$ or output queue at the intersection can be in one of two states :
\begin{itemize}
\item[$\bullet$]  \textbf{Open} Meaning this queue  can accommodate vehicles.
\item[$\bullet$] \textbf{Closed} Meaning this queue can not accommodate new vehicles.
\end{itemize}
For a queue in open state, we find the free space by using the density over the lane space.. This information is  important for finding  the  maximum number of vehicles that the queue can accommodate.
\subsection{ Entry Queue}
An Entry queue $Q_I$ or Input queue at the  intersection has three  possible states :
\begin{itemize}
\item[$\bullet$]$\{A\}$: \emph{Active} means that the signal light is \textbf{green} (G) for this queue.
\item[$\bullet$]$\{WA\}$: \emph{Waiting Active} meaning that the signal light should be \textbf{green}  but  for some reason($Q_O$ is closed or important vehicle has been detected) it has been blocked and the  light remains red.
\item[$\bullet$] $ \{IA \} $: \emph{Inactive} meaning that the signal light is \textbf{red} (R) for this queue.
\end{itemize}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\SetUpEdge[lw= 1.5pt]
\GraphInit[vstyle=Shade]
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=red}]
\Vertex[x=0 ,y=0]{IA}
\end{scope}
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=green}]
\Vertex[x=3 ,y=-3]{A}
\end{scope}
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=orange}]
\Vertex[x=6 ,y=0]{WA}
\end{scope}

\tikzset{EdgeStyle/.style={draw=red, post, bend right}}
\Edge[label=$\text{red}$](A)(IA)

\tikzset{EdgeStyle/.style={draw=orange, post, bend left}}
\Edge[label=$\text{wait}$](A)(WA)
\Edge[label=$\text{important Vehicle}$](IA)(WA)
\tikzset{EdgeStyle/.style={draw=green, post, bend left}}
\Edge[label=$\text{green}$](WA)(A)

\tikzset{EdgeStyle/.style={draw=green, post, bend right}}
\Edge[label=$\text{green}$](IA)(A)

\end{tikzpicture}
\caption{Simple state diagram of queue.}
\label{DiagramBig}
\end{figure}
Figure \ref{DiagramBig} shows the states a queue can be in at any time. The controller algorithm chooses the queue with the highest number of vehicles to move from state $\{IA\}$ to $\{A\}$ and the state $\{WA\}$ precedes $\{IA\}$. However, the logic to select the waiting queue with a large number of vehicles has some problems, namely long waiting time in queue with low traffic.
 Figure \ref{exa1} shows that at time $t$, $\{EL\}$ has the highest number of cars in it's queue so the algorithm turns this light green, at the same time $\{EF, ER,NR,SR \}$ can be open without conflict. In Figure \ref{exa2} a time $t+x$, $\{ SF\}$ is the queue with most of the cars, so this turns green. Observe that $\{ EL\}$ is filling up with vehicles and will be opened next time, while queues such as $\{ NL\}$ and $\{ WL\}$ with low traffic are still waiting and may wait forever. \par
\begin{figure}[!h]
 \captionsetup{justification=centering}
    \begin{subfigure}{.48\textwidth}
       \centering
        \captionsetup{justification=centering}
        \includegraphics[width=0.7\linewidth]{images/example1.jpg}
        \caption{Our approach consists of setting the green light to queue with highest number of car. At time $ t$:  $\{NL,WR, WL\}$ are waiting.}
        \label{exa1}
\end{subfigure}

    \begin{subfigure}{.5\textwidth}
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.68\linewidth]{images/example2.jpg}
        \caption{Apply same principle as shown on figure  \ref{exa1}.  At time $t+x$ :  $\{NL,WR\}$ are still waiting and next queue to be opened is $\{EL\}$. So, $\{NL,WR\}$ might wait forever. }
        \label{exa2}
        \end{subfigure}
        \caption{Dead wait of  low traffic queue along heavy traffic queue for simple state diagram queue  modeling.}
\end{figure}

We have introduced the notion of internal state $IA \in \{0,1,2,3,4 \}$ (the light is still red for those states) to take into account the fact that a queue with low traffic can at certain time have the highest priority. As describe in Figure \ref{Diagram-state} where
\begin{itemize}
\item E is a transition caused by the presence of an emergency vehicle.
\item $Y_i(t)$ is elapsed time for a queue to change his internal state during the cycle $i$.
\item $X_i(t)$ is the time allocated to empty the queue during a cycle $i$.
\end{itemize}
A cycle is when a queue made a complete turn through state  $\{A\}$.
 An example of a possible cycle can be $\{ 0 \rightarrow 1 \rightarrow 2 \rightarrow A \rightarrow 0\}$, or$\{ 0 \rightarrow 1 \rightarrow 2 \rightarrow 3 \rightarrow WA \rightarrow  A \rightarrow 0\}$. Hence $Y_i(t)$ is computing each cycle and is constant for a time slot $t$. The figure \ref{Diagram-state} shows the difference transitions and state of a waiting queue $Q_I$.
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\SetUpEdge[lw= 1.5pt]
\GraphInit[vstyle=Shade]
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=red}]
\Vertex[x=0 ,y=0]{0}
\Vertex[x=2 ,y=0]{1}
\Vertex[x=4 ,y=0]{2}
\Vertex[x=6 ,y=0]{3}
\Vertex[x=5 ,y=-2]{4}
\end{scope}
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=green}]
\Vertex[x=1 ,y=-2]{A}
\end{scope}
\begin{scope}[VertexStyle/.append style={shape=circle, shading=ball, ball color=orange}]
\Vertex[x=3 ,y=-4]{WA}
\end{scope}
\tikzset{LabelStyle/.style={draw,fill = white,text = red,post}}
\tikzset{EdgeStyle/.style={draw=red, post, bend left}}
\Edge[label=$Y_i(t)$](0)(1)
\Edge[label=$Y_i(t)$](1)(2)
\Edge[label=$Y_i(t)$](2)(3)
\Edge[label=$Y_i(t)$](3)(4)

\tikzset{LabelStyle/.style={draw,fill = white,text = orange,post}}
\tikzset{EdgeStyle/.style={draw=orange, post}}
\Edge[label=$E$](0)(4)
\Edge[label=$E$](1)(4)
\Edge[label=$E$](2)(4)
\tikzset{EdgeStyle/.style={draw=orange, post, bend right}}
\Edge[label=$E$](3)(4)

\tikzset{EdgeStyle/.style={draw=red, post, bend right}}
\Edge[](A)(0)

\tikzset{EdgeStyle/.style={draw=orange, post, bend left}}
\Edge[](A)(WA)
\Edge[label=$E$](4)(WA)
\tikzset{EdgeStyle/.style={draw=green, post, bend left}}
\Edge[](WA)(A)

\tikzset{LabelStyle/.style={draw,fill = white,text = green,post}}
\tikzset{EdgeStyle/.style={draw=green, post, bend right}}
\Edge[label=$X_t(t)$](0)(A)
\tikzset{EdgeStyle/.style={draw=green, post}}
\Edge[label=$X_i(t)$](1)(A)
\Edge[label=$X_i(t)$](4)(A)
\tikzset{EdgeStyle/.style={draw=green, post, bend left}}
\Edge[label=$X_i(t)$](2)(A)
\Edge[label=$X_i(t)$](3)(A)
		\Edge[label=$X_i(t)$](WA)(A)

\end{tikzpicture}
\caption{ Extend state diagram of a queue.} \label{Diagram-state}
\end{figure}

The set $\{0,1,2,3,4 \}$ are  the states that a waiting queue $Q_I$ goes trough cyclically whenever transition conditions are fulfilled. Only the controller or the master can set the status of the queue as $\{A\}$ and afterwards to zero to mark the end of a cycle. \par
Let's consider this cycle as the first running time. $\{ 0 \rightarrow 1   \rightarrow 4 \rightarrow  A \rightarrow 0\}$.  The queue starts in state $\{ 0\}$, we assume that, the queue is not empty (id the queue is empty, the state remains in zero). After $Y_1(t)$ time has elapsed (index 1 means cycle number 1) the queue moves to state $\{ 1\}$. The presence of an emergency vehicle upgrades it to state $\{ 4\}$, and after some time it becomes the only queue in state $\{ 4\}$, and it moves to state $\{ A\}$. After the time taken to empty the queue noted $X_1(t)$, it returns to state $\{ 0\}$ and $Y_2(t)$ is computing to mark the end of the cycle.  \par
Let $I^{a}_i(t)$ be the internal state of queue $\{a\}$ during the cycle $i$, the equation is given by:
\begin{equation}
\tiny
I^{a}_{i}(t) = \begin{cases}
I^{a}_{i}(t-1),  \text{ if } I^{a}_{i}(t-1) < 0 \text{ or } I^{a}_{i}(t-1) > I_{max} \\
\min\{I^{a}_{i}(t-1)+1_{[Y^{a}_{i} ~\text{elapsed} ~ \&~ d^{a}_I(t)\neq 0 ]},I_{max}\},  \text{ Otherwise}
\end{cases}
 \label{eqInternalState}
\end{equation}
Where $I \in \{ 0,1,\cdots,I_{max}\}$ , in particular  $I_{max}=4$, $1_{[X]}$ is the indicator function that takes the value $1$ if $X$ is true and $0$ otherwise, and $d^{a}_I(t)$ the current density of the entry queue $\{ a\}$.  \par

There are 12 queues in our target system: $\{WR,WF$ $,WL,ER,EF,EL,NR,NF,NL,SR,SF,SL\}$, each of
which has an internal state. This internal state is relayed back to the main controller, where the algorithm sets the queue with the highest state to have a green light. If this is not possible, it selects the next highest state queue. After the queue has been emptied, the controller then reassesses which queue should be given priority.

\subsection{Calculating $X_i(t) $ : time needed to empty a queue}

\par $X_i(t)$ is the time needed to empty the  $Q_I$ at time slot $t$ during a cycle $i$. This time depends on the exit  and the entry queue. \par
There are  situations where  the exit queue is not ready to accommodate vehicles but the light is green  for the entry queue. On the figure \ref{Counter-Example}, The queue $\{EL\}$ has the highest number of vehicles and has been selected, then  we find the queue in green  can operate without conflict, especially the arrival queue $\{ EF\}$ but the departure queue is not ready to accommodate vehicles.
\begin{figure}[!h]
       \centerline{
        \includegraphics[width=2.5in]{images/ComputeTime.jpg}}
        \caption{Case of a queue EF with green light but with exit queue that cannot accommodate new vehicle.}
        \label{Counter-Example}
\end{figure}
\par
Hence, we take into account all these parameters and find out that the formula for computing the time $X^{a}_{i}(t)$ needed to empty a queue $\{a\}$ during a cycle $i \in \mathbb{N}$ at time slot $t$ is:
\begin{equation}
X^{a}_{i}(t) = \frac{\min\{(1-d^{a}_{O}(t))L^{a}_{O},d^{a}_{I}(t).L^{a}_{I}\}}{V} .\label{Xtime}
\end{equation}
Where $d^{a}_{I}$ and $L^{a}_{I}$ are the current density of the vehicle on input traffic queue $\{ a\}$ and the length of the queue $\{ a\}$, $d^{a}_{O}$ and $L^{a}_{O}$ are the current density on the output traffic queue(exit queue) and the length of the queue, and  $V$ is the velocity to cross the crossroad.

\begin{itemize}
\item $(1-d^{a}_{O}(t))L^{a}_{O}$ is the proportion of space  available to accommodate vehicles on exit (output) queue.
\item $d^{a}_{I}(t).L^{a}_{I}$ is the proportion of space occupied by vehicles on the entry (Input) queue.
\end{itemize}

The function minimum guaranty the time needed to empty a queue is enough in order to avoid vehicles to remain in middle of the intersection after that time elapsed.  \par
Note that, $X^{a}_{i}(t)=0 $ implies either  $d^{a}_{I}=0$  meaning there is not vehicles on the input queue, or  $d^{a}_{O}=1$ meaning the Output queue is full and can not accommodate vehicles.

\subsection{Calculating $Y_i(t)$}
\par Let $Y^{a}_{i}$ be the time needed for a queue $\{a\}$ to change internal state. $Y^{a}_{i}$ can be written as a function of the time needed to empty the queue:
\begin{equation}
Y^{a}_{i} = f(X^{a}_{i-1}) \label{Ytime}.
\end{equation}

Our goal is to find an appropriate function $f$ that minimizes the time needed to empty the queue. If this time is high, this queue will be assume to have heavy traffic, and its internal state should change quickly. That is, if $X^{a}_{i-1}$ is large, then $Y^{a}_{i}$ should be small, and vice versa.
\begin{figure}[!h]
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.4\textwidth]{images/sage3.png}
        \caption{Plot of a possible choice for $Y^{a}_{i} = f(X^{a}_{i-1})$ }
        \label{sketchY}
\end{figure}
Thus equation \ref{Ytime} becomes :
\begin{equation}
Y^{a}_{i} = Y_{min}+(Y_{max}-Y_{min})a^{X_{i-1}} ~~ \text{where} ~~ 0<a<1
 \label{YtimeFinal}
\end{equation}
The figure \ref{sketchY}  was obtained with $a=\frac{4.5}{5}, Y_{min}=0.5,$ and $Y_{max}=15$.  \par
Here we will make an assumption that the model \ref{sketchY} is appropriate. Our goal is to vary the parameters $\{ a, Y_{min},Y_{max} \}$ in order to minimize the average waiting time. \par

Note that if a queue has only one car, it's internal state will still change, but the time taken to change will be longer than that of a queue with many cars. This way both the number of cars and the time spent are taken into account when assigning an internal state.  \par

The complete algorithm is described as flowchart on the figure \ref{flowChartQueue}. Note  that, each queue is supposed to run independently this algorithm.

\begin{figure}[!h]
\centering
 \captionsetup{justification=centering}
\includegraphics[width=0.3\textwidth]{images/flowchart.jpg}
\caption{Flowchart queue insight.}
\label{flowChartQueue}
\end{figure}
\begin{table}[H]
\tiny
\centering
\caption{Sub functions used on flowchart Figure \ref{flowChartQueue}.}
\begin{tabular}{@{}ll@{}}
\toprule
\multicolumn{2}{c}{\textbf{Sub-process}} \\ \midrule
\textbf{Init()} & $Y_i=f(X_{i-1})$;Status=0; Event=$False$; T=Time(). \\
\textbf{ChangeLevel()} & Check if $Y_i$ time elapsed and  $d \neq 0$ and status $\neq \{A, WA \}$. \\
\textbf{IncreaseStatus()} & Status = $I_i(t+1)$, get it from equation \ref{eqInternalState} \\
\textbf{VehicleImportant() }& Event= ( emergency vehicle detected) ? True : False \\
\textbf{SetPriority()} & Set Status = (Status \textless 4) ? 4 : WA. \\
ResetEvent() & Event=False \\ \bottomrule
\end{tabular}
\label{subfunctioon}
\end{table}

\begin{table}[H]
\tiny
\centering
\caption{Variables  used  on flowchart figure \ref{flowChartQueue}.}
\begin{tabular}{@{}ll@{}}
\toprule
\multicolumn{2}{c}{\textbf{Variables}} \\ \midrule
\textbf{T} & Record the  time when increase Status occurs. \\
\textbf{Status} & Current Internal state of a queue, $\in \{0,...,T_{max}, WA, A \}$ \\
\textbf{Y\_i} & Time elapsed for changing the internal state during current cycle. \\
\textbf{d} & Current density of the queue. \\
\textbf{X} & Time needed to empty queue during the previous cycle \\ \bottomrule
\end{tabular}

\label{variableused}
\end{table}

\section{Distributed Control Algorithm}\label{sec:distributed}

In this section we describe the distributed algorithm for traffic light, based on the conflict matrix \ref{MatrixCon}.

\subsection{Modeling}
We have described the different states of a queue in section  \ref{Diagram-state}, taking into account the density of traffic and the time elapsed. The road code was modeled through the conflict table \ref{MatrixCon} where entries in the diagonal were considered the illegal case. In the rest of this article, this table will be seen as a square symmetric matrix where indexes are queuing labels and the diagonal entries will hold the state of the corresponding queue. This matrix named here $M$ contains the configuration of the intersection and the current state of the system. \par Thus the  square  matrix $M$ corresponds to the states of the queue and being constructed based on the following formula:
\begin{equation}
\scriptsize
M_{[a,b]}(t) =\begin{cases}
I^{a}_{i}(t) ,  & \text{ if } a = b \\
\otimes, &  \text{if queue } \{a\} \text{is in conflict with queue. }  \{b\} \\
0,   & \text{Otherwise. }
\end{cases}
\label{eqModelingMatrix}
\end{equation}
where $I^{a}_{i}(t)$ is the current state of queue $\{ a\}$  from \ref{eqInternalState}. Note that, from the equation \eqref{eqModelingMatrix} are follow :
\begin{equation*}
M_{[a,b]} = M_{[b,a]} \text{ and } M_{[a,a]} = I^{a}_{i}
\end{equation*}
To solve this, we introduce a numerical values for the active state $A:-1$. and similarly for the waiting active state, we assign it a value of $I_{max}+1$ which is $5$ in particular.
\begin{equation*}
\{A\} \leftarrow -1 \text{ and }\{WA\} \leftarrow  5
\end{equation*}
$\{A\}$ and $\{WA\}$ are respectively the status Active and Waiting Active from our state diagram of Figure \ref{DiagramBig}. The matrix $M$ of equation \ref{algoMatrix} represents the state of the system at a specific time where the diagonal is the only dynamic part.  The queues $\{ ER,NR\}$ in red are operative, thus their internal state is set as  $\{A\}$ meaning $M_{[ER,ER]} = - 1 $, and the next queue to open is $\{SF\}$ because of its highest internal state obtaining with following formula $ $ $\argmax\{diagonal(M)\}=\arg\{M_{[i,i]}=3\}=\{SF\}$.

\begin{equation}
\scriptsize
\centering
M=\begin{blockarray}{cccccccc}
WR & \cdots & {\color{red} ER} & \cdots & {\color{red} NR} & \cdots & {\color{blue} SF}   \\
\begin{block}{(ccccccc)c}
{\color{yellow} 2}	&  \cdots	&0 &	\cdots &0 & \cdots &0 & WR	\\
\vdots & \ddots & \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
0 & \cdots & {\color{red} -1} & \cdots & 0 &\cdots & \otimes & {\color{red} ER} \\
\vdots & \ddots & \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
0	&  \cdots	&0 &	\cdots &{\color{red} -1} & \cdots &0  & {\color{red} NR}	\\
\vdots & \ddots & \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
0 & \cdots & \otimes & \cdots & 0 &\cdots & {\color{blue} 3} & {\color{blue} SF} \\
\end{block}
\end{blockarray}
\label{algoMatrix}
\end{equation}
This model with the matrix gives us a flexibility in case of modification of the road code at the intersection, it will be enough for us to modify the static part of the matrix by performing an operation to exchange between $\{0\}$ and $\{\otimes \}$. These operates can be extend in  remotely control the intersection for a smart city. \par

\subsection{Algorithm for updating the matrix $M$}
Since each queue has his internal state as described in section \ref{flowChartQueue}, it is enough to set their internal state in dynamic part of the matrix $M$.  \par
\begin{algorithm}[!ht]
\scriptsize
\SetAlgoLined
 \KwData{set of the queue }
\KwResult{ Matrix $M$  }
\For{$q \in set Of Queue$}{
\tcp{Compute the internal state of the queue from the  flowchart \ref{flowChartQueue}}
     Compute  $I^q$ \;
     \tcp{Update the diagonal of the matrix $M$}
     $M[q,q] \leftarrow I^q $\;
}
 \caption{Update the matrix $M$ }
 \label{UpdateMatrix}
\end{algorithm}

\subsection{ Notations and Sub-functions }
Now that we have digitized any intersection via our Matrix $M$, before writing the distributed algorithm, we are going to show variables and sub-functions used in the algorithm.
\begin{table}[H]
\tiny
\caption{Notations used in algorithm \ref{AlgoDistribted}.}
\centering
\begin{tabular}{@{}ll@{}}
\toprule
\multicolumn{1}{c}{\textbf{Variables}} & \multicolumn{1}{c}{\textbf{Meaning}} \\ \midrule
$Q$ & \begin{tabular}[c]{@{}l@{}}Set  of all queue \\  i.e $Q=\{WR,WF, WL, ER ,EF ,EL ,NR, NF ,NL, SR ,SF ,SL\}$\end{tabular} \\
\textbf{$M$} & Square Matrix of size $\| Q\|\times\| Q\|$ \\
\textbf{ListOpen} & Set of queue to open \\
\textbf{RunList} & Set of queue in process \\
S & Set of forbidden queue \\
$U_a$ & set a queue without conflict with queue $\{a\}$ \\ \bottomrule
\end{tabular}
\end{table}
For the \textbf{Sub functions}, we have two. $ Sort(L)$ : which  Sorts in ascending order the items in the list $L$, and $Open(a)$.
\begin{equation*}
\scriptsize
Open(a) =\begin{cases}
\text{ True} , & if X^a(t) \neq 0 \text{ we obtain } X^a \text{ from } equation \ref{Xtime}  \\
& X^a(t) \text{: time needed to empty the queue } \{a\}  \\
\text{False}, &  \text{Otherwise.}
\end{cases}
\label{eqModelingMatrix}
\end{equation*}
Basically, the sub-function $open(a)$ is a Boolean function that returns true if the time needed to empty the queue is different to zero and false otherwise. Consider a scenario where an entry queue is full and the exit queue is also full. Then at a certain time, we realize that the queue has the highest priority. If we set a queue to green, the vehicles will stand in the middle of the intersection and that will cause traffic congestion. In order to avoid that, the time $X^a_i$  needed to empty a queue is taking into account this scenario.

The distributed algorithm \ref{AlgoDistribted} is based on the matrix $M$ essentially the diagonal of the matrix. It operates according to the principle that the queue having a high priority level (internal state) will be selected, and this algorithm is supposed to be executed by an irregular interval of time.

\begin{algorithm}[!h]
\scriptsize
 \caption{Distributed Algorithm.}
\SetAlgoLined
 \KwData{Matrix $M$ }
\KwResult{ Return the set of queue to open $ListOpen$  }
\tcp{initialization}
 $ListOpen \leftarrow \oslash $ \;
 \tcp{get  set a queue in process}
$RunList \leftarrow \arg \{{diag(M)<0} \}$ \;
$S \leftarrow RunList$ \;
\tcp{find set of queue which is in conflict with queues in Process}
  \For{$q \in RunList$}{
     $p \leftarrow \smash{\displaystyle\arg_{i \in Q}} \{M[q,i]=\otimes \}$ \;
    $ S \leftarrow S \cup \{p\}$ \;
}
 $listOrder \leftarrow \smash{\displaystyle\arg_{i \in Q\backslash S}} \{Sort(M[i,i]) \} $ \;
 \tcp{find exactly one queue without constraint to open}
  \For{$q \in ListOrder$}{
          $S \leftarrow S \cup \{q\}$ \;
    \eIf{ $Open(q)$}{
        $M[q,q] \leftarrow WA=5$ \;
        \tcp{ Take the next queue with highest level}
        $continue$\;
    }{
    $ ListOpen \leftarrow \{q \}$ \;
    $break$ \;
    }
}

\eIf{ $ ListOpen = \oslash $}{
\tcp{ End the program if there no queue to open}
      $ exit()$ \;
}{
    \tcp{ find the list of queue without conflict with $q \in ListOpen$}
    $U_q \leftarrow \smash{\displaystyle\arg_{i \in Q\backslash S}} \{M[q,i])\neq \otimes \}$ \;
    \tcp{Find  the set of queue to open in parallel with $q$ without conflict}
    \While {$U_q \neq \oslash $}{
    \tcp{Among those queues, chose the one with  highest internal state}
    $p \leftarrow \smash{\displaystyle\argmax_{i \in U_q}} \{M[i,i] \}$ \;
    \tcp{}
    \If{$Open(p)$}{
    \tcp{add $p$ in the list of queue to open}
     $ ListOpen \leftarrow ListOpen \cup \{p\}$ \;
    }
    \tcp{remove $p$ from $U_q$}
    $ U_q \leftarrow U_q \backslash \{p\}$ \;
    \tcp{ find the list of queue without conflict with $p$}
   $ U_p \leftarrow \smash{\displaystyle\arg_{i \in U_q}} \{M[p,i] \neq \otimes \}$ \;
   $ U_q \leftarrow U_q \cap U_p$

    }

}
 \label{AlgoDistribted}
\end{algorithm}

\section{Simulation }\label{sec:simulation}
This section evaluates our algorithm using a combination of image processing and the SUMO (Simulation of Urban MObility,\cite{SUMO2012}) framework. SUMO is an open-source, discrete-time, continuous space, microscopic simulator entirely coded in C++ to model traffic flow as well as supporting tools, mainly for network import and demand modeling. In short, it allows placing sensors and retrieving real-time traffic data using tools TraCI (\textbf{Tra}ffic \textbf{C}ontrol \textbf{I}nterface ) and to act on the behavior of the Traffic Light Control on-line. Our distributed algorithm is based on an intersection modeled from the city Amiens in France at rush hour, between 8 AM and 9 AM, which according to  Sebastien Faye and al. \cite{faye2012distributed2} statistically have in SUMO new vehicles arrival-rate of $\lambda = 0.8$ per second on the intersection. Relying on this statistical assumption, our simulation was conducted on an intersection with 4 directions and 12 possible movements: from each direction, a vehicle could go straight, turn left or turn right. In addition to that, we injected emergency vehicles with an arrival rate of $\lambda = 0.025 $ per second in order to evaluate the impact of such vehicles on our distributed algorithm. Each simulation ran for 3600 program steps representing the 3600s. The results presented below are the average waiting time computed on the 3000 first vehicles that left the intersection. This allows us to evaluate our algorithm with a realistic traffic. Note that, the TraCI tool allows us to gather traffic data but in the real deployment of our proposed solution, those traffic data are provided by the distributed smart-cameras installed at the intersection.
\begin{figure}[!ht]
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.5\textwidth]{images/simluation.png}
        \caption{Capture of simulation after 150 steps(150 seconds), Emergency vehicle(EV) in blue and Classic vehicles(CV) in yellow. }
        \label{fig :simulation}
\end{figure}
\subsection{Parameters}
The green light limit time $T_{max}$ are expected  to have a strong  influence  on the performance result. In case $T_{max}< X_i$ (define time needed to empty queue $i$  see equation \ref{Xtime}), the green light queue will be  $T_{max}$. Afterwards, the internal state  of  the queue will not  be  set  to zero but proportionally  to the  ratio between $T_{max} $  and $ X_i$. We chose to evaluate the algorithm  with two scenarios :(1) $S_1$  when  taking into account the priority of the emergency vehicles; (2) $S_2$ without considering priority on any vehicles. For both scenarios, we output the average waiting time of emergency vehicles(EV), classic vehicles (CV) and both vehicles (AV). These simulation is conducted  for $T_{max} \in [15,90]$ in steps of $5$ seconds.
\begin{figure}[!h]
\begin{subfigure}{.5\textwidth}
  \centering
        \centering
        \captionsetup{justification=centering}
        \includegraphics[width=0.8\textwidth,scale=0.8]{images/AWTBoxPlot.png}
        \caption{Multiple average waiting time for scenarios  $S_1$ \\ and $S_2$ with collision forbidden. }
        \label{fig : awtboxplot}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.8\textwidth,scale=0.8]{images/AWT_Tmax.png}
        \caption{(Vehicle type, scenario), $T_{max}  $  influence on average waiting time with collision forbidden. }
        \label{fig : awtTmax}
\end{subfigure}
\caption{Performance results.}
\label{fig:AWT_Result}
\end{figure}

 Figures \ref{fig : awtboxplot} and \ref{fig : awtTmax} present the average waiting time at an intersection for different class of vehicles with and without emergency vehicles. We can first  notice that, the scenario $S_1$ allows reaching the better average waiting time especially the emergency vehicles (EV) which is the target class of vehicle for this scenario. We can also notice the fact the average waiting time is proportional to $T_{max}$.

 \subsection{Performance}
We compare the results of the distributed algorithm presented above to other  achieved works \cite{yousef2010intelligent},\cite{faye2012distributed},\cite{faye2012distributed2} on the same isolated-intersection data set of Amiens city in France. Provided the correct value of $T_{max}$, our distributed algorithm achieves the best average waiting time with an average vehicle of $2651$ instead of $2138$ for 3600 steps (3600 s). Moreover, our algorithm is more efficient as it can fast evacuate the emergency vehicles at the intersection while fulfilling the constraints of zero collisions and no green light with an empty queue. In addition to that, this faster evacuation will be  done without significantly increasing the average waiting time of non-emergency vehicles.
\begin{figure}[!h]
        \centering
         \captionsetup{justification=centering}
        \includegraphics[width=0.48\textwidth]{images/compareResult.png}
        \caption{Performance analysis of our result to other result on Amiens isolated dataset \protect\footnotemark. }
        \label{fig :sebastienResult}
\end{figure}
\footnotetext{http://tapioca.sfaye.com/}

\section{Conclusion and Future Works}
In this work, we presented a vision-based infrastructure of a decentralized approach for the Intelligent Traffic System(ITS).  The main challenges associated with traffic congestion and emergency vehicles were discussed and an adaptive algorithm was presented. \par
We have modeled an intersection through the conflict matrix, thus giving flexibility in case of a modification of the code of the road, it will be enough to perform an exchange operation on the matrix. The proposed optimized distributed algorithm is based on this matrix and it will provide a set of queues without conflict of collisions and the time needed to empty each queue. We also took into account the balance between the queue with heavy traffic and  low traffic in order to avoid the problem of an empty queue with a  green light.  \par
We also implemented an algorithm to monitor real-time traffic information using cameras. This low cost and smart vision-based infrastructure approach for gathering traffic data replaces the use of WSN coupled with cameras for video-surveillance which are complex to establish.

Our future works will attempt to first extend the simulation to multiple intersections data-set while introducing new elements like pedestrian crossing, and secondly port this work on edge devices to perform computation on the edge.