1) Getting motion detection to lock onto individuals and keep track of coordinates
2) Stabilizing the range of variation of the rectangle surrounding the locked individual.
3) Obtaining the distance that the individual is away from the camera
Previously, the team has had tremendous success in coding facial detection which locks the coordinates that the user's face is on the camera. However, we had to take a turn to implement motion detection (tracking an individual instead of a face) because individuals walking around the camera's line of sight might not have their faces orientated directly to the camera at all times.
An example of what we are trying to achieve is shown below:
The thick green box will follow the individual within the camera's line of sight. The X and Y coordinates could be then extracted fairly easily as we can implement a centre-point. The next step is to attempt to stabilise the variation of the size of the green box while the individual is moving. As the user/individual moves, the pixels change and that is what OpenCV tracks for us. The green box is going to vary in size each time the video frame updates (assuming that the individual is moving), the next objective revolves around stabilising the range of fluctuations of the rectangular green box.
The importance of the stabilisation of the green box is crucial as the distance is currently being estimated by taking into account the length of the green box. The estimation of the distance are based on the conditions below:
- Individual close to cam = green box is huge = length of the box is large
- Individual far from cam = green box is small = length of box is small
Examples of conditions:
In this image, my face is further away from the camera, therefore the green box is smaller. This proves the concept in estimating the distance of the individual from the camera by using the data obtained from the width of the box.
With the conditions stated above, it is possible to estimate the distance and create a variable to store the estimated distance, which the progress will be constantly updated through blog posts.