Por el momento ya tengo la detección de rostros a tiempo real usando la webcam con C++ funcionando en GNU/Linux, aunque aun falta la parte del reconocimiento y aplicarlo en el inicio de sesión.
// detection.C
#include <iostream>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
string title = "Sistemas adaptativos, reconocimiento facial";
String fcn = "detect_faces_bitch.xml";
CascadeClassifier fc;
void detectFaces(Mat frame) {
Mat frame_gray;
std::vector<Rect> faces;
cvtColor(frame, frame_gray, CV_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
fc.detectMultiScale(frame_gray, faces, 1.1, 2, 0, Size(80, 80));
for(int i = 0; i < faces.size(); i++) {
Mat faceROI = frame_gray(faces[i]);
Point pt1(faces[i].x, faces[i].y);
Point pt2(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
Point org(faces[i].x + faces[i].width * 0.5 - 50, faces[i].y + faces[i].height + 50);
rectangle(frame, pt1, pt2, Scalar(0, 0, 0), 10, 8, 0);
putText(frame, "Desconocido", org, 1, 1.5, Scalar(0, 0, 0), 2, 8, 0);
}
imshow(title, frame);
}
int main(int argc, const char *argv[]) {
Mat frame;
CvCapture* capture;
if(!fc.load(fcn)) {
std::cout << "Error cargando cascada de clasificacion..." << std::endl;
return -1;
}
capture = cvCaptureFromCAM(-1);
if(capture) {
while(true) {
frame = cvQueryFrame(capture);
if(!frame.empty())
detectFaces(frame);
else {
std::cout << "Error al capturar video..." << std::endl;
break;
}
int q = waitKey(10);
if((char)q == 'q' || (char)q == 'Q')
break;
}
}
return 0;
}
Probando formatos de video...
NOTA: Agregaré el video del avance lo más pronto posible.