Using OpenCV To Catch a Hungry Thief
![](../themes/icons/grey.gif)
![](../themes/icons/grey.gif)
[Scott] has a neat little closet in his carport that acts as a shelter and rest area for their outdoor cat, Rory. She has a bed and food and water, so when she’s outside on an adventure she has a place to eat and drink and nap in case her humans aren’t available to let her back in. However, [Scott] recently noticed that they seemed to be going through a lot of food, and they couldn’t figure out where it was going. Kitty wasn’t growing a potbelly, so something else was eating the food.
So [Scott] rolled up his sleeves and hacked together an OpenCV project with a FLIR Boson to try and catch the thief. To reduce the amount of footage to go through, the system would only capture video when it detected movement or a large change in the scene. It would then take snapshots, timestamp them, and optionally record a feed of the video. [Scott] originally started writing the system in Python, but it couldn’t keep up and was causing frames to be dropped when motion was detected. Eventually, he re-wrote the prototype in C++ which of course resulted in much better performance!
It didn’t take long to nab the thief — actually, thieves! It seemed quite a few different local animals had discovered Rory’s shelter and were helping themselves to her food. How rude! The first night detected a few different visitors. First, Rory’s local “boyfriend” stopped by to have a snack. Then within half an hour, an opossum (or possibly a small raccoon?) scarfed down what food was left. And within fifteen minutes of that visitor, a raccoon stopped by and was disappointed all the food was gone. Then, early in the morning. Rory arrives and is aghast that all her food is missing — again!
![](../themes/icons/grey.gif)
After analyzing all the footage, the solution, for now, is to feed Rory wet food twice a day and put just a little bit of kibble in her closet bowl in the morning for her to snack on throughout the day. In the future, [Scott] might use an RFID door to keep others out (though raccoons can be very smart and might be able to rip the door open), or possibly even something as simple as a magnetic collar and a Hall effect sensor to open the door or dispense food. Either way, the important thing is Rory is a happy cat and OpenCV rocks!