Tony Onodi's Blog

I Made a Binary Search Tool for Videos To Embarrass British Transport Police Into Doing Their Job

I Made a Binary Search Tool for Videos To Embarrass British Transport Police Into Doing Their Job

This week London Centric reported that British Transport Police (BTP) would no longer review CCTV footage in bike theft cases if the footage was longer than two hours

If it is available we will review around two hours of CCTV footage to try to identify the incident, but it is not proportionate to review longer periods as it keeps officers from being available to respond to emergencies, visibly patrolling railway stations and trains, investigating crimes with identified lines of enquiry or which cause the most harm to victims – such as violent or sexual offences.

London Centric, quoting a Cambridge mathematics professor, then go on to suggest that the police could use binary search to cut the time taken to search any plausible amount of footage down to something very trivial. Their explanation of how binary search works is pretty good

Essentially, it involves the police officer scrolling to halfway through a CCTV recording and asking themselves “is the bike still visible?”

If the bike is still visible and yet to be stolen, they can ignore the first half of the tape and then scroll to halfway through the remaining section. Apply this principle repeatedly and the officer can identify the moment that a theft took place in almost no time.

Here’s a similar story from 2023 (unfortunately, the original story has forever been lost to mankind behind a Times paywall) in which a computer scientist tries to convince Cambridge police their policy of not reviewing footage longer than four hours also doesn’t make sense. Again because of binary search. To no avail.

I think part of the problem with selling the police on binary search is that it’s called “binary search”, which sounds very technical, and it’s being flogged to them by computer scientists and mathematics professors. I think a more palatable name for binary search would be something like “scrubbing through a video using common sense” and a better messenger would be just some guy. Luckily I’m not a computer scientist or a mathematics professor, I am just some guy. So I used AI (Claude Code if you must know) to build a tool that makes binary search even more foolproof than it already is. To make a point.

The way it works is a user uploads a video that they suspect contains footage of a theft, and gets shown a frame from the middle of the video. They then click either the “Item still there” or “Item stolen” button to narrow down which half of the video the theft happens in. Then they’re shown a frame from the middle of that half and the process repeats until the user has narrowed the range down to whatever granularity they want, at which point they can play the video and watch the theft take place.

To test my tool, I pointed my phone’s camera at a set of Sheffield stands, and recorded over an hour of mostly nothing happening, except for a few short seconds in which I appear and “steal” my own bike. Here’s what it looks like to use Theft Bisect (that’s what I’m calling it) to search that footage and find the crime:

By my count, it takes about 10 seconds to narrow 64 minutes of footage down to a 30 second window, and—because of the way binary search scales (O(log n) for the nerds)—searching an 8 hour video would take more like 20 seconds than 80.

It might look like a serious GDPR or privacy issue for police to drop a video into a random website like this, and well… maybe it is. But Theft Bisect at least tries to solve this by being local only. There’s no backend service, so videos you import never leave your machine. You can test this by disabling your internet connection while you use it, or you can review the code or download the code and run it locally if you know how to do either of those things.

So do I expect BTP, or any other police force, to use Theft Bisect to start solving crimes? They’re more than welcome to, but no. Not really. Using Common Sense to Scrub Through a Video is already so easy that the fact police aren’t doing it is probably indicative of some other problem. Either they’re just using it as an excuse to not spend even five minutes investigating a crime—in which case trying to make noise about the issue to embarrass them into action seems appropriate—or there’s some other issue, like that BTP are using an antiquated CCTV with no ability to scrub through video—in which case I feel a tiny bit bad for trying to make noise (but only a tiny bit).

If BTP think they don’t have even minutes to spare on solving bike thefts they should be honest about that and stop hiding behind excuses that make them look silly. Likewise if it’s because they’re fighting some arcane CCTV system, BTP should be more clear about what the problem is than they have been, and consider it their job to route around the problem so they don’t have to declare bike theft from railway stations de facto legal. I think the worst case scenario for fixing an issue like this is pointing a digital camera at a CCTV monitor for 8 hours then scrubbing through that footage, which seems tolerably bad. And all the other cases are better!

Anyway, the code for Theft Bisect is here if anyone wants to take a look, and if you do end up using it to solve a crime, feel free to get in touch and let me know.