CM3065 - Intelligent Signal Processing.

End of term assignement.

Exercise 1.1

Develop an application to detect and track moving cars.

First import the video using the open cv library. Once the video opened successfully, get the video width and height. This information can be used to focus only on the part of the image that is of interest.

In order to detect motion, we follow these steps:

  1. Convert the image frame to greyscale
  2. Apply blur to the image frame
  3. Get a baseline still image from the first blurred frame
  4. Get the absolute difference between the current blurred frame and the baseline blurred image
  5. Create a threshold frame by filtering out all pixels below a certain brightness
  6. Apply image dilation to improve performance

Baseline code reference:

Install the required Python libraries

pip install pyttsx3
pip install pywin32
pip install numpy
pip install opencv-python

These libraries apply to both exercise 1.1 and 1.2

As we can see above, all the required packages are installed.
Lets start with the code.

Lets create a funtion to run and analyse the video clips, this way we can just call the function with the wanted video.

Lets call the above function with the first video and see how well it tracks motion.

Lets call the above function with the second video and see how well it tracks motion.