I wonder why the train test Batteroo did, showed such different results, see here:
https://www.facebook.com/revivebatteries/posts/1303252479741119 With the train model I used, the speed for both tests, with and without sleeve, was nearly identical. Too bad that Batteroo didn't publish the full movie or data so far.
So for better comparison, a reliable and honest person, with experience in programming, created a Python script (me
![Smiley :)](https://www.eevblog.com/forum/Smileys/default/xsmiley.gif.pagespeed.ic.R8GFI-pF6f.png)
), with OpenCV to extract the number of laps and lap time for each round, because this is a perfect example to evaluate OpenCV, something I wanted to do anyway. See
here for the full script. It was much easier than expected, because of all the useful functions in OpenCV. And the script analyzes the video faster than realtime.
It works like this: There are two rectangular areas, one at the top of the track and one at the bottom. If the train gets inside the bottom rectangle, the lap detection gets armed. When armed and it gets inside the top rectangle, the lap timer is started and it is disarmed. When it is at top again (after armed at bottom), the lap time is printed, and the lap timer is started for the next lap. This is very reliable, even when the detection if a train is inside a rectangle is not reliable, e.g. if it oscillates at the borders, and can measure very slow trains as well, without the need for an arbitrary hold-off time.
The detection if the train is inside a rectangle is easy: I just count the number of dark and bright pixels and if there are more dark pixels than bright pixels, it is inside (because the track is much brighter than the train). To determine the threshold for dark pixels and test the train detection, the script can be started in interactive mode. If it is inside a rectangle, the rectangle is drawn in green:
![](http://i.imgur.com/xZV3UxP.png)
![](http://i.imgur.com/4Uxd4eO.png)
![](http://i.imgur.com/1xgkXHT.png)
For the threshold you can press the "h" key while the train is in one rectangle, and you'll get a histogram of both rectangles:
![](http://i.imgur.com/h1JDZQs.png)
Just choose a value between the two peaks. This could be automated as well and more sophisticated functions of OpenCV could be used, like the train could be tracked on the whole track and it could be evaluated how smooth it moves (looks a bit more jerkily with the Batteroo sleeve), but this quick hack works really good to measure the basics.
With the startStop array at the beginning of the script, multiple test runs can be defined for one video.
I used the raw footage of the train video (glad I didn't delete it already) and created a full video of it, but compressed and scaled down a lot more, so that it doesn't need many GB, but it is the full 3:19 hour without timelapse. I've uploaded it
here, 1.4 GB (no worries if you want to download it to play with OpenCV, my server has an unlimited bandwidth hosting plan, it just gets limited to 10 Mbit/s if the traffic gets too high). As in the Batteroo test, I created a spreadsheet with the following number: lap number, lap start time, lap end time, total lap time, feet per minute speed. Unlike Batteroo of course, I publish the spreadsheet, you can see it
here. The lap counts are the same as @samgab reported (+/-1). Diagram:
![](http://www.frank-buss.de/batteroo/batteroo-train.png)
If anyone wants to measure something as well, maybe a drop out art student, feel free to use the script. No need for any extra hardware for a lap counter.