Used loops instead of complex list comprehensions

This commit is contained in:
kinaryml 2022-11-08 10:52:26 -08:00
parent c0265ca2ac
commit 88ab9d4922
2 changed files with 20 additions and 16 deletions

View File

@ -122,19 +122,21 @@ def _build_recognition_result(
for proto in hand_landmarks_proto_list: for proto in hand_landmarks_proto_list:
hand_landmarks = landmark_pb2.NormalizedLandmarkList() hand_landmarks = landmark_pb2.NormalizedLandmarkList()
hand_landmarks.MergeFrom(proto) hand_landmarks.MergeFrom(proto)
hand_landmarks_results.append([ hand_landmarks_list = []
landmark_module.NormalizedLandmark.create_from_pb2(hand_landmark) for hand_landmark in hand_landmarks.landmark:
for hand_landmark in hand_landmarks.landmark hand_landmarks_list.append(
]) landmark_module.NormalizedLandmark.create_from_pb2(hand_landmark))
hand_landmarks_results.append(hand_landmarks_list)
hand_world_landmarks_results = [] hand_world_landmarks_results = []
for proto in hand_world_landmarks_proto_list: for proto in hand_world_landmarks_proto_list:
hand_world_landmarks = landmark_pb2.LandmarkList() hand_world_landmarks = landmark_pb2.LandmarkList()
hand_world_landmarks.MergeFrom(proto) hand_world_landmarks.MergeFrom(proto)
hand_world_landmarks_results.append([ hand_world_landmarks_list = []
landmark_module.Landmark.create_from_pb2(hand_world_landmark) for hand_world_landmark in hand_world_landmarks.landmark:
for hand_world_landmark in hand_world_landmarks.landmark hand_world_landmarks_list.append(
]) landmark_module.Landmark.create_from_pb2(hand_world_landmark))
hand_world_landmarks_results.append(hand_world_landmarks_list)
return GestureRecognitionResult(gesture_results, handedness_results, return GestureRecognitionResult(gesture_results, handedness_results,
hand_landmarks_results, hand_landmarks_results,

View File

@ -98,19 +98,21 @@ def _build_detection_result(
for proto in hand_landmarks_proto_list: for proto in hand_landmarks_proto_list:
hand_landmarks = landmark_pb2.NormalizedLandmarkList() hand_landmarks = landmark_pb2.NormalizedLandmarkList()
hand_landmarks.MergeFrom(proto) hand_landmarks.MergeFrom(proto)
hand_landmarks_results.append([ hand_landmarks_list = []
landmark_module.NormalizedLandmark.create_from_pb2(hand_landmark) for hand_landmark in hand_landmarks.landmark:
for hand_landmark in hand_landmarks.landmark hand_landmarks_list.append(
]) landmark_module.NormalizedLandmark.create_from_pb2(hand_landmark))
hand_landmarks_results.append(hand_landmarks_list)
hand_world_landmarks_results = [] hand_world_landmarks_results = []
for proto in hand_world_landmarks_proto_list: for proto in hand_world_landmarks_proto_list:
hand_world_landmarks = landmark_pb2.LandmarkList() hand_world_landmarks = landmark_pb2.LandmarkList()
hand_world_landmarks.MergeFrom(proto) hand_world_landmarks.MergeFrom(proto)
hand_world_landmarks_results.append([ hand_world_landmarks_list = []
landmark_module.Landmark.create_from_pb2(hand_world_landmark) for hand_world_landmark in hand_world_landmarks.landmark:
for hand_world_landmark in hand_world_landmarks.landmark hand_world_landmarks_list.append(
]) landmark_module.Landmark.create_from_pb2(hand_world_landmark))
hand_world_landmarks_results.append(hand_world_landmarks_list)
return HandLandmarksDetectionResult(handedness_results, return HandLandmarksDetectionResult(handedness_results,
hand_landmarks_results, hand_landmarks_results,