We draw a white circle around each face and display results.
If any valid faces are found in image, function will return the list of faces with positions. This gray scale image is fed to facedetection alogorithm, with some minimum size settingĬv2.circle(image, (x+w/2, y+h/2), int((w+h)/3), (255, 255, 255), 1) Image is then converted to a grayscale image. Gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)Įach image is picked from the camera and is loaded in nmupy array. Resolution is selected to be 162X120 for fast detection of faces. Raspberry pi camera is intialized and the streme of images is collectd from camera one by one. This imports the required libraries and open the haar cascade file RawCapture = PiRGBArray(camera, size=(160, 120)) from picamera.array import PiRGBArrayįaceCascade = cv2.CascadeClassifier(cascPath) # initialize the camera and grab a reference to the raw camera capture If the face is found in an image captured by camera, python program will print " Found 1 faces!." Below is brief description of how the code work. python face_detect.py haarcascade_frontalface_default.xml You can run this code from Raspberry Pi command line. You can download the face tracking sample code using haar cascade from here. Now we are all set to do some serious face tracking using Raspberry Pi.
The red light on the Pi camera will come on and a picture will be stored in cam.jpg file. Opencv Python Hand Detection and Tracking: Aim of the project is to move a robotic hand, mimicking humand hand based on a camera feed.The project is divided intoSoftware (i'm using opencv to detect human hand and find the distance between palm center and finger tips. For this on command prompt run, raspistill -o cam.jpg Let's test the Pi camera connected to Raspberry Pi for proper operation.
#OPEN CV EYE TRACKING INSTALL#
Now its is time to Install python wrapper for OpenCV, to do this run sudo apt-get install python-opencv
First thing you want to do is Enable Camera.Īnd chose Enable Camera (menu 6) also chose the correct speed for your Raspberry Pi from Overclock option (menu 8). Now since your SD card is ready, Boot your Pi. To install OpenCV on Raspberry Pi, you need Raspberry Pi ( Pi2 preferably), Pi camera, and internet connection to Raspberry Pi.īegin with latest Raspberry Pi Image from Ĭopy this image to correct size SD Card. To do this correctly please refers the detailed instructions at