IKH

Tracking Blobs

In the previous segment, you saw how to go about predicting the next position of a vehicle based on its previous centre positions. Now, we will take a look at the function to plot the blob and then look at the tracking algorithm. In the above video, you saw the function to display the blobs. You already know that the blobs are the valid hulls that are being tracked. Also, you have already gone through the pseudo code of tracking algorithm. Now, let’s see the actual code.

Let’s summarise the algorithm that you just saw. You already know that if you are starting video for the first time, you must save the blobs that appear by taking the difference between first two frames in the list existingFrameBlobs[]. In some places, the list is referred to as blobs[]. From the third frame onwards, we will start tracking the vehicles. For each valid blob in currentFrameblobs[], from the third frame onwards, we will compare the blobs in currentFrameblobs[] with those of existingFrameBlobs[], see if the difference between centre positions of the predictedNextPosition(coming from extrapolation in existingFrameBlobs[] ) and centrePosition (coming from currentFrameblobs[] ) is less than threshold. If that’s the case, then we say that the object is being tracked. The value of this threshold is half of the diagonal size of blob being tracked in currentframeBlobs[].

Next, let’s see what you need to do when you find that the blob in currentframeBlobs[] was already present in the previous timeframe. 

From the tracking algorithm, you know that we need to predict the next position using extrapolation for tracking the vehicle for another time-step if a match is found in current timestep. You will update the coordinates by updating the centrePositions variable of blobs in existingBlobs() using the function addBlobToExistingBlob(). Similarly, you will update other variables which are needed to track and validate the blobs such as blnStillBeingTracked, blnCurentMatchOrNewBlob, etc.

Note that you need to update the parameters for only those blobs in existingFrameBlob() for which you find a match with the blob in currentframeBlob() so that it can be tracked for another timestep. You locate that blob through the variable intIndexofLeastDistance, which you find when computing the least distance.

for a blob in existingBlobs(), if you cannot find a blob in currentFrameBlob() for which distance is less than the threshold for five consecutive time frames, we will stop tracking that blob.

Report an error