Model Based Design of Video Tracking Based on MATLAB/Simulink and DSP

: The implementation of digital image processing on electronic boards is a current problem. In this study, we present a Model-Based Design of video tracking based on Matlab/Simulink and DSP. The implementation on DSP, of multi-objects detection and tracking algorithms of two kinds of applications inside and outside, is obtained by using automatic code generation that is code composer studio. The transmission and reception of data is realized by a network connection via Ethernet port between DSP and PC. This allows us, in the future, to extend the number of DSP working in parallel and their IP addresses would be generated by a DHCP server


INTRODUCTION
With recent advances of computer technology automated visual surveillance has become a popular area for research and development.Machines that see and understand their environment already exist and their development is accelerated by advances both in micro-electronics and in video analysis algorithms.
The video tracking system consists of the hardware system and the software development environment.The hardware system implements the function of image acquisition, storage, display and running of the detection and tracking program.Because, video processing and specially, video tracking, requires a large number of iteration, this leads to a large occupation of memory space.The use of a multi-cores processor (DSP or FPGA) helps to minimize the processing time and so work on real time.The software development environment is for the establishment of algorithm's model and the realization of the automatic code generation.Covering areas as diverse as automotive, aerospace, defense and Mechatronics, Model-Based Design is an efficient methodology to specify, design, simulate and validate real-time physical systems and associated algorithms (http://www.mathworks.com/model-based-design).
Moving video tracking is one of the most important methods in computer science.Recently, there are many approaches for motion detection in a continuous video stream.All of them are based on comparing of the current video frame with one from the previous frames or with something that we'll call background http://www.codeproject.com/Articles/10248/Motion-Detection-Algorithms).The challenge of detecting the movement lies in the ability to identify moving objects regardless of their size, their velocities and their contrasts with the background.For this, many algorithms have been proposed for object detection in video surveillance applications.They rely on different assumptions e.g., statistical models of the background (Wren et al., 1997;McKenna and Gong, 1999), minimization of Gaussian differences (Ohta, 2001) minimum and maximum values (Haritaoglu et al., 1998), adaptively (Seki et al., 2000) and (Koller et al., 1994), or a combination of frame differences and statistical background models (Collins et al., 1999).
Object video tracking, by definition, is to track objects over a sequence of images and in general, is a challenging problem.Different estimation algorithms are used in literature (Emilio and Andrea, 2011).One of famous algorithms is Kalman filter (Caius et al., 2010) and it can be applied to track groups.
The objective of this study is to do a model-based design of multi-objects video detection and tracking of the indoor and the outdoor applications.

MODEL BASED DESIGN (MBD)
Software development based on the model, automatic code generation, production and testing of computer are more established in recent years.The automotive industry has adopted and successfully deployed these methods in many sets projects around the world.This allowed the reduction of development time and better quality (http://www.mathworks.com/model-based-design) due to the automatic code generation and verification and early validation through simulation.So, the MBD is a methodology applied in designing embedded software.
In our study, a Model-Based Design is developed by using MATLAB/SIMULINK to design the indoor and outdoor applications and the implementation on DSP is automatically done, using CCS (Code Composer Studio) as a software-to-hardware conversion scheme.Because we made a TCP/IP connection between PC (data reading and data displaying) and DSP TMS320C6455 (data processing), two software architectures are designed, the main software block diagram system and the software architecture of the video processing system.
The main software block diagram system is run online, Fig. 1a and c.The main function of this module is transmitting video data from PC to DSP by TCP/IP network and receiving the video targets detection and tracking from DSP to PC also by the same network connection, in order to display these informations.
The whole software architecture of the video processing system is based on DSP/BIOS real-time operation system, Fig. 1b and d.It is built offline in order to generate the automatic code that will be lead on the DSP.The video processing bloc, Fig. 2, can be divided into three modules: network reception module, video processing module and network sending module.The video processing module contains both of detection and tracking algorithms, Fig. 3. Depending of the application (indoor or outdoor), the architecture can be effectively chooses.

DETECTION AND TRACKING
Detection: Motion detection is to separate on each image in a video sequence, the moving zones of the static zones.There are different detection methods all are represented as shown in the Fig. 4: In our research, we use differential method, especially reference image, as the way of motion detection.Depending of the application, the reference image can be static background (indoor application) or adaptive background (outdoor application).
Indoor application: Because we have chosen a stationary background method to build the referential image, we first send N-samples enable (N equal to 20) to the DSP (Fig. 1a and Fig. 2a).In this case, unlike to the case of outdoor environment, the reference image can be taken when the scene is empty.From Fig. 3a, we see that, in the indoor application the detection and tracking blocs, in the beginning, are disabled.So we use the first few frames of the video to estimate the background image.After that, the background estimation bloc turns off and the detection and tracking blocs become enabled.In this way, by buffering the first few frames, we get the referential image.The detection uses the absolute difference in pixel values between the input image and the background image to determine which pixels correspond to the moving objects in the video; this allows the separation of the pixels that represent objects from that represent background.Mathematically, the detection is given as following: where, D ୲ is the absolute difference image in pixel values at time t between the input image I ୲ at the same time and the stationary background I ୰ୣ .This operation does not often give, to it alone, good results on a real image where the intensity changes are rarely sharp and abrupt.A thresholding operation is indeed necessary to eliminate the noise.So after using the autothreshold bloc and erosion bloc as filters we get our detected objects.
Outdoor application: In contrast to the indoor application, in this case we should choose the adaptive background method to build the referential image, because we have no idea about the scene, that's why, we just need to sent alone, the input video to the DSP processor (Fig. 1c and Fig. 2b).And from Fig. 3b, we see that all reference image, detection and tracking blocs, runs at the same time.So during the all execution of the application, the background is estimated, to be adaptive.The referential image is given by the equation: where, I ୰ୣ ሺp, t + 1ሻ and Iሺp, t + 1ሻ is the intensity values of pixel p at the time t+1 in the referential image and the current image, α is the forgetting factor ሺαϵሿ0,1ሿሻ.Similar to the indoor application, the difference image is given by the same equation of D ୲ Eq. ( 1) and the detection is done also in the same way as the indoor process.
Tracking: The process of estimating over time the location of one or more objects using a camera is referred to as video tracking.Generally, the different types of tracking algorithms, [http://www.mcn.ece.ufl.edu/public/taoran/website/mysite/object% 20 tracking.htm], are shown in the Fig. 5.
In this study, we chose the probabilistic method to do the tracking, because all detected objects are represented by points.Figure 6 shows us that, first in both cases, indoor and outdoor, the same strategy is used to estimate the positions of the detected objects.Second, before doing the merge blobs belonging to the same target and the Kalman filter to the tracking, we start by the blob analysis block to calculate the centroid of the blobs and output the number of blobs found.

Merge blobs:
The aim from this step is to selects a blob for determining its distance to other blobs and to computes, the distance between the selected blob and all remaining blobs.Check the distance between the current and reference target that means, compute the pixel distance between the current and reference positions.In our case, we chose the MANHATTAN distance as a pixel distance.It's given by the equation: where, d is the MANHATTAN distance between the current position represented by pixel cሺx ୡ , y ୡ ሻ and the reference position represented by pixel rሺx ୰ , y ୰ ሻ.So if the distance is within threshold then we update the reference target by merged blobs and reset the current ones.Otherwise, we keep the values of the blobs.
Figure 7 shows us how to merge the centroids if their distances are less than the threshold by computing the MANHATTAN distance and updating the current and reference positions.The threshold is fixed by the user before running the application in the parameters bloc (Fig. 1a and c).

Kalman filter:
The Kalman filter block uses the locations of the centroids detected in the previous frames to estimate the locations of these in the current frame.Based on Caius et al. (2010), from the basic kinematic equations with constant acceleration and value of the sampling period set to 1, we have: Here, the subscripts x and y refer to the direction of the object's position (s), velocity (v) and the constant acceleration (a) in the two-dimensional plane.The above equation can be writing in that way, is because the process model is characterized by the assumption that the present state, x ୩ , can be related to the past state, x ୩ିଵ , as follows: where, W ୩ is a discrete, white, zero-mean process noise with known covariance matrix, Q ୩ and Φ ୩ is the state transition matrix which determines the relationship between the present state and the previous one.In our case, Φ ୩ is deduced directly from Eq. ( 4) and the process noise covariance is taken like this: The measurement equation is defined as: where, z ୩ = The measurement vector V ୩ = Discrete, white, zero-mean process noise with known covariance matrix R ୩ Eq. ( 9) H ୩ = The matrix that describes the relationship between the measurement vector z ୩ and the state vector x ୩ , called measurement matrix: Measurement noise covariance: The main role of the Kalman filtering bloc is to assign a tracking filter to each of the measurements entering the system from the detection bloc.We know that, the Kalman filter attempts to improve the prior state estimate using the incoming measurement which has been corrupted by noise.This improvement can be achieved by linearly blending the prior state estimate, x ො ୩ିଵ , with the noisy measurement, z ୩ , in: x With x ො ୩ ି means the a-priori estimate, K ୩ is the blending factor.The minimum mean squared error of the estimate is obtained when the blending factor assumes the value of the Kalman gain: where, P ୩ is the state covariance matrix, generally it's a diagonal matrix.The state covariance matrix is determined from the a-priori state covariance matrix as follows: After that, the Kalman filter makes projections for the next value of k.These projections will be used as the a-priori estimates during processing of the next frame of data.So the projection equations for the state estimation and for the state covariance matrix are as following:

IMPLEMENTATION AND RESULTS
Here we present the results obtained from our model-based design of video tracking of the indoor and outdoor applications.We note that, the user can select Fig. 8: Experimental equipments previously, in the parameters bloc (Fig. 1a and c), the number of tracked objects and which target result will be displayed.The Fig. 8 shows the experimental equipments.
We used an ADC to convert the analog signal provided from the camera to the digital signal.
Indoor application: As we said, in the indoor application we used the first few frames to take the background.So from Fig. 9, we see that the background viewer is contained by a fixed image (referential image) in both cases one and multi objects video tracking.Also, we found that the detection and the tracking are made well.It is to emphasize that, the number of targets are previously set at 5 and we can see it from the tracking viewer.Because we chose the second object, noted by B, to display its result, we see (Fig. 10a and b) that if B isn't available then its coordinates ሺx, yሻ will be equal to ሺ0,0ሻ.But when it is provided (Fig. 10c and  d) we get some variation in the coordinates.
We know that, in case of the indoor application, the stationary background causes a problem of noise.This noise is usually the result of a change of intensity.The Fig. 11 illustrates the phenomenon.From the DSP/BIOS Tools we profile the DSP software performance.We find, from CPU load graph Fig. 12, that the maximum load is fewer than 25%, so there is still available capacity.We can also see, the time spent executing each task from Execution Graph.And starting the model viewer shows us the information about MAC and IP addresses.
Outdoor application: Unlike to the indoor application, in the outdoor application the background is adaptive.We can confirm that from the background viewer in Fig. 13.We see, from the viewers in that the fixed object (human) is taken as an object of background and the target in move, noted by 1, is detected and tracked.As we also see, in both cases, one and multi objects video tracking, the obtained results are satisfactory.To take an idea about the adaptive background, Figure 14 shows us that, when the motion is fast, the referential image is empty without any additional object.But in case of slow motion, we see in the background viewer, of Fig. 14b, that something is added to the empty background and this becomes the referential image.
Unfortunately, in the outdoor application we also have a noise problem, but in this case the noise phenomenon is provided from both changing of the intensity and updating of the background.The Fig. 15 presents that.We also provide, in this case, the DSP software performance under DSP/BIOS.From CPU load graph Fig. 16, we found that a 99% of the processor capacity is being used.In outdoor application, the use of

CONCLUSION
In this study a model-based design of multi-objects video detection and tracking of two kinds of applications, indoor and outdoor, was proposed.The use of TCP/IP connection between PC and DSP TMS320C6455, was helpful to send the video to the DSP, in which was implemented our detection and tracking algorithms, for a processing.The Kalman filter was able to correctly process target and to correctly assign a filter to the processed object.After reviewing the results we deduced that our model-based design of video tracking performed quite well showing a moderate consistency in tracking.We also confirmed that the processor capacity consumed in outdoor application was more than the indoor application because of additional processing set of adaptive background.Even the obtained results are acceptable, we seen that in both cases, indoor and outdoor environment, we got a noise problem.To remedy, we can do a normalization of the intensity or outright change the detection strategy.
Fig. 1: Model-based design video tracking, indoor and outdoor applications

Fig. 9 :
Fig. 9: One and multi objects video tracking indoor application

Fig. 13 :
Fig. 13: One and multi objects video tracking outdoor application