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. UsesFaceFinder
to detect and scan faces,FaceStorageBackend
to store and retrieve the saved faces and returns the optimal result.
Refrain from using this class for registering faces into the recognition system,FaceFinder
does not perform post processing and is as such better suited.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FaceRecognizer.Face
Stores a combination ofFaceScanner.Face
andFaceDetector.Face
, for face recognition workloads
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FaceRecognizer
create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, float minModelRatio)
CreateFaceRecognizer
instance, with matching model ratio constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).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)
CreateFaceRecognizer
instance, with matching model ratio constraint.static FaceRecognizer
create(Context ctx, FaceStorageBackend storage, float minConfidence, int inputWidth, int inputHeight, int sensorOrientation, float maxDistance, int minMatchingModels)
CreateFaceRecognizer
instance, with minimum matching model constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).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)
CreateFaceRecognizer
instance, 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)
CreateFaceRecognizer
instance, with minimum matching model constraint.- Parameters:
ctx
- AndroidContext
object, may be in background.storage
- TheFaceStorageBackend
containing faces to be recognized.minConfidence
- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth
- width of theBitmap
s that are going to be processedinputHeight
- height of theBitmap
s 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:
FaceRecognizer
instance.- 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)
CreateFaceRecognizer
instance, with matching model ratio constraint.- Parameters:
ctx
- AndroidContext
object, may be in background.storage
- TheFaceStorageBackend
containing faces to be recognized.minConfidence
- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth
- width of theBitmap
s that are going to be processedinputHeight
- height of theBitmap
s 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:
FaceRecognizer
instance.- 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)
CreateFaceRecognizer
instance, with minimum matching model constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).- Parameters:
ctx
- AndroidContext
object, may be in background.storage
- TheFaceStorageBackend
containing faces to be recognized.minConfidence
- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth
- width of theBitmap
s that are going to be processedinputHeight
- height of theBitmap
s 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:
FaceRecognizer
instance.- 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)
CreateFaceRecognizer
instance, with matching model ratio constraint and sensible defaults regarding hardware acceleration (CPU, XNNPACK, 4 threads).- Parameters:
ctx
- AndroidContext
object, may be in background.storage
- TheFaceStorageBackend
containing faces to be recognized.minConfidence
- Minimum confidence to track a detection, must be higher than 0.0f and smaller than 1.0finputWidth
- width of theBitmap
s that are going to be processedinputHeight
- height of theBitmap
s 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:
FaceRecognizer
instance.- 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
-Bitmap
to process- Returns:
List
ofFaceRecognizer.Face
s
-
-