Added optional removal of Z position in gesture recognizer test util
This commit is contained in:
parent
4438606f3f
commit
f51dd05e89
|
@ -98,7 +98,8 @@ static const float kLandmarksErrorTolerance = 0.03f;
|
||||||
|
|
||||||
return [MPPGestureRecognizerResult
|
return [MPPGestureRecognizerResult
|
||||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
||||||
gestureLabel:kExpectedThumbUpLabel];
|
gestureLabel:kExpectedThumbUpLabel
|
||||||
|
shouldRemoveZPosition:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (MPPGestureRecognizerResult *)fistGestureRecognizerResultWithLabel:(NSString *)gestureLabel {
|
+ (MPPGestureRecognizerResult *)fistGestureRecognizerResultWithLabel:(NSString *)gestureLabel {
|
||||||
|
@ -106,7 +107,8 @@ static const float kLandmarksErrorTolerance = 0.03f;
|
||||||
|
|
||||||
return [MPPGestureRecognizerResult
|
return [MPPGestureRecognizerResult
|
||||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
||||||
gestureLabel:gestureLabel];
|
gestureLabel:gestureLabel
|
||||||
|
shouldRemoveZPosition:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)assertMultiHandLandmarks:(NSArray<NSArray<MPPNormalizedLandmark *> *> *)multiHandLandmarks
|
- (void)assertMultiHandLandmarks:(NSArray<NSArray<MPPNormalizedLandmark *> *> *)multiHandLandmarks
|
||||||
|
|
|
@ -20,7 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
+ (MPPGestureRecognizerResult *)
|
+ (MPPGestureRecognizerResult *)
|
||||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
||||||
gestureLabel:(NSString *)gestureLabel;
|
gestureLabel:(NSString *)gestureLabel
|
||||||
|
shouldRemoveZPosition:(BOOL)removeZPosition;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -33,12 +33,15 @@ using ::mediapipe::tasks::ios::test::vision::utils::get_proto_from_pbtxt;
|
||||||
|
|
||||||
+ (MPPGestureRecognizerResult *)
|
+ (MPPGestureRecognizerResult *)
|
||||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
||||||
gestureLabel:(NSString *)gestureLabel {
|
gestureLabel:(NSString *)gestureLabel
|
||||||
|
shouldRemoveZPosition:(BOOL)removeZPosition {
|
||||||
LandmarksDetectionResultProto landmarkDetectionResultProto;
|
LandmarksDetectionResultProto landmarkDetectionResultProto;
|
||||||
|
|
||||||
if (!get_proto_from_pbtxt(fileName.cppString, landmarkDetectionResultProto).ok()) {
|
if (!get_proto_from_pbtxt(fileName.cppString, landmarkDetectionResultProto).ok()) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removeZPosition) {
|
||||||
// Remove z position of landmarks, because they are not used in correctness
|
// Remove z position of landmarks, because they are not used in correctness
|
||||||
// testing. For video or live stream mode, the z positions varies a lot during
|
// testing. For video or live stream mode, the z positions varies a lot during
|
||||||
// tracking from frame to frame.
|
// tracking from frame to frame.
|
||||||
|
@ -46,6 +49,7 @@ using ::mediapipe::tasks::ios::test::vision::utils::get_proto_from_pbtxt;
|
||||||
auto &landmark = *landmarkDetectionResultProto.mutable_landmarks()->mutable_landmark(i);
|
auto &landmark = *landmarkDetectionResultProto.mutable_landmarks()->mutable_landmark(i);
|
||||||
landmark.clear_z();
|
landmark.clear_z();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ClassificationListProto gesturesProto;
|
ClassificationListProto gesturesProto;
|
||||||
ClassificationProto *classificationProto = gesturesProto.add_classification();
|
ClassificationProto *classificationProto = gesturesProto.add_classification();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user