Package org.ptolemy.opencv
Class FaceRecognizer
- java.lang.Object
-
- org.ptolemy.opencv.FaceRecognizer
-
public class FaceRecognizer extends java.lang.ObjectA face recognition image filter. This filter detects faces in the given frame that lie in a square of dimensions [x,x], where _minFaceSize <= x >= _maxFaceSize. The parameters of the filter are:- MinFaceSize: Minimum face size to be considered ( one side of a bounding square)
- MaxFaceSize: Maximum face size to be considered ( one side of a bounding square)
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (cxh)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFaceRecognizer.EyesA filter that detects eyes and faces.classFaceRecognizer.FacesA filter that detects faces.
-
Constructor Summary
Constructors Constructor Description FaceRecognizer()Construct an instance of FaceRecognizer and load the face recognition classifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.opencv.core.MatbufferedImage2Mat(java.awt.image.BufferedImage source)Convert a BufferedImage object to OpenCV's Mat representation.org.opencv.core.Rect[]detectFaces(org.opencv.core.Mat img)Detect faces.java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage source, java.lang.String filterName)Apply the specified filter to the source image.intgetFaceCount()Return the number of faces detected.org.opencv.core.Rect[]getFaceRectangles()Return the number of faces detected.java.awt.image.BufferedImagemat2BufferedImage(org.opencv.core.Mat matrix)Convert a Mat image into a BufferedImage.voidsetMaxFaceSize(int size)Set the maximum face size.voidsetMinFaceSize(int size)Set the minimum face size.java.lang.StringtoString()Return a string description of the filter.
-
-
-
Method Detail
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage source, java.lang.String filterName) throws IllegalActionExceptionApply the specified filter to the source image.- Parameters:
source- The source image to transform.filterName- "eyes" or "faces".- Returns:
- The transformed image.
- Throws:
IllegalActionException- If the filter is anything other than "eyes" or "faces".
-
bufferedImage2Mat
public org.opencv.core.Mat bufferedImage2Mat(java.awt.image.BufferedImage source)
Convert a BufferedImage object to OpenCV's Mat representation.- Parameters:
source- BufferedImage input- Returns:
- Mat matrix
-
mat2BufferedImage
public java.awt.image.BufferedImage mat2BufferedImage(org.opencv.core.Mat matrix)
Convert a Mat image into a BufferedImage.- Parameters:
matrix- Mat input- Returns:
- BufferedImage output
-
detectFaces
public org.opencv.core.Rect[] detectFaces(org.opencv.core.Mat img) throws java.io.IOExceptionDetect faces.- Parameters:
img- The image containing faces- Returns:
- An array of faces.
- Throws:
java.io.IOException- if the haar cascade file cannot be found.
-
getFaceCount
public int getFaceCount()
Return the number of faces detected.- Returns:
- The number of faces detected.
-
getFaceRectangles
public org.opencv.core.Rect[] getFaceRectangles()
Return the number of faces detected.- Returns:
- The number of faces detected.
-
setMinFaceSize
public void setMinFaceSize(int size) throws IllegalActionExceptionSet the minimum face size.- Parameters:
size- the minimum face size, which must be positive.- Throws:
IllegalActionException- If the value of the size parameter is less than 0.
-
setMaxFaceSize
public void setMaxFaceSize(int size) throws IllegalActionExceptionSet the maximum face size.- Parameters:
size- the maximum face size, which must be positive.- Throws:
IllegalActionException- If the value of the size parameter is less than 0.
-
toString
public java.lang.String toString()
Return a string description of the filter.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string "MotionDetectorFilter".
-
-