bool myDetector(cv::InputArray image, cv::OutputArray faces, cv::CascadeClassifier *face_cascade){ cv::Mat gray;
if (image.channels() > 1) cvtColor(image, gray, CV_BGR2GRAY); else gray = image.getMat().clone();
equalizeHist(gray, gray);
std::vectorcv::Rect faces_; face_cascade->detectMultiScale(gray, faces_, 1.4, 2, cv::CASCADE_SCALE_IMAGE, cv::Size(30, 30)); cv::Mat(faces_).copyTo(faces); return true; }
(UIImage *) detectFacialLandmark:(UIImage *) image{ double CurrentTime = CACurrentMediaTime();
NSString *pathToFaceCascade = [[NSBundle mainBundle] pathForResource:@"lbpcascade_frontalface" ofType:@"xml"];
cv::Mat faceImage; UIImageToMat(image, faceImage);
cv::CascadeClassifier face_cascade; face_cascade.load([pathToFaceCascade UTF8String]); cv::face::FacemarkKazemi::Params params; cv::Ptrcv::face::FacemarkKazemi facemark = cv::face::FacemarkKazemi::create(params); facemark->setFaceDetector((cv::face::FN_FaceDetector)myDetector, &face_cascade); facemark->loadModel("load model"); std::vectorcv::Rect faces; resize(faceImage,faceImage,cv::Size(460,460), 0, 0, cv::INTER_LINEAR_EXACT); facemark->getFaces(faceImage,faces); std::vector< std::vectorcv::Point2f > shapes; if(facemark->fit(faceImage,faces,shapes)) { for( size_t i = 0; i < faces.size(); i++ ) { cv::rectangle(faceImage, faces[i], cvScalar(255, 0, 0)); } for(unsigned long i=0;i<faces.size();i++){ for(unsigned="" long="" k="0;k<shapes[i].size();k++)" cv::circle(faceimage,shapes[i][k],5,cv::scalar(0,0,255),cv::filled);="" }="" }<="" p="">
UIImage *returnImage = MatToUIImage(faceImage); NSLog(@"test processing time : %f", (CACurrentMediaTime() - CurrentTime));
return returnImage; }
I'm doing the project for the iOS application. For this project, I'm using OpenCV. Specifically, I added OpenCV_contrib modules to obtain the information of face landmarks.
During applied OpenCV_contrib, I have met one problem. facemark->loadModel("load model"); For detecting the facemark, I have to find the model files.
I wonder that how can I find the model files for "facemark->loadModel("load model"); "