feat:人脸识别人脸占比设置
This commit is contained in:
1 parent
382b8d660f
commit
e75b3bd58e
10 files changed
+475
-110
No files matched your search
@@ -90,6 +90,7 @@ class FaceRecognitionConfiguration {
|
||||
required this.recognizeFailedRetryInterval,
|
||||
required this.livenessFailedRetryInterval,
|
||||
required this.livenessType,
|
||||
this.minFaceAreaPercent = 5.0,
|
||||
});
|
||||
|
||||
const FaceRecognitionConfiguration.defaults()
|
||||
@@ -102,6 +103,7 @@ class FaceRecognitionConfiguration {
|
||||
libraryFaceQualityThreshold = 0.60,
|
||||
keepMaxFace = true,
|
||||
maxDetectFaces = 1,
|
||||
minFaceAreaPercent = 5.0,
|
||||
extractRetryCount = 3,
|
||||
livenessRetryCount = 3,
|
||||
recognizeFailedRetryInterval = 0,
|
||||
@@ -119,6 +121,9 @@ class FaceRecognitionConfiguration {
|
||||
final double libraryFaceQualityThreshold;
|
||||
final bool keepMaxFace;
|
||||
final int maxDetectFaces;
|
||||
|
||||
/// 人脸框占相机完整画面的最小面积百分比,达到该值才开始识别。
|
||||
final double minFaceAreaPercent;
|
||||
final int extractRetryCount;
|
||||
final int livenessRetryCount;
|
||||
final int recognizeFailedRetryInterval;
|
||||
@@ -151,6 +156,7 @@ class FaceRecognitionConfiguration {
|
||||
).clamp(0.0, 1.0).toDouble(),
|
||||
keepMaxFace: _asBoolOr(map['keepMaxFace'], defaults.keepMaxFace),
|
||||
maxDetectFaces: _asIntOr(map['maxDetectFaces'], defaults.maxDetectFaces),
|
||||
minFaceAreaPercent: _asFaceAreaPercent(map['minFaceAreaPercent']),
|
||||
extractRetryCount:
|
||||
_asIntOr(map['extractRetryCount'], defaults.extractRetryCount),
|
||||
livenessRetryCount:
|
||||
@@ -180,6 +186,7 @@ class FaceRecognitionConfiguration {
|
||||
libraryFaceQualityThreshold.clamp(0.0, 1.0).toDouble(),
|
||||
'keepMaxFace': keepMaxFace,
|
||||
'maxDetectFaces': maxDetectFaces,
|
||||
'minFaceAreaPercent': minFaceAreaPercent,
|
||||
'extractRetryCount': extractRetryCount,
|
||||
'livenessRetryCount': livenessRetryCount,
|
||||
'recognizeFailedRetryInterval': recognizeFailedRetryInterval,
|
||||
@@ -200,6 +207,7 @@ class FaceRecognitionConfiguration {
|
||||
double? libraryFaceQualityThreshold,
|
||||
bool? keepMaxFace,
|
||||
int? maxDetectFaces,
|
||||
double? minFaceAreaPercent,
|
||||
int? extractRetryCount,
|
||||
int? livenessRetryCount,
|
||||
int? recognizeFailedRetryInterval,
|
||||
@@ -221,6 +229,7 @@ class FaceRecognitionConfiguration {
|
||||
.toDouble(),
|
||||
keepMaxFace: keepMaxFace ?? this.keepMaxFace,
|
||||
maxDetectFaces: maxDetectFaces ?? this.maxDetectFaces,
|
||||
minFaceAreaPercent: minFaceAreaPercent ?? this.minFaceAreaPercent,
|
||||
extractRetryCount: extractRetryCount ?? this.extractRetryCount,
|
||||
livenessRetryCount: livenessRetryCount ?? this.livenessRetryCount,
|
||||
recognizeFailedRetryInterval:
|
||||
@@ -246,6 +255,7 @@ class FaceRecognitionConfiguration {
|
||||
libraryFaceQualityThreshold == other.libraryFaceQualityThreshold &&
|
||||
keepMaxFace == other.keepMaxFace &&
|
||||
maxDetectFaces == other.maxDetectFaces &&
|
||||
minFaceAreaPercent == other.minFaceAreaPercent &&
|
||||
extractRetryCount == other.extractRetryCount &&
|
||||
livenessRetryCount == other.livenessRetryCount &&
|
||||
recognizeFailedRetryInterval == other.recognizeFailedRetryInterval &&
|
||||
@@ -263,6 +273,7 @@ class FaceRecognitionConfiguration {
|
||||
libraryFaceQualityThreshold,
|
||||
keepMaxFace,
|
||||
maxDetectFaces,
|
||||
minFaceAreaPercent,
|
||||
extractRetryCount,
|
||||
livenessRetryCount,
|
||||
recognizeFailedRetryInterval,
|
||||
@@ -736,6 +747,13 @@ int _asIntOr(dynamic value, int fallback) =>
|
||||
double _asDouble(dynamic value, double fallback) =>
|
||||
value is num ? value.toDouble() : fallback;
|
||||
|
||||
double _asFaceAreaPercent(dynamic value) {
|
||||
final percent = value is num ? value.toDouble() : double.nan;
|
||||
return percent.isFinite && percent >= 1 && percent <= 100
|
||||
? percent
|
||||
: const FaceRecognitionConfiguration.defaults().minFaceAreaPercent;
|
||||
}
|
||||
|
||||
bool _asBoolOr(dynamic value, bool fallback) =>
|
||||
value is bool ? value : fallback;
|
||||
|
||||
|
||||
Reference in new issue
Block a user