当我播放面部检测代码时,我会感到困惑。当我评论这两句话时:
//cvtColor( frame, frame_gray, CV_BGR2GRAY );
//equalizeHist( frame_gray, frame_gray );
结果仍然相同,这意味着Opencv(detectMultiScale)仍然可以成功找到人们的脸。我在想什么是将彩色图像改为灰度图像,然后获得灰度图像的直方图?
我附上部分代码如下:
while (cvWaitKey(10) < 0)
{
Mat frame = cvQueryFrame( capture ); // get the next frame of video
cvtColor( frame, frame_gray, CV_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) ); // Detect faces
for( int i = 0; i < faces.size(); i++ ) // for each face found
{
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 ); // location of this face
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 ); // draw ellipse around this face}
imshow( "faces", frame);
}
/////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
OR:
while (cvWaitKey(10) < 0)
{
Mat frame = cvQueryFrame( capture ); // get the next frame of video
//cvtColor( frame, frame_gray, CV_BGR2GRAY );
//equalizeHist( frame_gray, frame_gray );
face_cascade.detectMultiScale( frame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) ); // Detect faces
for( int i = 0; i < faces.size(); i++ ) // for each face found
{
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 ); // location of this face
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 ); // draw ellipse around this face}
imshow( "faces", frame);
}
//////////////////////////////////////////////
答案 0 :(得分:0)
去饱和的关键是减少数据量,因为算法在没有颜色的情况下工作。均衡点是为了补偿光照变化。
您可以在此处找到更多信息:Face Recognition using OpenCV