c a t C a m


When we moved into our new apartment, we realized we had many different types of feral cats coming around:
Star Anise (grey, green eyes), Pepper (grey, green eyes), Flower (white and black), etc...
With winter approaching, we set up a little house for them, but realized it became a hassle to see which cat was around in order to feed it.
(Or, to monitor whether or not the large racoons were eating the food we set out)
So, catCam was created in order to accomplish a few simple goals:
  • Activate when triggered by motion sensor (microcontroller: Raspberry Pi Zero)
  • Take a picture (v.1)
  • Stream video (v.2)
  • Use ML to identify which cat is present
  • Send a text or email to notify

The set-up involved:

  • a microcontroller (Raspberry Pi Zero)
  • NoIR Camera
  • 4 Resistors
  • OVO ultrasound (usually made for arduinos, I just had a lot lying around)
  • Breadboard, wires (for prototyping)
The total cost of which was around $30 (not bad!).


The code was a little more invovled, following Warden & Situnayake's TinyML and a free online course on object localization ,
I chose to use Google Colab (partially for its GPU storage, partially for easy sharing with my friends).
➱ The first version of the code (v1.0) is trained on many images of our backyard cats' faces, in various positions,
in order to achieve object localization: detect where the cat face is. In addition to that, it predicts the "label", or the cat's name (eg: "starAnise", "flower").
➱ We then take these pre-trained weights and model, and apply it to new pictures.
➱ This allows us to input a cat's picture (hopefully recently taken), and for the machine to output: 1. name of cat (label), 2. position of cat.
Future versions (v2.0) would involve implementing something like YOLO (or, tiny YOLO), and a live video-stream of the cats.


➱ As you can see here, the preliminary training results are a bit mixed. For the more general cat Flower (black and white),
and with a picture that clearly shows the face, as seen in (a), the model does not too bad.
However, just swapping in other cats, such as Star Anise (grey),
you can see that the model automatically classifies her as Flower -- shown in (b).
Not only that, but if the picture isn't a good face picture, as shown in (c),
the model has a really hard time finding any sort of "face".
This just means that we need better training: more images of different cats and a more robust model.



➱ While using machine learning to identify images and classify them is not new, the implementation of such with small microcontrollers is not as widely used
Many sources online require either a more advanced microcontroller (raspberry pi 4+) or an attachment that is able to run "like" a GPU.
However, such limits the size and the mobility of our creation.
With tinyML, the pre-trained model takes up significantly less space, and can run not only faster, but on smaller devices.
This makes it perfect to also be more cost-efficient, running even on the Teeny (Arduino: $3).
With lower price and more flexibility, the implementation can become much more versatile, and be used in every-day situations.