An Adaptive Tracking Algorithm For Robotics and Computer Vision Application
An Adaptive Tracking Algorithm For Robotics and Computer Vision Application
MS-CIS-88-05
GRASP LAB 132
January 1988
Philadelphia, Pennsylvania
December 1987
A thesis presented to the Faculty of Engineering and Applied Science of the University of
Pennsylvania in partial fulfillment of the requirements for the degree of Master of Science
in Engineering for graduate work in Electrical Engineering.
Abtract ..................................................................................................iii
Chapter 1
Appendix I
to continuously point the video camera at the moving object. The real time video images
are fed to a PVM-1 (a pyramid-based image processor) for image processing and moving
object detection. The measured object coordinates are continuously fed to our algorithm
for track smoothing and prediction. In this study, we examined several tracking algorithms
and adopted an optimal a - B filter for tracking purposes and the a - /I - 7 filter as part of
the initialization procedure. The optimum gains for these 6lkm are based on the M i n g
Index principle which in its turn is based on the measurement noise variance and the object
dynamics. We derived an expression for the noise variance corresponding to our application.
As for the object dynamics, we developed an adaptive method (using the a - /I - 7 filter
mentioned above) for inferring object dynamics in an iterative learning process that results
in an accurate estimate of the W m g Index. The accuracy of our algorithm r e h that
A machine vision system is often considered as part of a larger system that interacts
with the environment. The input to such a system, is an image, or several images, while
its output is a description that must bear some relationship to what is being imaged and
must contain all the needed information to carry out a designated task. In other words, the
objective is not to obtain any description of what is imaged but one that allows us to take
an appropriate action. Since building a Wversal' vision system is still at the early stages
The work here is tied to one of those particular t d a , namely, real time analysis of images
in a dynamic environment. Under this category falls the topic of motion analysis.
It is known that there are two major obgtacleer in computing the 3-D parameters of
rigid motion from the retinal optical flow. One of these is the high dimensionality of the
parameter space; the other is the nonlinearity of the constraint equatione. It has been shown
in [2] that these ahortcominge may be eased by following two strategies. The h t , and the
most important of these, ia to employ t r a c h i , thereby exploiting the temporal behavior
of a moving object. The second ia to employ stereoscopic imaging. The results showed that
tracking the object of interest is advantageous in both monocular and binocular imaging
situations.
1
The use of a tracking filter is dasirable under these circumstances in order to increase the
accuracy of the image- based measurements of the position and orientation of a 3-D moving
object. Our goal has been to find the most suitable tracking filter and tailor it to an existing
vision-controlled robotics manipulation system that has the capability of performing object
detection in real time. Thia capability is provided mainly by the Pyramid preprocessor
[3], [4]. We will focus our attention here on tracking the translational motion of a 3-D
rigid object. Ttacking and prediction of this motion can be used to continuously point the
video camera of the robotics system on the moving object. An extension to the problem of
tracking the rotational motion of the rigid object is straightforward. The following sections
give an overview of the Pyramid preprocessor and the existing moving-object detection
algorithm.
in the input image. According to [3]there is evidence that the human visual system usea
a form of multi- resolution representation wbkh supports the concept that image process-
ing at multi-resolution levels is very efficient and robust. The most obvious advantage of
pyramid representatiom is that they provide a poeeibility for reducing the computational
cost of various image operations. Many basic image operations may be performed efficiently
within these pyramid structures. The first requirement for a multi-mlution image pro-
cesaing system is that it be able to perform a pyramid transform such ae the FSD (filter,
2
subtract, and decimate transform), to decompose the original image into a set of different
eliminating certain epatial frequency bands or computing local energy measures at different
scales, storing the results in a memory frame store. These d t s can be accessed simulta-
neously by the host computer for further processing. In this manner, the hoat processor (an
IBM RT in our case) is relieved from performing extensive computations. For example, for
a 256 x 256 pixel image, updated 30 times per mend, the data rate is 2M pixels per second.
By representing the video image in a suitable format, the hoat can perform real time or
near real time image proceesing operations by selectively limiting the processing to 1000 to
20,000 pixels per second, rather than 2M pixels/second. This proved to be sufficient for
performing numerous image processing tasks, e.g. real time motion detection and tracking,
The tracking filter (that provides tbis system with prediction capability) usca an existing
motion detection program which detects object motion wherever it may occur within a large
3
field of view. The following is a brief description of how this is accomplished 1.11.
Let I(T) be the image frame at time T . In the first step, a difference of two consecutive
images is obtained D(T) = I(T)- I(T- 1). Difference values that are not zero indicate that
a change has occurred in the original sequence. In the second step, the difference image is
d e c o m p d into spatial frequency bands through the conatmction of a Laplacian pyramid
(See Figure 1.1). A particular band paee level is then selected for further analysis. For
example, I& 1 could be chosen to generate a second series of low paes versions G,I Lo! where
n ranges from 1 to 4.
G4 which contains only 16 x 16 samples (and yet represents image changes correapondiig
to that within the original image) is examined by the host. (It is worthwhile mentioning
that a typical high performance microcomputer (e.g., an IBM-RT) can examine only, on
the order of, 16x16 samples per one h e interval [4].) If a change ia detected in G4,the
change within the new subimage directs the host to examine a 16 x 16 subarray of G2.This
procedure allows the system to rapidly home in on a small object anywhere within the field
of view, since G4,which is a 16 x 16 array, contains the entire field of view of the 256 x 256
original image, but a 16 x 16 subarray located in G1 covers only a small area of the original
image [4].
We conducted a general study on the tracking filters and chm one of these filters for
our application. Among the filters that were examined are: The Kalman, Wiener, rr - /3
and a! - ,fl - 7 Elten, and the Two-Point Extrapolator. The criteria followed in our decision
4
F = FILTER
D = DECIMATE
We adopted an optimal a - B filter for tracking purposes and the a - 8 - 7 filter ae part
of the initialieation procedure. The powerful performance of this filter (which redm that
of the Kalman) liw in the method that produces the filter gain values. The derivation of the
optimum filter gains is based on the k k i n g Index which is proportional to the position
uncertain$ due to object accelerations to that due to measurement errors (in the detection
scheme) 151.
We derived an expression for the noise variance corresponding to our application. As for
the object dynamics, we developed an adaptive method (using the cr - 6 -7 filter mentioned
previously) for inferring object dynamics in an iterative learning process that reaultn in an
The work presented here was developed on an IBM AT; and the d t a were tested using
the position data of the moving object obtained from files produced by the Pyramid/IBM-
RT system. The following chapters give a more detailed account of our work.
CHAPTER 2
As we observe the position of a moving object over time using any kind of measuring
instrument (a video camera, radar, etc.), almost always, the observations are cluttered by
noise, errors and i n a c w i e s . The primary function of the trackiig filter is to accept
the noiey position data at its input and provide smoothed object position and velocity
estimates at its output. These values are used for controlling the orientation and position
of the camera as well as predicting future object poeitions. In addition, the smoothed
position and velocity estimates can be used for track correlation and association purposes
in a multi-moving-object environment.
In smoothing and prediction, two set3 of equations govern the whole technique. The k t
set of equations is the differential equations which describe the process (object motion).
The second set relates the parameters being measured to those to be estimated (61. In
addition, smoothing and prediction are related in a recursive manner, i.e. a predicted value
depends on the last smoothed value, and a smoothed value t h into account the last
l51,[71:
or acceleration.
The problem then is narrowed down to obtaining the "best* estimate of i ( k ( k ) . There
are two solutione for extracting the k t " smoothmg estimate. The h t , is the Least
Squares method, the other is the Minimum Variance method. Generally, the Least Squares
method (the one under consideration) takes a fitting function and fits it to the data. The
method calculates the residuals (differences between the obsewations and the fitting func-
tion), squares them, ad& them, and produces a certain vdue. The Leaet Squares method
7
in its most general form, then minimizes that value, for any arbitrary number of dimen-
sions. The Mimum Variance method is similar to least squares, but is more generalized.
Minimum Variance take every o k m t i o n and weights each precisely according to ite mer-
its. For example, poor observations have a large variance while better observations have
a smaller variance. Typically, observations are weighted by the inverse of their variance,
hence poor obeervations are suppressed, while good observations are boosted relatively (61.
A comparative study of five important real-time tracking filters was conducted in 181.
It compared these filters in tracking accuracy and computer requirements (memory and
execution time).
The filters considered in this study were: the Kalman filter, simplified Kalman filter,
a - fi filter, Wiener filter, and the two point extrapolator. The gain vectors of the firat
three filters were assumed to be calculated in real time. The last two filters (Wiener and
two point extrapolator) were both examples of stored gain vectors. The following is a brief
overview of each filter.
can in principle, utilize a wide variety of modele for measurement noise and trajectory
disturbance; however, it is often sssumed that theee are described by white noise with zero
mean [9]. This becomes a requirement for the filter optimality and introdurn the need to
have two augmented state variables in order to whiten the object maneuver and adapt it to
and maneuvering noise were modeled as white gauasian with zero mean, the Kalman filter
equations reduce to the Alpha-Beta filter equatiom with the parameter alpha and beta
The Wiener filter differs from the Kalman filter in that its gain vector being equal to the
steady state gain vector of the regular K h a n filter and is calculated off-line and stored
in memory. This results in considerable computational savings in addition to makiig it
simpler than any of the preceding filters. Because it has constant gain, the Wiener filter
requires no auxiliary equations to be solved and requires very little computer memory.
Thia filter is adaptable to a variety of moving objects and can track both maneuvering and
nonmaneuvering moving objects well. This is because its gain is derived from the Kalman
filter, which accounts for the statistics of object maneuver directly [8].
The a-8 filter coma in many different varieties. Some are deaigned to provide the beat
transient following capability for a constant velocity object, while simultaneously providing
the best minimum variance estimate of position and velocity [lo]. Other a-@ filters that
have been designed utilize the object maneuver statistics [I 11. If the performance criterion
ia dynamic minimieation of the total mean-squared filtering errors, the filter then takes
the form of the Kalman filter. if the design objective is to minimize the tracking errors
against a general class of trajectories, the corresponding a-8 filter takes even a different
form [s]. The a-8 filter considered in the simulation study [8] was designed to minimize the
mean-squared error in filtered (smoothed) position and velocity, under the assumption of a
9
constant velocity object motion.
All of the mentioned filters are recursive fading memory filtera. The simplest type of
filters that can be implemented is the 'almost memoryleas" two point extrapolator. This
filter uses the last data point to determine object position and the last two data points to
determine object velocity. Because this filter is essentially memoryless, its performance in
The result of the simulation study conducted in [8],showed that the most sophisticated fil-
ter, the Kalman filter, is the m a t accurate and the m a t costly to implement. Furthermore,
the Kalman filter, the simplified Kalman filter, and the Wiener filter generally performed
within 20 percent of each other (in terms of execution time and memory requirements). The
a - /3 filter performed on the average about 50 percent worse than the Kalman filter with
the greatest degradation occurring for maneuvering objects. The two point extrapolator,
uniformly performed more than 70 percent worse than the Kalman filter.
As for implementation requirements, they increased in the following order: two point
extrapolator, Wiener filter, a - @ filter, simplified K h a n filter, Kalman filter. The com-
plexity factor between successive filters was about two to one.
An attractive filter would be one that can achieve the performance of a K h a n filter,
both in the transient and eteady state periods; yet be easily implementable in real time.
Also, it will be very desirable for such a filter to have the capability of tuning itself to the
sensor and moving object characteristics.
In addition to the optimal transient and steady atate performance, we would like to have
a simple filter that can achieve this performance regardless of object dynamics. It is unde-
sirable to have solutions (for filter gains) that entail m i v e relationahips of considerable
10
co~ltpkity;it would be ideal to obtain a closed form solution and eliminate the recursive
process altogether at Ieast for the steady state (even if it were simple as in [12]), without
any degradation in performance. Nor would it be desirable to have a simple closed form
solution that can only provide optimal performance for a particularid object motion be-
havior (as in (111 where it is assumed that object accelerations are exponentially correlated,
and (101 where the results apply for constant velocity objects only). This means that in
order to reduce the implementation cost, it is desirable to have constant gain vectors. This
will result in considerable savings over 6lters that calculate the gain vectors in real time.
h m the results of the simulation study, a probable filter that fits most of the above
descriptions would be the Wiener filter. However, the performance of this filter im the
transient state is not optimal, because its off-line computed vector is the Kalman steady
state gain vector. Using the steady state gain in the transient state will give erroneow
predictions.
A recent study (51 provided optimum parametera for the a=@filter which results in o p
timum tracking in both the transient and the steady states. With these parameters, the
a-8 filter achieves the performance of the Kalman filter without increasing its complexity
or implementation cmt.
The above mentioned study introduced an optimal filtering solution for the object track-
ing problem which depends on a parameter dehed as the W.aclting Indexn which is pro-
portional to the paition uncertainty due to object accelerations to &at due to measurement
errors. Upon evaluating this parameter, the optimal transient and steady state gaina are
11
specified. The atering procesa is as follows 161:
Prediction:
Smoothing:
where,
In modeling the object motion, a one dimensional, linear, time invariant, ideal model is
used:
where a ( k ) is the moving object state vector at time k; 4 is the state transition matrix;
w(k) is the unknown object maneuver/state transition matrix. 9 ia the acceleration state
12
transition matrix (for a second order model $ = [:TI TIT;for a third ordv model
$ = [bT2 T 1IT. A two state model which includes all possible maneuver accelerations
[5] is sufficient and will be considered hereon; that is
The model in our application is based on the assumption that, without maneuvering (or
with smooth maneuvering in a small time interval), the moving object will generally follow
a straight line constant velocity trajectory.
The noisy object measurements are modeled by the actual position of the moving object
plus an additive noise component, i.e:
and the measurement noise uncertainty is assumed to be a eero mean white stationary
a,, : The measurement noise standard deviation which is determined from the object de-
because the moving object may not be accelerating at the maximum rate. The object has
a probability PI of accelerating at thia mrurimum level (either plus or minus), a probability
The tracking index ia provided below in term of the above parameters and also in terms
As for the optimal a* relationship, it had to be derived and will be given in the following
chapter.
p* = 2(2 - a') - 4 @ 7
The optimum transient Mter gain parametera are based on following recursive approxi-
mations:
14
Figure 2.1 Typical Pmbabiity Demity of Object Acceleration.
a ( k ) = o ( k - 1 ) + Ga[a* - ~ ( -kl)]; Ga = 1 - e - l f k m
where,
cr(k) and B(k) are the gains for the present state
a(k - 1 ) and B(k - 1) are the gains for the previous state
a* and 8' are the steady state optimal gain values, ae defined on the previom page.
K, and Kg are the first order time constants of the corresponding gain excursion from
+
it8 initial to its optimal steady state value. It has been shown in [5] that these time constants
However, (51 does not provide an expression for the relationship between the tracking
index and these time constante. It does, on the other hand, provide the graphs for the
normalized time conatants vs log(A2), as shown in Fig. 3.
When the filter parameters are adjusted according to the above equation, the filter pro-
vides the best transient following capabiity for a constant velocity object, while simul-
taneously providing the best minimum variance estimate of position and velocity of any
15
fixed parameter Wter [lo]. The following chapter will discuss implementation details of the
elected filter.
CHAPTER 3
The cr-8, a-@-7filters, and the Two Point extrapolator have been implemented in the
simulation program. The equations for each filter are provided in Appendix I.
These three filters were implemented as an illustrative tool during our study. Then the
a-@ filter was chosen to perform the tracking, while an a-8-7 filter was implemented in
the learning procedure devised for inferring the dynamics of the moving object and hence
The following sections will consider both IYters since both are used by the simulation
Pww"l.
The t r d i index, A, plays a major role in determining the transient and the steady
state g a b of the a-/?and a-b-7 filters. It is a dimensionless parameter proportional to the
ratio of the position uncertainty due to object accelerations (maneuvers) and to that due
It ia defined by three primary object trackiig modeling parameters: track period (time
T, the track period always has a known value. h for determining a, and a,, one would
need to have an a priori knowledge of the defection mechanism and the object dynamics
qectively. Obtaining the values for these parameters will be discussed later on, but for
now we will assume that these values are available to ua and hence we have a value for the
tracking index A. Once A is known, we are able to calculate the filter transient and steady
state gains.
The program then calculates the transient gains at each sampling interval until the op-
timum steady state value, corresponding to that gain, has been reached.
The transient gains for the gain parametera a, @,and 7 are based on the reclvsive
approximations that were given in Sec. 2.2 and are repeated here for convenience (with the
addition of the third state parametens, i.e. acceleration):
where,
a(k), @(k), and 7(k)are the gains for the present state
-
a(k - I), @(k I), and 7 are the gains for the previous state
a * , B+, and 7' are the steady state optimal gain values.
k, , ka, and k7 are the &st order time constants of the cormponding gain e x m i o n
19
from its initial to its optimal steady state value. It has been shown in 151 that these time
consfants are strictly a function of the tracking index. However, [5] does not provide an
expmion for the relationship between the tracking index and these time constants. It does,
on the other hand, provide the graphs for the normalid time constants versus log@), as
shown in Figure 3.1. (The normalized time constant values were numerically approximated
by wing the KaIman filtering process).
In order to make these graphical relationships available to the program, one could divide
the t d i n g index range into subranges and provide the normalized time constant values
for each subrange endpoints (nodes) and estimate the values within the subranges, through
interpolation. This is required because the program will need these time constant values to
calculate the gains, and it needs to do so for any tracking index value.
The most suitable interpolation method for this purpose is that of Cubic Splinea [13j.This
is one of the most common piecewise polynomial approximations. It uscs cubic polynomials
to interpolate between each successive pair of nodes. There are several reaa011s for choosing
this type of interpolation, among them:
(1) The oscillatory nature of hi$ degree polynomials used to approximate an arbitrary
function on a closed interval, and the fact that a function over a small portion of the interval
can include large fluctuations over the entire range, restrict their use when a smoother
approximation is desired.
these points.
Figure 3.18 Fimt-Order Time Constatfor a-@ Filter ( h m 151).
A final note on Cubic Splines is that either one of the following set of boundary conditions
should be satisfied:
(1) Free boundary: The second derivative at the interval end points are zero.
(2) Clamped boundary: The k t derivative of the interpolant at these end points are
equal to the function first derivative at these points.
For simplicity, the free boundary condition has been used in the program.
Now, we d d b e the process of obtaining the optimum steady etate gains. For the
a-fl filter, the relationship between a and the tracking index had to be derived from the
following:
As for the a-&r filter, the relationship between a and the tracking index was derived
form:
The derivation gives the following result (by eliminating and 7):
We mhe the above equation numerically for a wing the Newton Raphson method [13]
which givea the positive real root that we are seeking (which lies between 0 and 1.)
Fig. 3.2 shows a flow diagram for obtaining the atens gains.
Each filter uses a different initial value for the smoothed eetimatea; the procedure for
The a-8 filter uses a two-point measurement process for the initial position and velocity
estimates:
The a-8-7 filter uses a threepoint measurement initiation process:
A case study was used to aid us in the understanding of the filters behavior. It also aided
us in testing our developed techniques as in the caee of the learning process, we developed,
to be used for determining a, of the moving object. When we chose the simulation model
for this purpoee, we had two objectives in mind. The first was to have a model that tests
the robustness of each filter; the second was to have a model where the primary tracking
modeling parameters could be calculated in closed forms. The latter, helped us in perform-
ing the simulation under a controlled environment which is an important requirement for
testing the filters and developing other techniques.
The chosen simulation model consists of sinusoidal oscillations both in the X and Y
i.e., it is ' of the maximum acceleration value. This is to be expected since the probability
3
density function takes the form shown in Figure 3.3.
As for the sampling interval T, it could range from 20 to 50 samples of a full cycle of the
The measurement noise which is awumed to be white gauaaian, has a standard deviation
equal to a small fnetion (A- $)of the maximum sinusoidal amplitude, i.e.
To test which of the three filters has the best performance, we calculated the standard
deviation of the difference between the predicted and model d u e s . Table 3.1 shows these
standard deviations for some of the runs. As expected, for this continuous acceleration
Except when the tracking index is relatively high, the program starts the filtering procees
by implementing the transient gains. Had not this been done, the steady state value of or
(corresponding to a moderate-blow tracking index), which in this case could be excessively
small, would have been used to perform the tracking during the transient state. The
latter would make it difficult for the filter to catch-up with the next measured position.
The transient gains in the initial state proved to be very useful since they provide larger
gain values (and then fall down to the optimum steady state dues.) Thb means that
initially, it is more important to catch-up with the next position rather than to filter out
the noise. With each predicted position, the filter gains are further reduced (to allow for
more smoothing of the measured position and to get a better accuracy) until the steady
state value, corresponding to each gain, has been reached.
It was mentioned earlier that in our application, the moving object will not perform
severe maneuvers; thus, the superior maneuver following capability of the cr-/3-7 filter will
be somewhat wasted. This was one of the deciding factors for choosing the a-B filter over the
a-8-76lter. In addition, it was shown in [5] that the accuracy of the prediction/smoothing
25
Two Point Ehtnpol;rtor a-p-7 Filter
optimum a than the one provided by the a-@-7filter (for the same A - as can be seen from
Fig. 3.4), we preferred to use the a-j9 hlter.
In the next chapter we will discuss two major remaining points. The first is how we
provided the a-p filter with an adaptive learning capability. The second, is how this fitter
In the previous chapter we wumed that the three fundamental tracking modeling pa-
rameters a,, a,, and T were available to us and we deferred the discussion on how we obtain
In order to make our filter practical to use, it would be necessary for us to provide the
filter with these parameters. Determining the first parameter, a,, depends entirely on tihe
moving object dynamics; the second parameter, a,, depends on the method that gene-
the object position valuea. The third parameter, T, ia simply the sampling period, i.e. the
time between mcceesive position samples. This paremeter is always known and in our case
and a,.
4.1 Determining a,
a, is a quantity that reflects the uncertainty of the moving object position due to its
acceleratiom. The degree of accelerations may vary from one moving object to another.
How do we determine a, for any moving object that might be of intereat to us? The idea
of a "learning" tracker evolved when we tried to answer this question. This means that
27
prior to performing any track'mg, an approximation to a, will be cdculated off-line using
position data obtained as a typical test run. Then the cr-/3 filter will use this value for future
tracking.
We begin our explanation of the process by introducing the underlying basic concepts
Let a be a random variable that could take any value in the range fA; where A is the
maximum acceleration that the moving object undergoes. Let us assume that we have N
consecutive position samples of the moving object. We can calculate the acceleration at
each point using the two preceding position points in addition to the current point, i.e.
where
Note that our notation z(i) represents a general position point value, not necesrrarily the
X-coordinate; i.e. s ( i ) implicitly indicates X or Y. a, is derived for both directions X and
Y; each has its corresponding a,, i.e. a,, and a,, . We will use the notation a, to represent
either direction.
The resuiting a, value would have been used to calculate the tracking index for the
tracking filter had it not been derived from the a; values, because the a; values were derived
from the unreliable noisy object position data. However this d u e could be das an initial
approximation to the actual oa.We can obtain a better approximation if we use a &red
version of the noisy data points. Here, the a-#?-7filter comes to play.
The a-fl-7 filter is run iteratively with each iteration using the smoothed position values
that the filter calculated during the previous iteration, That is, at each iteration, the filter
produces the object position values had there been a lesser amount of noise present in the
data (than that present in the data of the previous iferation). The quality of filtering-out
the noise depends on the values of the filter gains, a,j9, and 7. These gains are calculated
from the tracking index which in its turn is calculated from T, a,, and a,. Let us assume
that on is known at this point. We how the value of T and we have an initial approximation
to v,. When the a-8-7 filter is run on the noisy position data for the hat time, it uses
the initial approximation of a, (which we derived above) to calculate an initial value of
the tracking index. Then it calculates the corresponding gain values and usea them to
calculate the predicted and smoothed position, velocity and acceleration values, For the
second iteration, the filter uses the smoothed acceleration values from the first iteration
to calculate a new improved approximation for a, and the process is repeated again. The
29
next iteration will produce even better values because the newly cdculated a, is a closer
approximation than its previous value. The whole proce-w (see fig. 4.1) is repeated until
the newly calculated a, asymptotes to a d u e that is closest to the actual 0,.
We tested the above procedure using the simulation model (discwed in the previous
chapter). The resulting a, was identical to the theoretically calculated value (as in sec
3.2) without the presence of noise. As we increased the noise level, the deviation from the
theoretical value increased.
a, is a measure of the level of the uncertainty in the object position due to certain e m m
detection algorithm that was discussed in Chapter 1, to supply our frackiig filter program
with the moving object position; hence, u, corresponds to the errom introduced in this
detection algorithm.
Recall that detecting the moving object may occur at any one of the five pyramid levels,
(once an object has been detected, the algorithm calculates the center of the object and
passes that as the position value). Each pyramid level has a corresponding a,. For example,
one does expect the noise level in the lower mlution image to be greater than that in a
higher resolution image. A safe assumption, (that was later proven to be correct), was that
the noise level increases by the same factor at which the image resolution decreases, e.g.
the noise level in a 32 x 32 resolution image is approximately 4 times that in the 128 x 128
resolution image. Then it is clear that once we obtain a, for any one of the pyramid levels,
30
cddmk a. fmm I rat w pazttoa dua panu
I * - - c . M a u a', 8',1'
A
'-+
cdcul.u new a.,. a., u a q rmoolhcd vcdmtim nha
' The pmcrdure lor cdculaing (b. l n r i a r gain .h& ore r t h l dmm i Fi8. 3.2
with an ulditimd pis 1.
"Nomewrcl~tdb.ds.b.urrnur+(b.wcolc11~dY.POibl.
The measurement noise present in any of these levels is mainly due to quantization noise?
Let us consider on for the 256 x 256 original image. We will perform our derivation for
a one-dimensional model since, in our case, a, in the X-direction ia identical to that in the
Y -direction.
Our model is shown in Fig. 4.2. Let L be the length of a stretched wire. Let X I and xz
be the p i t i o n of the end points on the X-axie; and let z1, and 2~~be the positions of the
end points after quantization. Let c be the difference between x, and x (i.e., x, = x + c).
This is a random variable whose probability denaity function (pdf) is uniformly distributed
between +$, where A is the quantization step (see Fig 4.2b).
We would like to derive an expression for on b a d on the variance of the estimate of the
, represent this quantity. We proceed aa
object center (here the center of the wire). Let 6
follows:
Thus we can express ,&,, in terms of the actual center of the object with an additive e m r
factor i(cl + c2), i.e.:
Figure 4.2a Mode1 Used in Calculating tbt -ion Noise. L Here i the
A c t d Length Before Qurntbg.
therefore,
hence,
n is the image level. That is, a, for the second pyramid level is
%; for the third level,
a; etc.
A final note is that if the moving object is being detected in the third level, for example,
our tracking algorithm uses the an that corregponds to this level to calculate the t d i g
index. It is a simple matter for the detection algorithm to pass the pyramid level value
These results were tested on position data files that the detection program produced
(from the Pyramid Machine - IBM R!I' setup). Our tracking algorithm performed best
when we used the proper a,, , i.e., the one that corresponded to the pyramid level where the
object was detected.
A typical image frame, obtained by our syatem, is shown in Figure 4.3. This ia the
original 256 x 256 image which is a part of a series of frames from which the position data
of the detected moving vehicle was obtained. For this particular frame, the proper o
. is a
which corresponds to the fourth (last) pyramid level. The vehicle image can be detected
at this level because it occupies approximately two pixels out of 16 (in the fourth level), as
seen from Figure 4.3.
Figure 4,3 A Single h e h m a Series of Fhunes Obtained by the
Pyramid Macbhe (from whkh the poeition data of the
detected moving vehicle waa obtained).
CHAPTER 5
1. Provide the a-p fllter with optimum on-line adaptive learning capability.
.
[2] Bandopadhay A., Aloimonous J , "Active Navigation: 'hacking an Environmental Point
[3] Van der Wal G., Sinniger J., 'Real time pyramid transform architecture," SPIE Vol.
579 Intelligent Robots and Computer Vision,1985.
[4] Anderson C., Burt P., Van der Wal G., 'Change detection and trackiug using pyramid
transform techniques" ,SPIE Vol. 579 Intelligent Robots and Cornput et Viaion, 1985.
[5] P. Kalata, T h e tracking index: A generalized parameter for cr-8 and a-8-7 target
trackers," IEEE Iltaw. on Aerospace and Electronic Systerna, Vol AES-20, March 1984, pp
174-182.
(61 Morrison N., Tracking and Smoothing.In Eli Brookner (Ed.), Radar Technology, Dedham,
[7] Brookner E.,The Kdman Filter.In Eli Brookner (Ed.) Radar Technology, Dedham,
Mass., Artech House, 1977.
[8] Singer R., Behnke K., " Real-time tracking filter evaluation and selection for tactical
36
application^,^ lEEE Ram. on Aerospace and Electronic Systema, Vol. AES-7, No.1, 1971.
[lo] Benedict T., Bordner G., 'Synthesis of an optimal set of Radar-while-scan smoothing,"
IRE Trana. on Automatic Control, Vol. AC-7, No.4 (July 1962, pp. 27-32.
[12] Acharya R., 'Dynamic Scene Model: An Estimation Theory Approach," IEEE Conjer-
ence on Pattern Recognition and Image Proceaaing,Las Vegas, Nevada, June 1982.
[13] R. Burden, J. Faires, Numerical Analysi8,third ed., Prindle, Weber & Schmidt publish-
[14] Skolnic M.,Introduction to Radar Systema, second ed. McGraw Hill, N.Y., 1980.
[15] Schleher D.,Artomatic Detection and Radar Data Proceaaing, Artech House Inc, Ded-
[16] R. Fitzgerald, 'Development of practical PDA Logic for multitarget tracking by micro-
Prediction:
z(k + 1Jk)= z(k(k)+ Tv(k(k)
Correction:
(2) a-8-7Filter
Prediction:
Correction:
x(k + Ilk) is the position estimate at time interval k t 1 given k samples (measurements)
Prediction:
x(k + l ( k )= z ( k l k ) + Tv(k1k)
Correction:
APPENDM I1
VAH.
11 The following arrays store the filters gains f n r t,ht? x a n d
y directions. *)
gain .x, gain_-y : array r2. . 3 , 1 . .3j of array -type;
gain-opt--x,gain-opt - y : array12. . 3 , 1 . - 3J of real ;
gain--type : array[l . . 3 ] of string-type;
(* The following arrays are used to indiclte il a p-tri-if:~~l~ir
gain of the fading memory filters has reached ste,-1Jy st;lC,e
or not. * )
steady _state_ x ,
steady_state._y: array[Z..3,1..3] of boolean;
( The following are first order time coristarits 1
+. r Ltj
the filter gain excursion from its initial stat#-2 LCJ its
optimal state value. * )
k--taw-x : arrayL2..3 , l . .3] of real;
k t a w - y : arrayf2..3,1..3]of real;
( 6 The f~llowing variables are satandard devialions for
maneuvering accelerations and measurement noisc. 4 )
sigma-a-.x, sigma--a. y ,
s i g m a _ n . - x , sigma-n-y : real ;
t r a c k i n g - i n d e x - - x , t r a c k i n g - . inde:~:-;. : r e a l ;
( The t o l l o w i n g a r e t h e m e a s u r e d , p r e d i c t e d ,
k i smr-1 ]tiic<i
o b . i e c t p o s i t i o n a n d v e l o c i t y f o r t h e x a n d y d i r e t ~ l - i t - l r l a+ )
m x, m y : a r r a y _ t y p e ;
P. x , P-Yl
s _ - x > S-_Y,
m.-v-.x, p-v-x, s_-v_ x ,
m v . y , p v - y , s v y : a r r a y r l . . 3 ] of a r r a y t y p e ,
s-a-x, p a x ,
s_a . - Y , p a Y : a r r a y - t y p e ;
(* T i s t h e s a m p l i n g i n t e r v a l between t i m e k a n d k t 1 'l'k~
E:
sampling-factor reduces t h e sampling r a t e by Llle arl$-8t-i~it-
s p e c i f i e d by t h i s v a r i a b l e . . # )
T : real;
s a m p l i n g -f a c t o r : i n t e g e r ;
( * miscellaneous * )
k, ctr, c t r l , ctr2 : integer;
max-runs : i n t e g e r ;
s : string-type;
option : integer;
delay-factor : integer;
filter-option : integer;
p t s f i l e : f i l e of c h a r ;
f ile.-name : stringl-121;
num. of - p t s : i n t e g e r ;
i:*I n c l u d e t h e C u b i c S p l i n e i n t e r p o l a t i o n p r o c e d u r e . t ,
C$I c s - _ e x t r a p .p a s t
FUNCTION Gauss : real;
( R e t u r n s a gaussian r a r ~ d o mvariables by summing 1 2 :;arnpl+-a ~ * t
u n i f ormlly distributed random v a r i a b l e u b t a i r l s d 1L.C,III t 11,.
prede f i n e d Random f u n c t i o n .*1
V ar
temp : real;
i : integer;
Begin ( * gauss *1
tcrr1p : = U . O ;
f o r i : = 1 to 1 2 do
t e m p : = t e m p + random;
Gauss : = temp - 6 . 0 ;
End; (.* gauss -V 1
PROCEDURE get-position( 1 : integer);
valid point ( based (2n how kar t h e new p o s i t it In i5 i 1:. &in I IIS-.
previous one I . If the point is inva Lid, I Glt F - L - ~ I C ~L ~ I A ~ C
r.al~i..~laiesan approximation to what t11e prt)pr:r. v~ L I 2~ L.ki( l d '{I
Begin ! t get-_pc)sition4 )
position _difference : = pos-dif -f actor * sampling i a c t ur;
for ctr : = 1 to sampling-factor-1 do
read(ptsfile, temp-x, temp-y) ;
read( p t s f ile, temp-x) ;
read(ptsfile, temp - y ) ;
if ( 1 2) then
begin
m-x[l] : = ord(temp..x);
m-y[lJ : = ord(temp-y);
if ((abs(m .x[1] - m-x[l-11)) > position_dilt?,.r-nt~e I t h~_tn
m-x[1] : = 2Km-x[1-I] - m-x[l-21;
if ((abs(m_-y(l1- m y[l-11)) > p o s i t i o n c l i l Lk~entcrl:r~l_t~r
VAR
v x, v y : array type;
sum a x , sum. s _y ,
s u m . s q u a r e d .a_.x, sum--squared-a -y : real ;
i integer;
:
junk f i l e : t e x t ;
f o r i : = 1 t o num.-of - p t s - 2 do
begin
sum-a-x : = s urn_-a--x + s -a -x j i ] ;
sum-squared-a-x := xl j 1 I ;
sum- s q u a r e d - a _ - x + s g r ( s- :i_
sum.- a _y : = sum-a-_y + s-a--y [ i J ;
sum-squared-a-y := sum _ s q u a r e d - a _y + ~ q r,.;( _-i y 1 i j !;
end ;
s i g m a - a-_x := of- _ p t s --
s q r t fs u m - _ s y u a r e d _ . a - _ x / r ~ u m
s q r ( s u m a x'nurn Q L ~ I S ) ) ;
sigma -a--y : = s q r t (sum-squared ..a yJnum of - p t s
s q r ( s u m - a y/num of p t s ) 1 ;
writ,eln;
w r i t e l n ( ' E s t i m a t e d m a n e u v e r i n g standard d e v i s t i c l i l i n Lh12' 1;
w r i t e l n O x direction is : ' sigma-a-x);
w r i t e ln;
w r i t e l n [ 'Estimated m a n e u v e r i n g standard devia t i o r ~ i l l t h u ' ;
w r i t e l n l ' y d i r e c t i o n i s : ' , sigma a 5 7 ) ;
w r i t s 1 n:
reset(ptsf ile ) ;
End;( + talc-sigma-a*)
PROCEDURE Get-option;
( r T h i s procedure displa;yrsthe menus a n d ~ b3 i tr 1 s t h k i :Ic. 15: I !:,-I
options. I *
Var
answer : char;
parameter : integer;
Begin ( % g e t option*)
answer : = ' y ' ;
clrscr;
b l r i t e l n ( ' 1 . Calculate an estimate of manel.lverit~c:5 1 t x t ~ c i x r ~ l
d c v i s ~ tor!
i ' ) ;
writ,eln(' from a given test run. ' 1 ;
writeln;
writein( ' 2. (~ontinueousacceleration t r a c l . i n g dr?ni,-)' I ,
writeln;
writeln( ' 3. Track using series of positior~soLlt aic1~3t-l
tl1c:
1-11.
' ,.
;
writeln( ' Pyremid machine' ) ;
writeln;
writeln( '4. Exit' 1 ;
writeln;
write( 'Please Enter optZion number: ' ) ;
readln(option);
if (option = catd ~ p t then
)
begin
clrscr;
while ( answer= ' y ' ) or (answer=' Y ' k do
begin
writ-eln(' The following parameters havo tlls 1u:~ing
1 1 - 1 1
valucs: ' ) ;
writeln;
writeln(' 1. X-Y frequency factor = ' , m);
writeln;
writeln(' 2. Radial frequency = ' , w:S:3),
writeln;
writeln(' 3. Phase difference = ' , phase:S::3);
writeln;
writeln(' 4. Number of samples of a fu1.L c.il:la vf
the i - a s t c r ' i ,
writeln( ' sinusoid = ' , n- sampling ;
writeln;
writeln(' 5. "SNR" = ' , n-_measuremen t no i st3 ;
writeln;
writeln(' 6 . Display delay ( m s ) = ' d e l a y i : - t c C ~ - ~ r ) ;
writeln;
write(' Do you like to change any of the p A r - J n l c t t ~ r s
( y , ; ~ l ) :' j ;
readln ( answer t ;
while (answer='y') or (answer='Y1) d(>
begin
writeln;
write ( ' Which parameter d o :y.l2~1 1 i k.t-. t 6- 'tiingl;
I1 ' 1,
readln( parameter ) ;
writeln;
-
if (parameter=l) then
begin
write( ' X-Y f reqi-xerlcy t ~ c : t 1.1 t- ' ) ;
readln ( m ) ;
end
else
if (parameter=2) then
begin
write ( ' Radial f r e q u irll ,, = ' 1 ,
read( .w ;
end
else
if (parameter=3) then
begin
write( ' Phase dif'-ff?rt-:rll~t;.= ' ;
readln( phase ;
end
else
if (parameter=4) then
begin
write(' Number of
samplus = ' ) ;
readln (n-sampling) ;
end
else
if (parameter=5) t h e n
begin
write('"SNR" z ' I ,
readln ( n - m e a s u r c n i c - . r ~ C
c ~ ~ - ~ i . - , + >;
end
else
if (parameter = 6 L1lt:n
begin
write( ' D i s p l a y (1e.lsy
(rnsj: ' J;
delay i at: t ~ )) r;
readlr~(
end
else
writeln( ' I n v a l i d
optic~a
writeln;
w r i t e ( 'Do you like t o change anotht-.r
Iy,'n): ' 1:
readln(answer);
end ;
end ;
end
else
begin
clrscr;
writeln;
write( 'Please e n t , e r test-run file n a m e : 1 ,
readlnt f i l e name I ;
assign(ptsfile, file-name);
writeln;
write( ' How many measured points d~?-3s thl-: t i L C i'-'(.~ntairl" ' ) .
readln(nrxn-of-pts ) ;
reset(ptsfi1e);
writeln;
( t( The following value will be normally p s a a t = ~ ~ L,yl Lilc
existing Motion Detection Program. t )
write( 'Enter The pyramid level at w h i c h tllc c~b,j~?c:t was
d ~ t l - . 't ,- t 2 < 1 : ' ) ;
readln(pyramid-level);
clrscr;
writeln( ' The following parametxrs tlsvf.: Lilt2 icr.11L I L J L I I ~
va1ut:s: ' ) ;
wr'iteln;
writeln( ' 1 . = ',
Sampling rate reduced by -3 l'--l~_+tor
sampling factor) ;
writeln;
writelno 2 . Display delay (ms) = ' , cl(-:lsy fact-or);
writeln;
write( ' Do you like to change any of the psr3rneLcrs
l-t(y r 1 j . ) ;
readln (answer);
while (answerz'y') or tanswer='YY)do
begin
writeln;
write ( ' Whirh parameter do you l i k . . \ t.r_, i : k ~ ~ l l g ~
(1 2 ) : '1;
readln( parameter) ;
writeln;
if (parameter = 1) then
begin
write( 'Reduce the sampling r a t e b y
a t a c t t ) r ~ f :' ' ) ;
readln(samp1ing-fact0
end
else
if (parameter = 2 ) then
begin
write( 'Display delay i nis ' I .
readln(de1ay-f actor) ,
end
else
writeln( ' Invalid option. . . ' ) ,
writeln;
write('Do you like to change a n o t h e r
(y/n): ' 1 ;
readln(answer1;
end ;
end ;
(option = cnise-opt) then
begin
filter-option : = 3 ;
T : = 0.0:33:3*samplin.g .factor;
calc- sigma pa( true) ;
end;
Procedure calc-alpha-2(t-i:real;
var opt -gain: real ;
( This procedure calcu1~-tes the optimum steady 5 L:it t- l i p l l ~ t ,,L-
the Alphs-Beta filter. .+f
var
b: real;
root : r e a l :
( t' This procedure calculates the nptimum steady st-at.c -1.lpha lor
the Alpha-Beta-Gamma filter . The Newton-Ftaphsor~mc t l l ~ ~is~ lt l s t c j
here for solving the cubic equation. * )
cons t,
to1 = 0.0001;
var
b , c , d: real;
p a , p : real;
f _ _ p , f .d p : real;
temp: r e a l ;
continue: boolean;
begin (*talc.-alpha-3*)
b : = 0.25*t-i*(t_i-16 ) ;
c : = 0.25*t-i*(48-t-i);
d : = -8*t-i. 3
p@ : = 0 . 5 ;
temp : = sqr(p0);
continue : = true;
while continue do
begin
temp : = sqr(p0);
f-p : = pO*temp + b*temp + c*pO + d ;
f - d - p : = 3*temp + 2*b*p0 + c ;
P : = PO- f..p/f-d-P;
if (abs(p-pO)<tol) then
begin
opt.-gain : = p ;
continue : = false;
end
else
po : - p ;
end ;
e n d ; f 'tical c.-a l p a - 3 % )
Eegirl ( %ale g a i n s * 1
i f ( f i l t e r option = 2 ) then
begirl
c a l c - - a Lpha-2 ( t r a c k i n g - i n d e x _x, g a i n opL x 1 2 , l 1 ;
gairl_opt_xL2,21 : = 2 * ( 2 - g a i n - o p t - x l t : , l I ) 4
*
s q r t ( 1 - g a i n ctpt : - r ( l ; l , I l ~ ,
calc - a l p h a _2 ( t r a c k i n g - i n d e x - . y , g a i n - o p t j.. 1 2 , l 1 i ,
gain-opt-y[2,2J := 2 * ( 2 - gain o p t - y l 2 , l ) )-
* s q r t ( 1 - gain-opt-;lZ,l I ;
end
else
begin
c a l c - - a l p h a . - 3 ( t r a c k i n g - - i n d e x . - x , g a i n - o p t - xi 3 , l 1 ) ;
g a i n _ o p t _ x r 3 , 2 ] : = 2 :* ( 2 - g a i n - o p t x / 3 , l 1 ) - 4 .
+ s g r t ( 1 - g a i n cjpt :A( ' 3 , 1 1 1 ;
gain-opt--x[3,3] := s q r ( g a i n -opt-x[ 3 , Z I 1 ,
gain opt x [ 3 , l ] ;
c a l c - - a l p h a - - 3( t r a c k i n g - i n d e x - y , gain-upt-i. 1 3 , 1 j ) ;
gain.-opt-.y[3,21 : = 2 * ( 2 - gain-c3pt_yl3,1]) - 4
* sqrt(1 - g a i n o p t _ y [ 3 , 11 ) ;
gain--opt.-yC3, 31 : = s q r ( g a i n - - o p t - - y [ 3 , 21 I /
gain-upt-yl3,ll;
end ;
for i:= 1 to 3 do
begin
if (option=catd-opt) then
begin
model-x[ i J : = x_mag * sin( w*i:*T ) ;
model-yti] : = y--mag cos(m*w*i'KT+pllase) ; *
m-x[:i'l : = model -x[il + sigma-n x E. Gauss;
m-y[i] : = model-yEi] + sigma-n_y t Gauss;
end
else
if (option=spoprn-opt) then
get-position(i);
end ;
( The following are the initial estimates #>f the Tt~v k'c~iilt
extrapolator, Alpha-Beta, and Alpha-Beta (4nmmcl 1 i l t i : r * s ,
respectively. *)
if t iiltcr-option=l ) t h e n
begin
s-x[l,l] : = m-xr3-j;
s-yCl,Il : = m-yr31;
s-v-x[l.l] : = (m-x[3]-m_x[21 ) / T ;
s-v-yC1,lI : = I m - ~ ( 3 1 - m y[2])/T;
end
else
if i l t e r _ o p t i o n = 2 ) then
( f
begin
s_x[2,1] : = m-x[3] ;
s_yC2,11 : = m _ y r 3 ] ;
s - _ v - x [ 2 , 1 1 : = (m-x[3]-m-x[21)/T:
s . _ v - ~ [ 2 , 1 1: = (rn-y131-m-_yr21 j,'T;
end
else
begin
s _ x C 3 , 1 1 : = m.-x[3];
s - y r 3 , l j : = m-y[3];
s-v-x[3,1-j : = (3*m-x[3]-4~*m-x[2)+m-:.r[l J ),/(2+-T);
s-v-y[3,1] : = ( 3 * m - y [ 3 ] - 4 * m - y [ 2 ] + m _ y / l 11 i i i ( 2 $ T ] i
s-a--x[l) : = (m-x[3]-2*m-x[2]+m--x[I] ),/sqr(T1 ;
s-a-y[lI : = (m-~[3]-2*m-~f2]+rn-y[l]),sqr('I'i;
end ;
End; (*initialize-filter:*)
PROCEDURE Calc-trans-gain( f i l t e r - . i d , g a i n - i d : i n t e,.gt:l ,
~ ; o f > r d i n ~ t .. e ~ f h a r ) ;
(* T h i s p r o c e d u r e c a l c u l a t e s t h e f i l t e r g a i n s t a l p h a , tc Li.1, <iii:.l
gamma 1 d u r i n g t . h e t . r a n s i t i o n p e r i o d . I t r e t u r r t s 2 t . . r t . ~ e~ 3 l a c ~ : .
when t h e s t e a d y s t a t e , o p t i m a l g a i n v a l u e h a s b e c r i rc:a!:llcJ,
f a l s e o t h e r w i s e . :%)
Corlst
error-percentage = 0.1;
B o g i ~( ~
Xcalc -t,rans-gain* )
i f (coordinate = ' x ' ) then
begin
g a i n - x [ f i l t e r - - i d , g a i n - _ i d k]
, : = g a i n - - x l f i l l,oc i l l ,
g a i n - - i d , k-11 + ( 1 - e x p ( - l / k _ - t a w - x r f i l t e r - i d ,g ~ i ni d 1 I I
tr ( g a i n _ - o p t- x [ f i l t e r - i d , g a i n _ _ i d l - g a i n t i l t c r ill,
g 3 i u i d ,k- 1 ] ) ;
i f (abs(100*(gain_x[filter__id,gain_id,kj-
gain--opt -xrf i l t e r - - i d .g a i n i d j I /
gain-opt- filter i d , g a i n i d ] r .
e r rt L I Lllcn
s t e a d y - s t a t e -x[f i l t e r - i d , gain- i d ) : = t r w 2 ;
end
else
begin
g a i n - y r f i l t e r - i d , g a i n - i d , k l : = g a i n - y [ f i l L + - ? ri l l ,
g a i n - - i d ,k - l ] + (1-exp(-l/k_-taw-y[filttr i 4 , g a i n i d 1 r )
+- ( g a i n . - o p t _ y [ f i l t e r - i d , g a i n i d ] - g a i n - y 1 f i l t ~ l ri d ,
gilicl i d , k- 1 1 1 ;
i f ( a b s (lOO*(gain-y[f i l t e r _ i d ,g a i n _ i d ,k ] -
g a i n _ o p t _ y [ f i l t e r _ - i d ,g a i n i d ] i i
gain-opt-y [ f i l t e r - i d , g a i n - . i d I ) <
error-percentage) then
s t e a d y - s t a t e - y [ f i l t e r - i d , g a i n - i d ] : = LI-ue;
end ;
End ; ( f c a l c - _ t r a n s - g a i n * )
PROCEDURE initialize;
Begin ( * initialize
gain-type[l] : = 'alpha';
gain-type[2j : = 'beta';
gain-typeC31 : = 'gamma';
delay -fact.or : = 0;
m := 2;
w := 6.28;
phase : = 1 . 5 7 ;
n- sampling : = 20 ;
n -measurement-.noise :
sampling_f actor : = 1 ;
- 256 ;
x-mag : = 1 2 5 ;
y .mag : - 75;
get-option ;
End; ( * initialize ;+')
PROCEDURE add-measurement-noise;
(* This procedure adds noise t o the ideal model .Lr-,itntiun. 'I'he
noise is white zero mean. * )
Begin
m-xlkl : = model.-x[k] + sigma.-n-x * Gai~ss;
m-_y[k] : model--yrkl + sigma-n-y :# Gauss;
End ;
PROCEDURE p r e d i c t - l ( k : i n t e ~ e r ) ;
I f The p r e d i c t i o n i n t h i s p r o c e d u r e i s based o n t h i t elf thz-: 'I'675-,
Point Extrapalator. * )
B e g i n ( '*predict.-1.r:)
p _ - x [ l , k ] : = s _ - x [ l , k - 1 1 + T*s_v-x[l , k - 1 1 ;
P ~ C l , k l: = s - - y [ l , k - l ] + T * s . v - y [ l , k - 1 1 ;
p-v_xll, k l := s--v-x[l, k - l ] ;
P - v - Y I ~ , ~: =~ s - v - y [ l , k - 1 1 ;
End; ( *predict-1 r )
PROCEDURE s m o o t h - l ( k : integer);
Begin (*smuoth-1%)
s - x [ l , k ] : = m-x[k];
s - y [ l , k l : = m-y[k];
s - v - x l 1 , k I : = (m-x[k]-m-x[k-11 )/T;
s - . v - y r l , k ] : - (m-yCk1-m-y[k-l])/T;
E r t d ; (*smooth-.l*)
PROCEDURE predict_2(k:integer);
('+ The predicition in this proc:edure is based on that L~ the
Alpha-Beta Filter. * )
Begin t +predict--:!r:)
p - x i 2 , kl : = s-x[2, k-I] + T*s-v--x[2,k-I];
p_ Y I 2 , k j : = s-y[2,k-I] + T*s-_v-y[2,k-ll;
p - v - x [ 2 , k ] : = s-v-xr2,k-11;
p _ v - - y l 2 , k l : = s-v-yr2, k-11;
End ; ( rpred ic t - - 2 ' k )
Begin (*smmoth-2r)
difference-x : = m-x[k] - p-x[2,k1;
difference_y : = m_y[k] - p-y[2,k];
s_x[2,kl : = p-x12,kl + gain-x[Z,l,k]*difference x ,
s - y C 2 , k J : = p-yt2,kl + gain-y[2,1,k]*difference-y;
s-v-x[2,kl : = p-v-x[2,kl + (gain-x[2,2,k]/T)+differe11~:e x ;
s _ v _ y C 2 , k I : = p-v-y[2,kl + ( g a i n - y [ Z , Z , k ] / T ) ~ d i t f ~ r : ~ -y ~; ~ r ~ ~ ~ ;
End; (*smooth-2*)
PROCEDURE predict_3(k:integer);
( t- The predicition in this filter is based 011 I hx t t ht-: A lphl
Beta-Gamma Filter. 3 )
Begin ( *predict-3*)
p-xf.?,kJ: = ~._~[3,k-ll + T*s-v_x[3,k-l1 + U . ! l t j q r ( ? ' , t s -J x l k . 1 1 .
~ - ~ [ 3 , :k= l s-y[3,k-l1 + T*s v-.y[3,k-Il + C ) . ~ + S ~ Y ( T 1)1+j 'E 1J.q 11;
p_v--xr3, kl : = s _ v _ - x [ 3 k-I]
, + T*s--a_-x[k-l
J;
F.-v-Y[Y ,kl : = s_v_y[3,k--ll+ T*s-a-y[k-I];
p-a-xrk] : = s-2-x[k-l];
p _ a - y / k l : = s a y[k-11;
End; ( *predict-3*)
PROCEDURE smooth_3(k:integer);
(* The smoothing in this filter is based on that; of t,he Alpha-
Beta-Gamma Filter. * )
V a r
difference-x : real;
dif f erence-y : real;
Begin ( *#smooth_3*)
d i f f erence_x : = m.-xlk] - y - x [ 3 , k] ;
difference--y: = m-y[kl - p--y[3,kl;
s - X I - 3 , k l : = p--x[3,kl+ gain--xr3,l,kl*differenr.e_;,.
s-yC3,kl : = p-y[3,kl + gain--yC3,l,k]*differenc'cCy;
s_-v-xr3,k] : = p-v-x[3,k] + ( g a i n - - x [ 3 , 2 , k ] / T ) * d i f ~ c r c r 1 1:,; ~c
s - v - Y ~kl ~ , : = p-v-Y [3,k] + (gain-y[3,2,k J / T )k d i t i c r t - . n ( . t . . y ;
s-a_-x[kl : = p-a--x[kl + gain--x[3,3,k]/(Z*sqr(?') ) + d i tLf~:r:?~ic+t3x ;
s-a-y[kl : - p--a-y[k] + g a i n - y [ 3 , 3 , k ] / ( 2 * s q r ( T ) ) * d i ~ F ' ~ ~ r5,;
~11~~~
End; ( Ksmmoth-3*)
PROCEDURE get-statistics(x1, yl, x2, y2 : array_-typl;~;
(:I: This procedure calculates the standard d e v i a t i t - ! n s 1r.f the
predicted and model values in both the x and the y dirir!: t . i l ~ a s .
:*: )
Var
zzave._x,zzave_y,
zave-.x, zave--y : real;
i : integer;
sigma-x, sigma-y : real;
n : integer;
Begin (*drawp*)
if ( o p t i o n = c a t d . - o p t , ) t h e n
begin
x : = round(x_temp)+l60;
y : = round(y_temp)+100;
end
else
begin
x : = round(2240Jcx--temp/255) - 950;
y : = round(300.%y_temp/255) - 100;
end ;
draw(x-2, y , x + 2 , y , color);
drawtx, y-2, x, y + 2 , color);
E n d ; ( *drawp* )
BEGIN (*Track*)
initialize;
initialize-filter;
while (option < > exit-.opt) do
begin
if (option <> cmse-opt) then
begin
graphcolormode;
palette(2);
textcolor(2 1 ; write( ' R: predic+tcdl 1 ;
textcolor(3) ; write( ' y : modcl ' ) ;
textcolor( I ) ; writeln( ' t i : rnc?asurt:l-l' 1 ;
end ;
if (option=catd-opt) then
max-runs : = man-sampling+l
else
max-runs : = num-of-pts;
for k : = 2 to max-runs do
begin
delay(de1ay-factor);
if (filter_option=l) then
begin
predict-l(k);
drawp(p-x[l,kl, p _ y [ l , k f , p r color);
end
else
if (filter_option=2)then
begin
predict_2(k);
drawp(p--x12,kl,p-y12,kl,
y r .colclr ) ;
end
else
begin
predict_3(k);
opt 1 thcrl
if (option <'/ cmse--
drawp(p_xC3,kl, p - y l . 3 , k I ,
pr- '20lt~r ) ;
end;
delay(de1ay-factor);
if (option=catd-opt) then
begin
model-x[k1 := x--rnagt s i r i ( w t ( k + 21 +TI;
model-y[k] : = y mag *
i:(ss(rn*wv(k+2)t
'rt p ~ l ;~ l ~ ~
end
else
get-position(k);
if (option = catd--opt)then
begin
drawp(mode1-xrkl, ~ n v d c l. y l k l ,
fn<Jdc1 ~2<-> 1t-! I? ) ;
add_measurement..noise;
delay(de1ay-factor);
end ;
if ( f ilter_--option
0 1 ) than
begirl
if f ilter-option=2 ) t-lien
(
ctrl : = 2
else
ctrl : = 3 ;
for ctr:! : = 1 to f i l t - e r . o p t i c - ~ r qlcl
~
begin
gain_x[ctrl,ctr2,k j : =
gain-opt xi ctrl , c t r 2 J ;
gain_y[ctrl,ctr2,k] : =
gain-opt-y [ctrl, c t r v ;
end;
if not(steady-state-x[ctr1,11:tr2]) then
calc-trans-gain(ctrl,ctr2,'xJ)
else
ctr2,k]
gain--x[ctrl, := gai n-opt-x[
ctrl,ctr2];
for ctr2 : = 1 to filter--optiond(s
I c:trl,c t r 2 J )
if not ( steady--state--y
then
calc-trans-gain~ctrl,~t~r2,~y'~
else
gain_y[ctrl,ctr2,kl : =
gain_opt-y j ctr1 ,ctr2);
end ;
if (filter-option=l) then
I k)
smooth--1
else
if (filter_option=2) then
smooth-2 ( k )
else
smooth-3 ( k ) ;
end ;
readln;
graphcolormode;
palette(2);
end;
If (option C > catd_opt) then
close(ptsfi1e);
END. (*Track*)