Skip to content

Instantly share code, notes, and snippets.

@mascot27
Created March 28, 2018 08:59
Show Gist options
  • Save mascot27/3b062fa68244db28aa87c0ccbc0244c3 to your computer and use it in GitHub Desktop.
Save mascot27/3b062fa68244db28aa87c0ccbc0244c3 to your computer and use it in GitHub Desktop.
cv::CascadeClassifier face_cascade;
face_cascade.load("C:/OpenCV-3.2.0/opencv/sources/data/haarcascades/haarcascade_frontalface_alt2.xml");
std::vector<cv::Rect> faces;
face_cascade.detectMultiScale(frame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, cv::Size(30, 30) );
// Draw circles on the detected faces
for( int i = 0; i < faces.size(); i++ ){
cv::Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
cv::ellipse( frame, center, cv::Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, cv::Scalar( 255, 0, 255 ), 4, 8, 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment