DSLR Motion Capture with Raspberry Pi and OpenCV

IMG_9479

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!

pic1

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.

IMG_9429

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!

B688F4DA-463A-40B7-9592-9EBD24CDE391

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.

169B5C57-F278-444D-BDB4-B5ACC0DE67D9

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.

DCA0B9E6-47E3-455A-BB3E-942E840D50B9

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

IMG_9471

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

9E647371-4C76-499A-A4E6-1002F1B8A0F4

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…

35CD3588-9C45-433F-BD9B-028C06B6EFEA

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!

IMG_9475

 

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 *