Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit:</p> <p>Just to notify anyone visiting this site. I have written some sample code to perform face recognition in videos using my libfacerec library:</p> <ul> <li><a href="https://github.com/bytefish/libfacerec/blob/master/samples/facerec_video.cpp" rel="nofollow">https://github.com/bytefish/libfacerec/blob/master/samples/facerec_video.cpp</a></li> </ul> <p>Original post:</p> <p>I assume your problem is the following. You've used the Cascade Classifier <a href="http://opencv.willowgarage.com/documentation/cpp/objdetect_cascade_classification.html#cascadeclassifier" rel="nofollow">cv::CascadeClassifier</a> coming with OpenCV to detect and extract faces from images. Now you want to perform a face recognition on the images. </p> <p>You want to use the Eigenfaces for face recognition. So the first thing you have to do is to learn the Eigenfaces from the images you've gathered. I rewrote the <a href="https://github.com/bytefish/opencv/tree/master/eigenfaces" rel="nofollow">Eigenfaces class</a> for you to make it simpler. To learn the eigenfaces simply pass a vector with your face images and the corresponding labels (the subject) either to <a href="https://github.com/bytefish/opencv/blob/master/eigenfaces/include/eigenfaces.hpp#L48" rel="nofollow">Eigenfaces::Eigenfaces</a> or <a href="https://github.com/bytefish/opencv/blob/master/eigenfaces/include/eigenfaces.hpp#L53" rel="nofollow">Eigenfaces::compute</a>. Make sure all your images have the same size, you can use <a href="http://opencv.willowgarage.com/documentation/cpp/geometric_image_transformations.html#cv-resize" rel="nofollow">cv::resize</a> to ensure this.</p> <p>Once you have computed the Eigenfaces, you can get predictions from your model. Simply call <a href="https://github.com/bytefish/opencv/blob/master/eigenfaces/include/eigenfaces.hpp#L57" rel="nofollow">Eigenfaces::predict</a> on a computed model. The <a href="https://github.com/bytefish/opencv/blob/master/eigenfaces/src/main.cpp" rel="nofollow">main.cpp</a> shows you how to use the class and its methods (for prediction, projection, reconstruction of images), here's <a href="https://github.com/bytefish/opencv/blob/master/eigenfaces/src/main.cpp#L66" rel="nofollow">how to get a prediction for an image</a>.</p> <p>Now I see where your problem is. You are using the old OpenCV C API. That makes it's hard to interface with the new OpenCV2 C++ API my code is written in. Not to be offending, but if you want to interface with my code you better use the OpenCV2 C++ API. I can't give a guide on learning C++ and the OpenCV2 API here, there's a lot of documentation coming with OpenCV. A good start is the OpenCV C++ Cheat Sheet (also available at <a href="http://opencv.willowgarage.com/" rel="nofollow">http://opencv.willowgarage.com/</a>) or the OpenCV Reference Manual.</p> <p>For recognizing images from the Cascade Detector, I repeat: First learn the Eigenfaces model with the persons you want to recognize, it's shown in the example coming with my code. Then you need to get the Region Of Interest (ROI), that's the face, the Rectangle the Cascade Detector outputs. Finally you can get a prediction for the ROI from the Eigenfaces model (you have computed it above), it's shown in the example coming with my code. You probably have to convert your image to grayscale, but that's all. That's how it's done.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload