COVID-19 has entered our lives swiftly and relentlessly. Without a similar past event that we can use as a benchmark, we are finding it hard to adapt to many social rules that were unheard of up until now.
Social distancing is considered one of the most effective measures for containing the effects of the coronavirus but it is not always easy to put into effect or to measure its results.
Over the past few years MEO Beachcam has become one of the go-to websites for surfers. This website provides detailed, up-to-date information on the sea state, the temperatures and the beaches and plays back videos of many Portuguese beaches and a few in Spain and France in real time.
In the current scenario brought about by the global COVID-19 pandemic, we need to take appropriate safety measures, among them maintaining the mandatory interpersonal safety distance at the beach and in public spaces.
The Portuguese Environmental Agency (APA) has decided to launch a project in collaboration with Beachcam for calculating the occupancy rate of Portuguese beaches and provide beachgoers with semi real-time information about it with the aim of preventing congestions and encourage interpersonal spacing.
Thankfully, it has been possible to use the existing infrastructure and apply computer vision and machine learning techniques.
The advancements in machine learning – mostly in image processing applications – make it a good alternative for calculating the occupancy rate of beaches. In fact, this field has grown tremendously in recent years. We at Paradigma have carried out several machine learning projects. Hence, we have both the right know-how and a team of highly experienced and qualified people.
We have brought all these things together in order to design an algorithm that allows people to be counted in certain places and the results extrapolated in order to qualitatively estimate beach occupancy rates.
Using the already existing infrastructure.
One of the main obstacles to making occupancy rate calculations was having to install a infrastructure that would provide us with information (images in our case) on time that would allow us to deploy a solution in a very short time.
By using the infrastructure that was already in place (currently in operation and deployed in suitable locations) we have been able to overcome this problem and drastically reduce the introduction effort.
On the other hand, we realized from the very beginning that this infrastructure was not optimally installed for the purposes of our task because it only provided long-range and panoramic images, which made it hard to tell people on the beaches apart and thus calculate the latter’s occupancy rate.
Our solution overcomes this disadvantage by applying a software-based approach to adapt to the particularities of each camera based on parametrization and algorithm adjustment.
Looking for the right algorithm.
After a brief analysis, and based on our experts’ know-how, we decided to run tests using three different algorithms in order to see which one fit our use case best.
Once these initial tests were complete, we decided that the team should keep working on two of them at the same time.
These algorithms had to meet certain restrictions as regards the acceptable margin of error, the processing time, the cost of the infrastructure, and so on.
In the end, we finally chose the CrowdCounting algorithm, a machine learning model based on convolutional neural networks (CNNs) that partitions the space under surveillance according to a divide-and-conquer approximation.
Thanks to this, we were able to keep the time that goes by from the moment a camera takes a coded picture until the system calculates the qualitative occupancy rate below 30 seconds using standard (non-specialized) hardware, which more than fulfils the information refresh requirements (every 10 minutes).
Designing the right architecture for the project
The initial analysis and the type of project called for an event-orientated architecture with several light processing phases.
Using AWS’ managed services, we set up a serverless service-based architecture to encompass the four phases in our flow:
Uploading the specific settings into each camera.
Capturing a coded image.
Processing the image.
Sending the results to APA’s service.
This architecture is fully asynchronous: each phase is triggered by the arrival of a new event.
The architecture’s design, together with the features the AWS services that support it have, affords huge scalability capabilities, thus guaranteeing it will remain serviceable in the future.
Paradigma accepted a challenge, with a high level of difficulty and a very short implementation time. The result could not have been better!