public class FaceDetector
extends java.lang.Object
Example of use: FaceDetectorExample
Modifier and Type | Method and Description |
---|---|
static boolean |
detectAndSurroundFaces(org.opencv.core.Mat image,
java.lang.String outputFilename)
Launches a new search to detect faces on a specific image and creates a new image
with rectangles surrounding the detected faces.
|
static org.opencv.core.Rect[] |
detectFaces(org.opencv.core.Mat image)
Executes the OpenCV "haarcascade_frontalface_alt" cascade classifier on a specific image
and returns an array of org.opencv.core.Rect.
|
static int |
detectFacesNb(org.opencv.core.Mat image)
Launches a new search to detect faces on a specific image, and returns the number
of faces detected on a specific image.
|
static void |
setHaarcascadeFrontalfaceAltXmlFilePath(java.lang.String filePath)
Sets the file path of the OpenCV haarcascade_frontalface_alt.xml file
used to detect faces on pictures with
detectFaces(Mat) , detectFacesNb(Mat) and detectAndSurroundFaces(Mat, String) . |
static boolean |
surroundFaces(org.opencv.core.Mat image,
org.opencv.core.Rect[] faces,
java.lang.String outputFilename)
Creates a new output image from the input image with faces surrounded with green boxes.
|
public static int detectFacesNb(org.opencv.core.Mat image)
! Attention ! Up to 68 seconds on a Raspberry Pi 2 for a picture of 2592x1944.
4 seconds for a picture of 640x480.
image
- the org.opencv.core.Mat object corresponding to the image to analyze.public static boolean detectAndSurroundFaces(org.opencv.core.Mat image, java.lang.String outputFilename)
! Attention ! Up to 68 seconds on a Raspberry Pi 2 for a picture of 2592x1944.
4 seconds for a picture of 640x480.
image
- the org.opencv.core.Mat object corresponding to the image to analyze.outputFilename
- the name given to the newly created image with detected faces.public static boolean surroundFaces(org.opencv.core.Mat image, org.opencv.core.Rect[] faces, java.lang.String outputFilename)
image
- the input image previously analyzed.faces
- array of coordinates corresponding to the previously detected faces.outputFilename
- the output file name.public static org.opencv.core.Rect[] detectFaces(org.opencv.core.Mat image)
! Attention ! Up to 68 seconds on a Raspberry Pi 2 for a picture of 2592x1944.
4 seconds for a picture of 640x480.
image
- the org.opencv.core.Mat object corresponding to the image to analyze.public static void setHaarcascadeFrontalfaceAltXmlFilePath(java.lang.String filePath)
detectFaces(Mat)
, detectFacesNb(Mat)
and detectAndSurroundFaces(Mat, String)
.
Default file path is "/home/pi/opencv/data/haarcascades/haarcascade_frontalface_alt.xml".
filePath
- the new file path of the OpenCV haarcascade_frontalface_alt.xml file to use to detect faces.