This week Smart Technologies organized a Hackathon. The allotted time to solve the challenge is 5 hours. Unfortunate we (Casper Koning and myself) came in second. But according to the jury the first three placed teams performed equal. (The winning team implemented a “nicer” concept.)
The Dutch railways are looking into a solution for counting the passengers in the cabin of trains. This information is used in multiple ways, one of them is a indicator on the platform.
The means selected are two detectors, a Distance Measuring Sensor Unit (sharp) and a High Precision Infrared Array Sensor. two different devices to achieve the goal.
The images below are a visualization of the data provided to us.
The image shows a person passing from left to right for the sharp sensor.
This second images is a visualization of single sample from the infrared sensor.
Our initial thoughts
We started with a team of two, each a sensors.
This sensor shows the heat signature of people passing underneath it. When using a finding the a hotspot and include surrounding measurements it looks promising to see the number of persons and their direction.
Unfortunate the match between this is “fairly” simple math and the given time including the required result data structure made us decide to abandon this sensor.
The data from the distance sensor showed the passing of persons clearly. First impression, count the peeks. In essence that was a correct assumption. A video provided synced with the data showed unexpected peaks. More in depth processing is required to get accurate measurements.
After watching the video we had the following hypothesis:
- Order of the sensor data indicated the direction
- Peak heights of a single person is similar (between readings)
- start time of the peaks are within a certain timeframe
- Peaks have a minimal time
A piece of provided sample code allowed visualisation of the data. Unfortunate the language of choice, Python. Not our preferred language, that’s Scala. But opted to go for that, it allowed for simple submission of the results.
The discovery of the direction was the simplest task. By using a pair of Booleans to indicate the first sensor, we could determine the direction of the passing.
For the relation of the peak heights we used the height of the first peak. A next peak had to be in a certain range from the first one. Peaks that did not match we discarded, a glitch?
Due to the particularities of the Python syntax we ran into a bug that had us flabbergasted for quite some time. In the end it was just one of the Booleans that we didn’t take into account for an if statement. It took us quite some time to discover the location of this error.
Don’t underestimate the importance of testing!
Looking at the time a problem we didn’t think it would add significant advantages, boy we were wrong :-(
In the end we did not implement the last two observations.
Even though we did not implement the last two observations (and faired the price giving ceremony) the code actually is quite effective. A error range of a merely 12%!
The report of the jury :
De resultaten en gebruikte technieken van deze top 3 waren zo ’close’ dat de jury meer dan een half uur heeft moeten vergaderen wie de hoofdprijs verdiende… De jury heeft uiteindelijk unaniem gekozen voor Christiaan Teerling en Rik Bosma. Niet alleen hadden zij een prima cijfermatige uitkomst, maar de jury is overdonderd door hun professionele model, hun nette uitwerking (OO, Java, Desire/Belief/Intention model). In potentie niet alleen een prima oplossing voor deze NS opdracht maar volgens de jury bruikbaar als generieke bouwblok voor soortgelijke smart-sensor solutions!
The top 3 was close and took the jury half an hour to reach a decision. The winner had a clean solution that is both extensible and original (Desire/Belief/Intention model) proved decisive for the result.