Package com.anlavn.opencv
Class FaceRecognition
java.lang.Object
com.anlavn.opencv.FaceRecognition
The FaceRecognition class supports to face recognition in java, using python program compiled.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final DoubleUse this method to get facial recognition percentage.static final BooleanisMatch()Use this method to check if the face matches the original face?static final voidUse this method to check Module support for face recognition.
Run this method first.static final StringUse this method to recognition and get result after setup successfully all parameter.static final voidsetImageOrginal(BufferedImage buff) Use this method to set image for original face from BufferedImage.static final voidsetImageOrginal(String image) Use this method to set image for original face from File or URL.static final voidsetImageTesting(BufferedImage buff) Use this method to set image for testing face from BufferedImage.static final voidsetImageTesting(String image) Use this method to set image for testing face from File or URL.static final voidUse this method to set the required percentage for face recognition.
-
Constructor Details
-
FaceRecognition
public FaceRecognition()
-
-
Method Details
-
loadModule
public static final void loadModule()Use this method to check Module support for face recognition.
Run this method first. -
setImageOrginal
Use this method to set image for original face from File or URL.- Parameters:
image- is specific location of face image, it can be local path in computer or link address of image.
Example: "C:/Users/Admin/Pictures/funfact.jpg"
or "https://www.onthisday.com/images/people/rowan-atkinson-medium.jpg"- Throws:
IOException- throw an exception if there is no internet connection or can't download image from link.- See Also:
-
setImageTesting
Use this method to set image for testing face from File or URL.- Parameters:
image- is specific location of face image, it can be local path in computer or link address of image.
Example: "C:/Users/Admin/Pictures/funfact.jpg"
or "https://www.onthisday.com/images/people/rowan-atkinson-medium.jpg"- Throws:
IOException- throw an exception if there is no internet connection or can't download image from link.- See Also:
-
setImageOrginal
Use this method to set image for original face from BufferedImage.- Parameters:
buff- is BufferedImage of face image.- Throws:
IOException- throw an exception if can't write BufferedImage to file.- See Also:
-
setImageTesting
Use this method to set image for testing face from BufferedImage.- Parameters:
buff- is BufferedImage of face image.- Throws:
IOException- throw an exception if can't write BufferedImage to file.- See Also:
-
setRequirementPercent
Use this method to set the required percentage for face recognition. More high more hard. 65 is typical best performance and the default value also.- Parameters:
per- is percentage required for face recognition to returntrue.- See Also:
-
Recognition
Use this method to recognition and get result after setup successfully all parameter.- Returns:
- Result after recognition:
[True]if Testing Face match Original Face and Percent greater than or equal to RequirementPercent.
[False]if Testing Face does not match Original Face or Percent less than RequirementPercent.
[Empty Error]if Original Face or Testing Face not exists.
[Invalid Version]if the current version of FaceRecognition does not match the requirements version. Then the program will stop immediately.
[Connection Error]if an exception occurs when checking the requirements version. Then the program will stop immediately.
[Face Recognition Error]if an exception occurs when recognizing face. Like:
1. No or too many faces in the frame.
2. Brightness is too low.
3. The distance between the face and the camera is too far.
4. There are masks, glasses, hair covering the face... - See Also:
-
getPercent
Use this method to get facial recognition percentage.- Returns:
Percentaccuracy of face after recognition.- See Also:
-
isMatch
Use this method to check if the face matches the original face?- Returns:
trueif Testing Face match Original Face.
falseif Testing Face does not match Original Face- See Also:
-