Cat Deterrent for Fish Pond

by Rune Guillemyn in Circuits > Raspberry Pi

30 Views, 0 Favorites, 0 Comments

Cat Deterrent for Fish Pond

20240616_175735.jpg
20240616_175741.jpg
20240616_175750.jpg

My project is a cat deterrent for fish ponds. I came up with the idea to help my grandparents because they have a little pond in their garden but a lot of their fish have gotten killed by local cats. This project will help them a lot because it is able to watch over the pond at all times, keeping the fish safe even when my grandparents aren't at home. A camera will watch over the pond and detect when cats are near, this will activate a high frequency sound that scares the cats away.

Supplies

image_2024-06-11_103014941.png
image_2024-06-11_103041748.png
image_2024-06-11_103117505.png
image_2024-06-11_103146899.png
  1. Raspberry Pi 5: https://shorturl.at/KER7Y (RaspberryStore.nl)
  2. Webcam: https://shorturl.at/LSclr (Bol.com)
  3. LCD Display: https://shorturl.at/gCT2U (Amazon.com)
  4. Passive Buzzer: https://shorturl.at/QGUZD (Amazon.com)
  5. Wooden planks: https://www.brico.be/nl/search?text=hout+plank

Gathering and Preparing Data

image_2024-06-11_103900859.png
  1. I gathered data by looking for datasets that contain images of cats, ponds and both of them together.
  2. Once I found a decent amount I made sure I had around the same quantity for each group, that way my dataset will be balanced.
  3. Then I annotated the data on Roboflow. I did this by drawing a box around a cat or a pond whenever this was seen in the picture.
  4. Once ready I divided my dataset in 70% train, 20% validation and 10% test data.
  5. Finally I added augmentation like blur, noise and brightness and that way I have more images to train on.

Train a YOLOv8 Model

Screenshot 2024-06-11 105509.png
image_2024-06-11_110015669.png
  1. First import YOLO from ultralytics so you can use YOLO.
  2. Then select a model, in this case choose the YOLOv8 with size small.
  3. Train this model using your data.yaml file, with 50 epochs and images size 320.
  4. In your data.yaml file you first say where all your images are located, then how many classes there are and after that you say which model you are using.
  5. You can look at your confusion matrix to see how accurate your model is.

Make Sure Model Works

Make some code that uses the model to see if it works well and detects everything.

Downloads

Make Connection Between Laptop and Raspberry Pi

  1. I made a "connect.py" on my laptop that looks for the connection to my Raspberry Pi, it also has code that initialises the camera and sends the classes detected to the Raspberry Pi.
  2. After that I made a "server.py" on my Raspberry Pi that waits until the laptop connects to it, it also has code that takes the detections and uses them to display something on the LCD and makes a sound with a passive buzzer when a cat is near a pond.

Make the Case to Put Everything In

20240611_183233.jpg
20240611_183238.jpg
20240611_183228.jpg
20240616_184049.jpg
20240616_184042.jpg
20240616_184057.jpg
  1. Cut out 4 sides from the wooden planks. (15cm by 19cm)
  2. Make the holes needed for the camera, lcd, cables and buzzer.
  3. Stick the sides together with screws.
  4. Make the top and the bottom. (19cm by 19cm)
  5. Stick the bottom together with screws as well.
  6. Attach hinges to the top and to the backside to create a lid.
  7. Glue the camera, buzzer and lcd to the right holes.