DSLR Motion Capture with Raspberry Pi and OpenCV


Having spent a week in bed with Covid symptoms, it was soooo nice be feeling better and wanting to get my head into something. I’ve had an idea rattling around my brain for a while (with and end goal in mind – more of that later)

I wanted to see if I could use motion detection using OpenCV on the Raspberry Pi to trigger my ‘real’ camera to actually take the pictures. Now, before aaaaaanyone asks why I didn’t use the spanky new Pi camera with some cool lenses, the reasons are twofold. I don’t have a Spanky new Pi camera. And I don’t have any cool lenses.

I do have Pi and Pi Camera V2, and a really nice Lumix camera my utterly amazing wife bought me for my last birthday. So I hit Amazon to find a cheap (ish!) remote for my camera and then proceeded to…. I believe break it better is the correct terminology.

I love it when things are actually screwed together – makes hacking them so much easier!


I was hoping to be able to just re-solder some connectors to the button but it was a dual function button depending on depth of press. I therefore got a set of probes out and traced which pins on the chip were responsible for the actual shutter release and then *carefully* managed to add two fine wires.


Held in place with a blob of hot glue, I added Dupont cables to the ends so I could go into the breadboard. A very simple circuit using an NPN transistor to switch via GPIO gave me remote control of the camera from Python – success!


Adding OpenCV was really straightforward thanks to Adrian over at PyImageSearch – he has an amazing range of tutorials and resources for OpenCV on the Pi – can’t recommend it enough.

I took the basic motion detection script and added a tiny hack to trigger the GPIO when motion was detected.


I then added a delay to the start of the script so I could position stuff or myself in front of the camera with time to spare.

And with that in place we were done.

The camera was set to fully manual and to a really nice fast shutter speed. There is almost no delay at all between motion being detected and the Lumix actually taking pictures, I was really surprised how instantaneous it was.


It was then time to mount everything on the tripod and go out in the garden and chuck stuff around!


I also tried again later inside, but don’t quite have enough lighting to capture it as sharply as I’d like to.


So…. the reason this all started? I, like many people, have been feeding the birds in the garden with a selection of delicious treats including this lovely coconut husk / suet ball thing. Which is often raided, although I suspect in the wee small hours as I never actually witness it happening…


I’m now going to make a stand for this set up so I can sit it close enough to the feeding point and see if we can get some nice close up shots.

I’ll keep you posted with updates!

And on that note, until next time – Cheers!



3 thoughts on “DSLR Motion Capture with Raspberry Pi and OpenCV

  1. Great stuff. What model camera exactly are you using, and what are you connecting to the camera (and how) ?

    1. Hi, It’s a Panasonic Lumix DMZ-FZ300. The receiver for the wireless remote is plugged into the camera and am sending the signal from the transmitter using the Pi – sorry, I didn’t think to show the camera end of things!

Leave a Reply

Your email address will not be published. Required fields are marked *