Convert face training image to gray scale only if image has 3 channels

This commit is contained in:
Anshul Jain 2015-11-05 12:08:43 +05:30
parent 58093bdcfc
commit 3736e83aa0

View File

@ -162,7 +162,9 @@ Local<Value> UnwrapTrainingData(Nan::NAN_METHOD_ARGS_TYPE info,
int label = valarr->Get(0)->Uint32Value();
cv::Mat im = fromMatrixOrFilename(valarr->Get(1));
im = im.clone();
cv::cvtColor(im, im, CV_RGB2GRAY);
if (im.channels() == 3) {
cv::cvtColor(im, im, CV_RGB2GRAY);
}
labels->push_back(label);
images->push_back(im);
}