One face can not be detected in an image with six faces
I am testing OpenCV and I have used multiple images of faces. One image does not get one of the faces out of six. I am using the picture of the Friends show with all six friends in the picture. Chandler can not be found in the picture. I have cut his face out into an individual picture. OpenCV still can not detect his face. What is wrong with his face? I'm programming with the Java API on a Windows 10 machine
Here is my code
private static void detectFaces(CascadeClassifier faceDetector, String inputFileName) {
Mat image = Imgcodecs.imread(inputFileName);
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
int index = inputFileName.indexOf(".");
String prefix = inputFileName.substring(0, index);
String suffix = inputFileName.substring(index);
int count = 1;
for (Rect rect : faceDetections.toArray()) {
Rect rectCrop = null;
Imgproc.rectangle(image, new Point(rect.x - PADDING, rect.y - PADDING),new Point(rect.x + rect.width + PADDING, rect.y + rect.height + PADDING),new Scalar(0, 255, 0), 1);
rectCrop = new Rect(rect.x- PADDING, rect.y- PADDING, rect.width + PADDING, rect.height + PADDING);
Mat image_roi = new Mat(image, rectCrop);
Imgcodecs.imwrite(prefix + "_detectedFace" + count + suffix, image_roi);
count++;
}
String outputFileName = prefix + "_detected" + suffix;
Imgcodecs.imwrite(outputFileName, image);
}
can you take another look at your question ? how would we know, what you tried, and what went wrong ?
I edited my original post to add my code. Thanks for any help
there are params to tweak, like minNeighbours, min/maxSize()