Skip to content

Commit ae3888e

Browse files
authored
refactor: stop using deprecated APIs (#1121)
* chore: stop using deprecated methods * refactor!: return an empty string if the ptr is IntPtr.Zero
1 parent 4f3668e commit ae3888e

File tree

29 files changed

+153
-163
lines changed

29 files changed

+153
-163
lines changed

Assets/MediaPipeUnity/Samples/Scenes/Face Detection/FaceDetectionGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task<List<Detection>> WaitNext()
6666

6767
_ = TryGetValue(result.packet, out var faceDetections, (packet) =>
6868
{
69-
return packet.GetProtoList(Detection.Parser);
69+
return packet.Get(Detection.Parser);
7070
});
7171

7272
return faceDetections;

Assets/MediaPipeUnity/Samples/Scenes/Face Detection/FaceDetectionSolution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected override IEnumerator WaitForNextValue()
5252
private void OnFaceDetectionsOutput(object stream, OutputStream<List<Detection>>.OutputEventArgs eventArgs)
5353
{
5454
var packet = eventArgs.packet;
55-
var value = packet == null ? default : packet.GetProtoList(Detection.Parser);
55+
var value = packet == null ? default : packet.Get(Detection.Parser);
5656
_faceDetectionsAnnotationController.DrawLater(value);
5757
}
5858
}

Assets/MediaPipeUnity/Samples/Scenes/Face Mesh/FaceMeshGraph.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@ public async Task<FaceMeshResult> WaitNext()
127127

128128
_ = TryGetValue(results.Item1.packet, out var faceDetections, (packet) =>
129129
{
130-
return packet.GetProtoList(Detection.Parser);
130+
return packet.Get(Detection.Parser);
131131
});
132132
_ = TryGetValue(results.Item2.packet, out var multiFaceLandmarks, (packet) =>
133133
{
134-
return packet.GetProtoList(NormalizedLandmarkList.Parser);
134+
return packet.Get(NormalizedLandmarkList.Parser);
135135
});
136136
_ = TryGetValue(results.Item3.packet, out var faceRectsFromLandmarks, (packet) =>
137137
{
138-
return packet.GetProtoList(NormalizedRect.Parser);
138+
return packet.Get(NormalizedRect.Parser);
139139
});
140140
_ = TryGetValue(results.Item4.packet, out var faceRectsFromDetections, (packet) =>
141141
{
142-
return packet.GetProtoList(NormalizedRect.Parser);
142+
return packet.Get(NormalizedRect.Parser);
143143
});
144144

145145
return new FaceMeshResult(faceDetections, multiFaceLandmarks, faceRectsFromLandmarks, faceRectsFromDetections);

Assets/MediaPipeUnity/Samples/Scenes/Face Mesh/FaceMeshSolution.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ protected override IEnumerator WaitForNextValue()
7878
private void OnFaceDetectionsOutput(object stream, OutputStream<List<Detection>>.OutputEventArgs eventArgs)
7979
{
8080
var packet = eventArgs.packet;
81-
var value = packet == null ? default : packet.GetProtoList(Detection.Parser);
81+
var value = packet == null ? default : packet.Get(Detection.Parser);
8282
_faceDetectionsAnnotationController.DrawLater(value);
8383
}
8484

8585
private void OnMultiFaceLandmarksOutput(object stream, OutputStream<List<NormalizedLandmarkList>>.OutputEventArgs eventArgs)
8686
{
8787
var packet = eventArgs.packet;
88-
var value = packet == null ? default : packet.GetProtoList(NormalizedLandmarkList.Parser);
88+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
8989
_multiFaceLandmarksAnnotationController.DrawLater(value);
9090
}
9191

9292
private void OnFaceRectsFromLandmarksOutput(object stream, OutputStream<List<NormalizedRect>>.OutputEventArgs eventArgs)
9393
{
9494
var packet = eventArgs.packet;
95-
var value = packet == null ? default : packet.GetProtoList(NormalizedRect.Parser);
95+
var value = packet == null ? default : packet.Get(NormalizedRect.Parser);
9696
_faceRectsFromLandmarksAnnotationController.DrawLater(value);
9797
}
9898

9999
private void OnFaceRectsFromDetectionsOutput(object stream, OutputStream<List<NormalizedRect>>.OutputEventArgs eventArgs)
100100
{
101101
var packet = eventArgs.packet;
102-
var value = packet == null ? default : packet.GetProtoList(NormalizedRect.Parser);
102+
var value = packet == null ? default : packet.Get(NormalizedRect.Parser);
103103
_faceRectsFromDetectionsAnnotationController.DrawLater(value);
104104
}
105105
}

Assets/MediaPipeUnity/Samples/Scenes/Hair Segmentation/HairSegmentationGraph.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ public async Task<ImageFrame> WaitNext()
5454
var result = await _hairMaskStream.WaitNextAsync();
5555
AssertResult(result);
5656

57-
_ = TryGetValue(result.packet, out var hairMask, (packet) =>
58-
{
59-
return packet.GetImageFrame();
60-
});
61-
57+
_ = TryGetValue(result.packet, out var hairMask);
6258
return hairMask;
6359
}
6460

Assets/MediaPipeUnity/Samples/Scenes/Hair Segmentation/HairSegmentationSolution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected override IEnumerator WaitForNextValue()
4141
private void OnHairMaskOutput(object stream, OutputStream<ImageFrame>.OutputEventArgs eventArgs)
4242
{
4343
var packet = eventArgs.packet;
44-
var value = packet == null ? default : packet.GetImageFrame();
44+
var value = packet == null ? default : packet.Get();
4545
_hairMaskAnnotationController.DrawLater(value);
4646
value?.Dispose();
4747
}

Assets/MediaPipeUnity/Samples/Scenes/Hand Tracking/HandTrackingGraph.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,27 @@ public async Task<HandTrackingResult> WaitNext()
162162

163163
_ = TryGetValue(results.Item1.packet, out var palmDetections, (packet) =>
164164
{
165-
return packet.GetProtoList(Detection.Parser);
165+
return packet.Get(Detection.Parser);
166166
});
167167
_ = TryGetValue(results.Item2.packet, out var handRectsFromPalmDetections, (packet) =>
168168
{
169-
return packet.GetProtoList(NormalizedRect.Parser);
169+
return packet.Get(NormalizedRect.Parser);
170170
});
171171
_ = TryGetValue(results.Item3.packet, out var handLandmarks, (packet) =>
172172
{
173-
return packet.GetProtoList(NormalizedLandmarkList.Parser);
173+
return packet.Get(NormalizedLandmarkList.Parser);
174174
});
175175
_ = TryGetValue(results.Item4.packet, out var handWorldLandmarks, (packet) =>
176176
{
177-
return packet.GetProtoList(LandmarkList.Parser);
177+
return packet.Get(LandmarkList.Parser);
178178
});
179179
_ = TryGetValue(results.Item5.packet, out var handRectsFromLandmarks, (packet) =>
180180
{
181-
return packet.GetProtoList(NormalizedRect.Parser);
181+
return packet.Get(NormalizedRect.Parser);
182182
});
183183
_ = TryGetValue(results.Item6.packet, out var handedness, (packet) =>
184184
{
185-
return packet.GetProtoList(ClassificationList.Parser);
185+
return packet.Get(ClassificationList.Parser);
186186
});
187187

188188
return new HandTrackingResult(palmDetections, handRectsFromPalmDetections, handLandmarks, handWorldLandmarks, handRectsFromLandmarks, handedness);

Assets/MediaPipeUnity/Samples/Scenes/Hand Tracking/HandTrackingSolution.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,35 +81,35 @@ protected override IEnumerator WaitForNextValue()
8181
private void OnPalmDetectionsOutput(object stream, OutputStream<List<Detection>>.OutputEventArgs eventArgs)
8282
{
8383
var packet = eventArgs.packet;
84-
var value = packet == null ? default : packet.GetProtoList(Detection.Parser);
84+
var value = packet == null ? default : packet.Get(Detection.Parser);
8585
_palmDetectionsAnnotationController.DrawLater(value);
8686
}
8787

8888
private void OnHandRectsFromPalmDetectionsOutput(object stream, OutputStream<List<NormalizedRect>>.OutputEventArgs eventArgs)
8989
{
9090
var packet = eventArgs.packet;
91-
var value = packet == null ? default : packet.GetProtoList(NormalizedRect.Parser);
91+
var value = packet == null ? default : packet.Get(NormalizedRect.Parser);
9292
_handRectsFromPalmDetectionsAnnotationController.DrawLater(value);
9393
}
9494

9595
private void OnHandLandmarksOutput(object stream, OutputStream<List<NormalizedLandmarkList>>.OutputEventArgs eventArgs)
9696
{
9797
var packet = eventArgs.packet;
98-
var value = packet == null ? default : packet.GetProtoList(NormalizedLandmarkList.Parser);
98+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
9999
_handLandmarksAnnotationController.DrawLater(value);
100100
}
101101

102102
private void OnHandRectsFromLandmarksOutput(object stream, OutputStream<List<NormalizedRect>>.OutputEventArgs eventArgs)
103103
{
104104
var packet = eventArgs.packet;
105-
var value = packet == null ? default : packet.GetProtoList(NormalizedRect.Parser);
105+
var value = packet == null ? default : packet.Get(NormalizedRect.Parser);
106106
_handRectsFromLandmarksAnnotationController.DrawLater(value);
107107
}
108108

109109
private void OnHandednessOutput(object stream, OutputStream<List<ClassificationList>>.OutputEventArgs eventArgs)
110110
{
111111
var packet = eventArgs.packet;
112-
var value = packet == null ? default : packet.GetProtoList(ClassificationList.Parser);
112+
var value = packet == null ? default : packet.Get(ClassificationList.Parser);
113113
_handLandmarksAnnotationController.DrawLater(value);
114114
}
115115
}

Assets/MediaPipeUnity/Samples/Scenes/Holistic/HolisticTrackingGraph.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,35 +194,32 @@ public async Task<HolisticTrackingResult> WaitNextAsync()
194194

195195
_ = TryGetValue(results.Item1.packet, out var poseDetection, (packet) =>
196196
{
197-
return packet.GetProto(Detection.Parser);
197+
return packet.Get(Detection.Parser);
198198
});
199199
_ = TryGetValue(results.Item2.packet, out var poseLandmarks, (packet) =>
200200
{
201-
return packet.GetProto(NormalizedLandmarkList.Parser);
201+
return packet.Get(NormalizedLandmarkList.Parser);
202202
});
203203
_ = TryGetValue(results.Item3.packet, out var faceLandmarks, (packet) =>
204204
{
205-
return packet.GetProto(NormalizedLandmarkList.Parser);
205+
return packet.Get(NormalizedLandmarkList.Parser);
206206
});
207207
_ = TryGetValue(results.Item4.packet, out var leftHandLandmarks, (packet) =>
208208
{
209-
return packet.GetProto(NormalizedLandmarkList.Parser);
209+
return packet.Get(NormalizedLandmarkList.Parser);
210210
});
211211
_ = TryGetValue(results.Item5.packet, out var rightHandLandmarks, (packet) =>
212212
{
213-
return packet.GetProto(NormalizedLandmarkList.Parser);
213+
return packet.Get(NormalizedLandmarkList.Parser);
214214
});
215215
_ = TryGetValue(results.Item6.packet, out var poseWorldLandmarks, (packet) =>
216216
{
217-
return packet.GetProto(LandmarkList.Parser);
218-
});
219-
_ = TryGetValue(results.Item7.packet, out var segmentationMask, (packet) =>
220-
{
221-
return packet.GetImageFrame();
217+
return packet.Get(LandmarkList.Parser);
222218
});
219+
_ = TryGetValue(results.Item7.packet, out var segmentationMask);
223220
_ = TryGetValue(results.Item8.packet, out var poseRoi, (packet) =>
224221
{
225-
return packet.GetProto(NormalizedRect.Parser);
222+
return packet.Get(NormalizedRect.Parser);
226223
});
227224

228225
return new HolisticTrackingResult(poseDetection, poseLandmarks, faceLandmarks, leftHandLandmarks, rightHandLandmarks, poseWorldLandmarks, segmentationMask, poseRoi);

Assets/MediaPipeUnity/Samples/Scenes/Holistic/HolisticTrackingSolution.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,57 +112,57 @@ protected override IEnumerator WaitForNextValue()
112112
private void OnPoseDetectionOutput(object stream, OutputStream<Detection>.OutputEventArgs eventArgs)
113113
{
114114
var packet = eventArgs.packet;
115-
var value = packet == null ? default : packet.GetProto(Detection.Parser);
115+
var value = packet == null ? default : packet.Get(Detection.Parser);
116116
_poseDetectionAnnotationController.DrawLater(value);
117117
}
118118

119119
private void OnFaceLandmarksOutput(object stream, OutputStream<NormalizedLandmarkList>.OutputEventArgs eventArgs)
120120
{
121121
var packet = eventArgs.packet;
122-
var value = packet == null ? default : packet.GetProto(NormalizedLandmarkList.Parser);
122+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
123123
_holisticAnnotationController.DrawFaceLandmarkListLater(value);
124124
}
125125

126126
private void OnPoseLandmarksOutput(object stream, OutputStream<NormalizedLandmarkList>.OutputEventArgs eventArgs)
127127
{
128128
var packet = eventArgs.packet;
129-
var value = packet == null ? default : packet.GetProto(NormalizedLandmarkList.Parser);
129+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
130130
_holisticAnnotationController.DrawPoseLandmarkListLater(value);
131131
}
132132

133133
private void OnLeftHandLandmarksOutput(object stream, OutputStream<NormalizedLandmarkList>.OutputEventArgs eventArgs)
134134
{
135135
var packet = eventArgs.packet;
136-
var value = packet == null ? default : packet.GetProto(NormalizedLandmarkList.Parser);
136+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
137137
_holisticAnnotationController.DrawLeftHandLandmarkListLater(value);
138138
}
139139

140140
private void OnRightHandLandmarksOutput(object stream, OutputStream<NormalizedLandmarkList>.OutputEventArgs eventArgs)
141141
{
142142
var packet = eventArgs.packet;
143-
var value = packet == null ? default : packet.GetProto(NormalizedLandmarkList.Parser);
143+
var value = packet == null ? default : packet.Get(NormalizedLandmarkList.Parser);
144144
_holisticAnnotationController.DrawRightHandLandmarkListLater(value);
145145
}
146146

147147
private void OnPoseWorldLandmarksOutput(object stream, OutputStream<LandmarkList>.OutputEventArgs eventArgs)
148148
{
149149
var packet = eventArgs.packet;
150-
var value = packet == null ? default : packet.GetProto(LandmarkList.Parser);
150+
var value = packet == null ? default : packet.Get(LandmarkList.Parser);
151151
_poseWorldLandmarksAnnotationController.DrawLater(value);
152152
}
153153

154154
private void OnSegmentationMaskOutput(object stream, OutputStream<ImageFrame>.OutputEventArgs eventArgs)
155155
{
156156
var packet = eventArgs.packet;
157-
var value = packet == null ? default : packet.GetImageFrame();
157+
var value = packet == null ? default : packet.Get();
158158
_segmentationMaskAnnotationController.DrawLater(value);
159159
value?.Dispose();
160160
}
161161

162162
private void OnPoseRoiOutput(object stream, OutputStream<NormalizedRect>.OutputEventArgs eventArgs)
163163
{
164164
var packet = eventArgs.packet;
165-
var value = packet == null ? default : packet.GetProto(NormalizedRect.Parser);
165+
var value = packet == null ? default : packet.Get(NormalizedRect.Parser);
166166
_poseRoiAnnotationController.DrawLater(value);
167167
}
168168
}

0 commit comments

Comments
 (0)