-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
From my point of view, I think it's a bug. :(. So I would like to report to you guys for checking that.
Error message
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.6) .../opencv346/opencv_contrib-3.4.6/modules/face/src/facemarkLBF.cpp:332: error: (-5:Bad argument) Training data is not provided. Consider to add using addTrainingSample() function! in function 'training'
After checking the source code, find it means NO FACE is detected at all.
System information (version)
- OpenCV => 3.4.6, but find it also exists in master branch
- Operating System / Platform => Ubuntu desktop 64bit
- Compiler => g++
I was trying to use the FacemarkLBF
method in the face
module to train a facial landmark detection model. I used my own face detector MyFaceDetection
.
cv::Ptr<cv::face::FacemarkLBF> facemark = cv::face::FacemarkLBF::create(params);
facemark->setFaceDetector((cv::face::FN_FaceDetector)MyFaceDetection, nullptr);
//... some code
facemark->training();
My own face detector NEEDS a RGB image as the input, but the following code in file facemarkLBF.cpp
located in face
module converts RGB into GRAY image before calling my face detector which actually happens in getBBox(img, _shape);
. In my opinion, the conversion operation should be delayed to the actual face detector to decide, just like the FacemarkLBFImpl::defaultFaceDetector
does. It's really redundant and a bug to leave it here from point of view.
So please check it whether I am right, guys.
The detailed snippet in the file facemarkLBF.cpp
is as follows, and the three lines should be line 505-507:
void FacemarkLBFImpl::prepareTrainingData(Mat img, std::vector<Point2f> facePoints,
std::vector<Mat> & cropped, std::vector<Mat> & shapes, std::vector<BBox> &boxes)
{
if(img.channels()>1){
cvtColor(img,img,COLOR_BGR2GRAY);
}
Mat shape;
Mat _shape = Mat(facePoints).reshape(1);
Rect box = getBBox(img, _shape);