I gave a little break to myself from developing my game/game engine and have developed a side project, a camera trap for watching bird nests.

I developed two program for the project – one for client side to watch the footage live, and the server side to transmit camera image to the client and capturing image with motion detection.

I used the following hardware:

  • Raspberry Pi Zero 2W
  • Raspberry Pi Camera v1.3
  • Mounting screws and nuts
  • 3D printed case

I have installed headless raspberry pi os and I had written the codes via vim remotely using SSH connection.

I used libcamera library for the server side, and SDL3 for the client side. I programmed both with C++.

Server side

We can seperate server side program into two categories:

Image transmission

I have implemented two sockets: one tcp socket for securing connection, and one udp socket for transmitting the image data. Current camera frame is sent to the client by dividing it by 8 and combining them in the client side.

Honestly it would be so much better to use an encoder, possibly h264, for transmitting the camera image, but for a side project I didn’t find it necessary -or interesting- to use another library.

Image capturing with motion detection

I used gaussian blur for motion detection. The program captures the frame every 0.25 seconds, downscales them and compares it with previously taken image. If there is a difference of a threshold between the frames, it takes a picture and saves it with a meta-data.

Client side

I used SDL3 for creating window and displaying images via an SDL surface.

When a client connects to the server successfully, server starts sending its frame data, and client listens to it and draw its data to SDL surface in the secreen. The client is capable of sending data to server such as capturing an image of the current frame.

Hardware

I have designed a case and got it printed. Cut a plexiglass for its camera hole and sealed it.

Overall, I had fun developing a side project for watching birds on our home garden. I had been wanting to make some embedded projects, and tried to do it with my other hobby, bird watching.

Here are two pictures of the captures of the project, two great great tits😍: