Raspberry Pi and OpenCV snaps a fridge thief in action

As long, of course, as they don’t steal the Pi and Pi camera as wells as the Hummus or the yoghurts…

The system has been built by a computer vision specialist, Dr Adrian Rosebrock, and it is very well documented. You can see it in operation below:

OpenCV and IoT

As well as the Raspberry Pi and Raspberry Pi Camera module, it’s based on OpenCV, an open source library aimed at real-time computer vision.

There’s also IoT involved, because the Pi can message a smartphone – with images, and video clips – when the security camera is triggered. Twilio and Amazon web services handle the cloud-based action.

The creator writes:

Amazon Web Services (AWS) has a service called Simple Storage Service, commonly known as S3. The S3 services is a highly popular service used for storing files. I actually use it to host some larger files such as GIFs on this blog. Today we’ll be using S3 to host our video files generated by the Raspberry Pi Security camera.

S3 is organized by “buckets”. A bucket contains files and folders. It also can be set up with custom permissions and security settings. A package called boto3 will help us to transfer the files from our Internet of Things Raspberry Pi to AWS S3.

You can read full details of the project on his website, pyimagesearch.com, which takes you through the JSON configuration files, obtaining Twilio API keys and creating AWS S3 buckets, as well as the Python for OpenCV calls…


At the heart of the system is detect.py. The driver script detects a significant light change, which triggers recording video, and sends alerts.

He says that detecting whether the refrigerator is open or not is “a dead-simple, two-step process”:

Average all pixel intensities of our grayscale image (Line 75).

Compare the average to the threshold value in our configuration (Line 78). I’m confident that a value of 50 (in the config.json file) will be an appropriate threshold for most refrigerators with a light that turns on and off as the door is opened and closed. That said, you may want to experiment with tweaking that value yourself.

Dr Rosebrock is obviously a Gadget Master to keep an eye on – note that he is planning to release a book on computer vision and the Raspberry Pi. You can read more about the project.

[Via Raspberry Pi twitter]


Source link


Please enter your comment!
Please enter your name here