In the previous segment, we had captured 2 frames, made copies of them, converted copied frames into grayscale images and applied a gaussian blur. This will give the following results as shown below.
If you observe carefully, You will find that the edges have blurred a little, but no significant difference can be observed as there is no graininess in the image. Blurring is standard practice (that is, it’s not necessary) followed when doing any pre-processing to deal with any sharp change in the image.
Now, we will find the difference between those two frames to find out the change in pixels and do further preprocessing. This change in pixels implies motion which means a vehicle is present there.
The process of finding the difference between two consecutive frames is to detect the objects that are in motion in those two frames. After finding the difference, the pixels of the difference image is converted to either o or 255. Thresholding makes the fainted outline of the vehicle more clear.
Generally, we perform morphological operations (such as dilation and erosion) on the thresholded image to remove the white noise from the image. Even after the thresholded image is clear, there are lots of holes in it. Out objective is to clearly identify the outline of the vehicle so that it can be extracted using contour. Below, you can clearly see the difference with the image with and without morphological transformations.
We will extract each vehicle by finding the contours in the next segment.
Report an error