fix: 修复特征提取失败(错误码81929)
问题: extractFaceFeature 返回错误码 81929 (MERR_FSDK_FACEFEATURE_FACEDATA) 根本原因: detectFaces 返回的人脸信息缺少 faceData 字段, 而虹软 SDK 的 extractFaceFeature 必须要有这个字段才能提取特征 修复: - FaceEngineManager.convertFaceInfoToList: 添加返回 faceData - ArcPlugin.handleExtractFaceFeature: 接收并传递 faceData 参数 - Dart API: extractFaceFeature 添加 faceData 参数 - example: 传递 faceData 到特征提取调用 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
89
test/arc_test.dart
Normal file
89
test/arc_test.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:arc/arc.dart';
|
||||
import 'package:arc/arc_platform_interface.dart';
|
||||
import 'package:arc/arc_method_channel.dart';
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class MockArcPlatform
|
||||
with MockPlatformInterfaceMixin
|
||||
implements ArcPlatform {
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() => Future.value('42');
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> activeOnline({
|
||||
required String appId,
|
||||
required String sdkKey,
|
||||
required String activeKey,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'message': 'success'});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> init({
|
||||
int? detectMode,
|
||||
int? orient,
|
||||
int? maxFaceNum,
|
||||
int? combinedMask,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'message': 'success'});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> detectFaces({
|
||||
required Uint8List data,
|
||||
required int width,
|
||||
required int height,
|
||||
int format = 2050,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'faceList': [], 'rgbLiveness': 1, 'isRgbAlive': true});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> extractFaceFeature({
|
||||
required Uint8List data,
|
||||
required int width,
|
||||
required int height,
|
||||
required int rectLeft,
|
||||
required int rectTop,
|
||||
required int rectRight,
|
||||
required int rectBottom,
|
||||
int format = 2050,
|
||||
int faceOrientation = 0,
|
||||
int faceId = -1,
|
||||
Uint8List? faceData,
|
||||
int extractType = 1,
|
||||
int mask = 0,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'featureData': Uint8List(512)});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> compareFaceFeature({
|
||||
required Uint8List featureData1,
|
||||
required Uint8List featureData2,
|
||||
int compareModel = 0,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'similarity': 0.95});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> registerFaceFeature({
|
||||
required int searchId,
|
||||
required Uint8List featureData,
|
||||
String? faceTag,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'message': 'success'});
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>?> registerFaceFeatureBatch({
|
||||
required List<Map<String, dynamic>> faceList,
|
||||
}) => Future.value({'success': true, 'errorCode': 0, 'message': 'success'});
|
||||
}
|
||||
|
||||
void main() {
|
||||
final ArcPlatform initialPlatform = ArcPlatform.instance;
|
||||
|
||||
test('$MethodChannelArc is the default instance', () {
|
||||
expect(initialPlatform, isInstanceOf<MethodChannelArc>());
|
||||
});
|
||||
|
||||
test('getPlatformVersion', () async {
|
||||
Arc arcPlugin = Arc();
|
||||
MockArcPlatform fakePlatform = MockArcPlatform();
|
||||
ArcPlatform.instance = fakePlatform;
|
||||
|
||||
expect(await arcPlugin.getPlatformVersion(), '42');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user