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
|
||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
||||
gestureLabel:kExpectedThumbUpLabel];
|
||||
gestureLabel:kExpectedThumbUpLabel
|
||||
shouldRemoveZPosition:YES];
|
||||
}
|
||||
|
||||
+ (MPPGestureRecognizerResult *)fistGestureRecognizerResultWithLabel:(NSString *)gestureLabel {
|
||||
|
@ -106,7 +107,8 @@ static const float kLandmarksErrorTolerance = 0.03f;
|
|||
|
||||
return [MPPGestureRecognizerResult
|
||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:filePath
|
||||
gestureLabel:gestureLabel];
|
||||
gestureLabel:gestureLabel
|
||||
shouldRemoveZPosition:YES];
|
||||
}
|
||||
|
||||
- (void)assertMultiHandLandmarks:(NSArray<NSArray<MPPNormalizedLandmark *> *> *)multiHandLandmarks
|
||||
|
|
|
@ -20,7 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
+ (MPPGestureRecognizerResult *)
|
||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
||||
gestureLabel:(NSString *)gestureLabel;
|
||||
gestureLabel:(NSString *)gestureLabel
|
||||
shouldRemoveZPosition:(BOOL)removeZPosition;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -33,18 +33,22 @@ using ::mediapipe::tasks::ios::test::vision::utils::get_proto_from_pbtxt;
|
|||
|
||||
+ (MPPGestureRecognizerResult *)
|
||||
gestureRecognizerResultsFromTextEncodedProtobufFileWithName:(NSString *)fileName
|
||||
gestureLabel:(NSString *)gestureLabel {
|
||||
gestureLabel:(NSString *)gestureLabel
|
||||
shouldRemoveZPosition:(BOOL)removeZPosition {
|
||||
LandmarksDetectionResultProto landmarkDetectionResultProto;
|
||||
|
||||
if (!get_proto_from_pbtxt(fileName.cppString, landmarkDetectionResultProto).ok()) {
|
||||
return nil;
|
||||
}
|
||||
// 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
|
||||
// tracking from frame to frame.
|
||||
for (int i = 0; i < landmarkDetectionResultProto.landmarks().landmark().size(); i++) {
|
||||
auto &landmark = *landmarkDetectionResultProto.mutable_landmarks()->mutable_landmark(i);
|
||||
landmark.clear_z();
|
||||
|
||||
if (removeZPosition) {
|
||||
// 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
|
||||
// tracking from frame to frame.
|
||||
for (int i = 0; i < landmarkDetectionResultProto.landmarks().landmark().size(); i++) {
|
||||
auto &landmark = *landmarkDetectionResultProto.mutable_landmarks()->mutable_landmark(i);
|
||||
landmark.clear_z();
|
||||
}
|
||||
}
|
||||
|
||||
ClassificationListProto gesturesProto;
|
||||
|
|
Loading…
Reference in New Issue
Block a user