diff --git a/modules/face/src/facemarkLBF.cpp b/modules/face/src/facemarkLBF.cpp index 264ec0379..df01a2213 100644 --- a/modules/face/src/facemarkLBF.cpp +++ b/modules/face/src/facemarkLBF.cpp @@ -535,13 +535,14 @@ Rect FacemarkLBFImpl::getBBox(Mat &img, const Mat_ shape) { void FacemarkLBFImpl::prepareTrainingData(Mat img, std::vector facePoints, std::vector & cropped, std::vector & shapes, std::vector &boxes) { + Mat shape; + Mat _shape = Mat(facePoints).reshape(1); + Rect box = getBBox(img, _shape); + if(img.channels()>1){ cvtColor(img,img,COLOR_BGR2GRAY); } - Mat shape; - Mat _shape = Mat(facePoints).reshape(1); - Rect box = getBBox(img, _shape); if(box.x != -1){ _shape.convertTo(shape, CV_64FC1); Mat sx = shape.col(0);