A Grand Vision
Imagine upgrading your Raspberry Pi with an “eye” to be able to recognize and target your cat
Or to wave hello and take snapshots when it sees you.
Imagine it being able to find Waldo in less than 3 seconds lol.
Imagine a smart security system that recognizes intruders.
I succeeded in Aquiring this knowledge and more With just a raspberry pi, a webcam
and a python library known as OpenCV.
Open Computer Vision
OpenCV is a powerful, open-sourced computer vision library and It’s pretty much what it sounds like: It allows you to program your raspberry pi to see, and to respond to what it sees. You can perform from image analysis, face Recognition, to video and snapshots among other cool things.
So to get started, you need a Raspberry Pi3B(haven’t tested the 3B+ yet):
And a USB webcam of practically any kind.
I’m in love with the C920 for its excellent recording quality both in sound with it’s dual mics and in its HD 1080p camera. It’s proven its versatility in many of my projects including computer vision and voice commands.
OpenCV on The Raspberry Pi3
I tried many ways of installing OpenCV for many weeks with many miserable results that wreaked havoc on my system.
Eventually I actually found one that works by upgrading to the latest Raspian Jessie pixel.
It would seem that the full version of OpenCV cannot be handled by the pi. It’s just way too big and powerful and usually fails like an hour into installation.
So this Trimmed version of openCV includes the bare essentials like recognition and snapshots, Video recording etc. And apparently removes some the higher functioning, CPU heavy qualities.
Though I imagine them to be things I wouldn’t really use anyway as I haven’t had any trouble yet besides, If It’s good enough for my pi, it’s good enough for me. 🙂
Installation took a while as expected. In the meantime, I had a look at the official examples to find anything interesting that i may want to mess around with down the road.
My main motivation for seeking this knowledge was to be able to Grant my projects with the ability to recognize and respond to visual stimulus. So I figured I’d start with Face/eye Recognition:
Heh note that it recognizes my nostrils as eyes.
I wanted to see just how specific recognition can be so I took it a small step further with smile recognition:
And from there, it’s as easy to choose what you want your pi to recognize as modifying a single line of code. And just as easy to program a response to said recognition.
I’ll give you my personal python3 code on basic face recognition as well as smile recognition in exchange for a small donation.
[sell_media_file item_name=”test download” name=”Sinistergenius.com” label=”Donate with Stripe” description=”Face and Smile Recognition” amount=”3.50″ locale=”auto”
panelLabel=”Donate ” download_link=”https://sinistergenius.com/wp-content/uploads/2018/01/Computer-Vision-with-OpenCV-n-Raspberry-pi-3-master.zip”%5D
All code comes with highly detailed comments so that you can thoroughly understand my method snippet by snippet. That can be applied however you like in ANY computer vision projects utilizing Python and the Raspberry pi. (All donations go toward site maintenance and new research)
One time donation, lifetime benefits.
While getting to know this thing, you may have noticed that the face has to be positioned right In order to be recognized.
The key is in the haar cascades you call up. Haar Cascades are a sort of library that can be used in your code To allow your machine to recognize what it reads. And it could be a picture library of anything that you want to be recognized by your system.
So if you want, say for your computer to recognize you and only you, you would put a bunch of pictures of yourself into a custom haar cascade from all angles and lighting conditions and use that in the script.
The more pictures of varying types you have of the subject, the easier it is for your pi to recognize said subject.
OpenCV already has a few ready to go cascades in it’s directory to be experimented with if you don’t need a custom cascade and you can easily find ready to go cascades on the net to be used in your projects.
All you’d have to do in the code is switch out the path of the cascade with the one you want.
Pretty cool huh? 🙂
Raspberry Pi Computer Vision Part2
OpenCV with Servos
So by using haar cascades, we can choose what our pi sees and reacts to Such as a face or even something so specific as a smile.
But my question at this point was: Can I apply my little Adafruit 16 channel Servo hat system to get a nice servo targeting/tracking thing going?
Turns out I could 😉 and much easier than i thought it would be:
The Adafruit 16 channel servo hat is a raspberry pi add-on that gives the pi the ability to seamlessly control up to 16 hobby Servos. A fantastic and essential piece of hardware when it comes to physical computing.
The code works much like the previous code except with the upgrade of my servo controller neatly merged with it to now allow for an actual physical tracking of your desired target.
Donate for detailed code (python3) on targeting and tracking any object using OpenCV3, The Adafruit Servo hat, and the Raspberry pi.
[sell_media_file item_name=”test download” name=”Sinistergenius.com” label=”Donate with Stripe” description=”Face Tracking” amount=”7.50″ locale=”auto”
panelLabel=”Donate ” download_link=”https://sinistergenius.com/wp-content/uploads/2018/01/Computer-vision-WITH-Servos-master-1.zip”%5D
With servos at your disposal, you can really make full use of OpenCVs’ potential.
Imagine pulling off:
-Automatic surveillance cameras that follow and record unfamiliar people.
-Smart Cameras that track your movement while recording For better youtube movies.
-Face activated door that locks itself if it doesn’t recognize you And opens if it does.
-Activate certain programs upon recognizing certain things.
-Interpret sign language!
-Give alerts on your target based on targets body language.
-Or even a bionic selfie Stick..
Simply by swapping out the haar cascades to have your camera track just about anything.
Skies the limit.
See Ya Later
Well that’s just about it to get you started on some simple yet crazy computer vision mischief.
Don’t forget to comment, like and share 🙂