Package com.libremobileos.yifan.face
Class FaceRecognizer
- java.lang.Object
-
- com.libremobileos.yifan.face.FaceRecognizer
-
public class FaceRecognizer extends Object
Task-specific API for detecting & recognizing faces in an image. UsesFaceFinderto detect and scan faces,FaceStorageBackendto store and retrieve the saved faces and returns the optimal result.
Refrain from using this class for registering faces into the recognition system,FaceFinderdoes not perform post processing and is as such better suited.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFaceRecognizer.FaceStores a combination ofFaceScanner.FaceandFaceDetector.Face, for face recognition workloads
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FaceRecognizercreate(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, float minModelRatio)CreateFaceRecognizerinstance, with matching model ratio constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).static FaceRecognizercreate(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, float minModelRatio, boolean hwAcceleration, boolean enhancedHwAcceleration, int numThreads)CreateFaceRecognizerinstance, with matching model ratio constraint.static FaceRecognizercreate(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, int minMatchingModels)CreateFaceRecognizerinstance, with minimum matching model constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).static FaceRecognizercreate(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, int minMatchingModels, boolean hwAcceleration, boolean enhancedHwAcceleration, int numThreads)CreateFaceRecognizerinstance, with minimum matching model constraint.List<FaceRecognizer.Face>recognize(Bitmap input)Detect faces and scan them
-
-
-
Method Detail
-
create
public static FaceRecognizer create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, int minMatchingModels, boolean hwAcceleration, boolean enhancedHwAcceleration, int numThreads)
CreateFaceRecognizerinstance, with minimum matching model constraint.- Parameters:
ctx- AndroidContextobject, may be in background.storage- TheFaceStorageBackendcontaining faces to be recognized.minConfidence- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth- width of theBitmaps that are going to be processedinputHeight- height of theBitmaps that are going to be processedsensorOrientation- rotation if the image should be rotated, or 0.maxDistance- Maximum distance (difference, not 3D distance) to a saved face to count as recognized. Must be higher than 0.0f and smaller than 1.0fminMatchingModels- Minimum count of matching models for one face to count as recognized. If undesired, set to 1hwAcceleration- Enable hardware acceleration (NNAPI/GPU)enhancedHwAcceleration- if hwAcceleration is enabled, use NNAPI instead of GPU. if not, this toggles XNNPACKnumThreads- How many threads to use, if running on CPU or with XNNPACK- Returns:
FaceRecognizerinstance.- See Also:
create(Context, FaceStorageBackend, float, int, int, int, float, float, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, float),create(Context, FaceStorageBackend, float, int, int, int, float, int)
-
create
public static FaceRecognizer create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, float minModelRatio, boolean hwAcceleration, boolean enhancedHwAcceleration, int numThreads)
CreateFaceRecognizerinstance, with matching model ratio constraint.- Parameters:
ctx- AndroidContextobject, may be in background.storage- TheFaceStorageBackendcontaining faces to be recognized.minConfidence- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth- width of theBitmaps that are going to be processedinputHeight- height of theBitmaps that are going to be processedsensorOrientation- rotation if the image should be rotated, or 0.maxDistance- Maximum distance (difference, not 3D distance) to a saved face to count as recognized. Must be higher than 0.0f and smaller than 1.0fminModelRatio- Minimum count of matching models for one face to count as recognized. Must be higher or equal to 0.0f and smaller or equal to 1.0f. If undesired, set to 0fhwAcceleration- Enable hardware acceleration (NNAPI/GPU)enhancedHwAcceleration- if hwAcceleration is enabled, use NNAPI instead of GPU. if not, this toggles XNNPACKnumThreads- How many threads to use, if running on CPU or with XNNPACK- Returns:
FaceRecognizerinstance.- See Also:
create(Context, FaceStorageBackend, float, int, int, int, float, int, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, float),create(Context, FaceStorageBackend, float, int, int, int, float, int)
-
create
public static FaceRecognizer create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, int minMatchingModels)
CreateFaceRecognizerinstance, with minimum matching model constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).- Parameters:
ctx- AndroidContextobject, may be in background.storage- TheFaceStorageBackendcontaining faces to be recognized.minConfidence- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth- width of theBitmaps that are going to be processedinputHeight- height of theBitmaps that are going to be processedsensorOrientation- rotation if the image should be rotated, or 0.maxDistance- Maximum distance (difference, not 3D distance) to a saved face to count as recognized. Must be higher than 0.0f and smaller than 1.0fminMatchingModels- Minimum count of matching models for one face to count as recognized. If undesired, set to 1- Returns:
FaceRecognizerinstance.- See Also:
create(Context, FaceStorageBackend, float, int, int, int, float, float, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, int, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, float)
-
create
public static FaceRecognizer create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, float minModelRatio)
CreateFaceRecognizerinstance, with matching model ratio constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).- Parameters:
ctx- AndroidContextobject, may be in background.storage- TheFaceStorageBackendcontaining faces to be recognized.minConfidence- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth- width of theBitmaps that are going to be processedinputHeight- height of theBitmaps that are going to be processedsensorOrientation- rotation if the image should be rotated, or 0.maxDistance- Maximum distance (difference, not 3D distance) to a saved face to count as recognized. Must be higher than 0.0f and smaller than 1.0fminModelRatio- Minimum count of matching models for one face to count as recognized. Must be higher or equal to 0.0f and smaller or equal to 1.0f. If undesired, set to 0f- Returns:
FaceRecognizerinstance.- See Also:
create(Context, FaceStorageBackend, float, int, int, int, float, int, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, float, boolean, boolean, int),create(Context, FaceStorageBackend, float, int, int, int, float, int)
-
recognize
public List<FaceRecognizer.Face> recognize(Bitmap input)
Detect faces and scan them- Parameters:
input-Bitmapto process- Returns:
ListofFaceRecognizer.Faces
-
-