Face Detection using Open CV and Python
Swami Nikhilaananda said:
"Face Detection and other awesome stuff have been greatly simplified with OpenCV and Python"
I am no expert in this field, but I was just excited to have a piece of code working. In this little program, we attempt to do a face detection using Python and OpenCV.
First get Open CV and Python up and running following simple tutorials found here.
The following is a piece of code - Replace the path of the Haar Classfier file (xml) with the one in your system. Save the file, and run the script.
"Face Detection and other awesome stuff have been greatly simplified with OpenCV and Python"
I am no expert in this field, but I was just excited to have a piece of code working. In this little program, we attempt to do a face detection using Python and OpenCV.
First get Open CV and Python up and running following simple tutorials found here.
The following is a piece of code - Replace the path of the Haar Classfier file (xml) with the one in your system. Save the file, and run the script.
You can see LED Glowing with Face Detection using Arduino here
Taking Face Detection to the next level? Instead of merely putting a rectangle, you can perhaps overlay stuff... Here's my first rough attempt to mimic Google's Reindeer stunt on Hangout
Comments
Can you tell me what changes should I make if i want to detect face in an image. Your code basically activates the webcam and face is detected in the live feed from the webcam. I want the code to look up for an image, detect face in it and save it.
Please help me. Thanks
That's actually easier. Instead of reading the image from the webcam, you just read it from a file. Just use cv.LoadImage("filename") to get the image, instead of from webcam... and use cv.SaveImage("filename", image) to save it.
So instead of the line "cap=cv.CreateCameraCapture(0)", I replace it with "cap=cv.LoadImage("myimage.jpg")" and rest of the things remains same.
Am I right?
I am able to do it but your code does not detect multiple faces. I have a image in which there are 2 faces but the saved image has rectangle only on 1 image and that too on left one. Any possible explanation?
How to detect multiple faces?
Also I want to click image from a webcam, store it, then invoke the image by LoadImage function and then save the image with detected faces. So I've already implemented the latter part. How to click images from webcam and store it using python code and opencv?
Thank You.
Regarding the other requirement, it's very simple. Follow the steps below
1. Read from webcam like how you did before
cap=cv.CreateCameraCapture(0)
image = cv.QueryFrame(cap)
2. Save image - cv.SaveImage("myimage.jpg", image)