Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 image description

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 image description

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); }

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 image description

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); }

}