My Octopress Blog

A blogging framework for hackers.

Motion to the Rescue

For the last several weeks, things have been disappearing from my office area. First, a backpack I had left out. I had assumed that people in an academic building full of offices would be trustworthy, perhaps I had this one coming. A couple weeks after that, I went to use my camera only to find it gone. Funny, I thought I locked that drawer. I guess I must have been mistaken. A couple weeks after that, my iPhone gone. This time, I’m certain I locked the drawer, and there are marks on the cabinet that indicate it being forced open.

Fed up with the disappearing devices, my friend Tyler and I set out on a mission. We went into Jeddah, bought a webcam and using the popular (thank to Iain for the link) Linux package motion, we set up a hidden motion-detecting spy cam in our office. We have a Linux box sitting near our desk (we’ve locked it to the floor), and so we hid the camera, trained on the place where most of disappearances had taken place.

[caption id=”attachment_680” align=”aligncenter” width=”300” caption=”A test shot of Tyler as we’re setting it up.”]A test shot of Tyler as we're setting it up.[/caption]

What motion does is that every time it detects the picture it sees changing, it takes pictures for five seconds (or until the motion stops - which ever takes longer). It’s supposed to be able to encode a video with ffmpeg on the fly, but as it wasn’t working right for us, we decided to just go ahead and throw it into a script. I wrote a short bash script that just took all the photos, archived them and then generated a video (when dealing with the tens of thousands of photos generated in an average day and night I learned about xargs). It also provides triggers for when motion is captured (for example, if you’d like to update Twitter (via Lifehacker) you can do this with curl).

One night, when bored and filled with anger about the situation, I decided to check the feed and found footage of someone clear-as-day breaking into my cabinet. I first saw it about 20 minutes after the fact, but I was sure the guy was still there. I called Tyler and we quickly deliberated (after getting the opinions of a couple officemates) and we decided to wait until the morning and talk to the security officer.

[caption id=”attachment_681” align=”aligncenter” width=”300” caption=”Looking for goodies. The man’s face is not visible in this shot nor is this frame alone incriminating. In the context of the video, you can see him gain entry, begin rummaging and removing items.”]Looking for goodies.  The man's face is not visible in this shot nor is this frame alone incriminating.  In the context of the video, you can see him gain entry, begin rummaging and removing items.[/caption]

We spent some time with them the next morning, giving them footage and printing key frames, and then they said they’d look into it. They assured us they would not involve the local authorities if they didn’t have to (the penalty for such crimes in Saudi Arabia can be quite stiff) and would take care of it discreetly. That night, they arrested four people and recovered a number of electronic devices. They held them as evidence for a bit, but today, I was given back my camera and iPhone (the only really big-ticket items I had stolen).

I am extremely relieved to have these back, especially my camera as I had been wanting to take photos of trips, events, etc. in its absence. Our next step was going to have off-site storage in case the bandits took off with our computer, but it would seem it wasn’t necessary.

Motion: 1, Thieves: 0

Of course, this was not a solo effort by any means. Some system admins and colleagues in the office park offered input, and the evidence wouldn’t have left our webcam if not for the security staff. Thanks, guys.