fix(tracker): copy MediaPipe segmentation mask (fixes Windows use-after-free crash)
This commit is contained in:
1 parent
b4397e6151
commit
dafd249165
1 file changed
+4
-1
+4
-1
@@ -165,7 +165,10 @@ class MediaPipePoseProvider(PoseProvider):
|
|||||||
|
|
||||||
mask = None
|
mask = None
|
||||||
if result.segmentation_masks:
|
if result.segmentation_masks:
|
||||||
mask = np.ascontiguousarray(result.segmentation_masks[0].numpy_view(), dtype=np.float32)
|
# numpy_view() aliases MediaPipe-owned memory that is freed on the
|
||||||
|
# next detect/result release; copy it so the publisher never reads a
|
||||||
|
# freed buffer (a hard access-violation crash on Windows).
|
||||||
|
mask = np.array(result.segmentation_masks[0].numpy_view(), dtype=np.float32, copy=True)
|
||||||
if mask.ndim == 3 and mask.shape[-1] == 1:
|
if mask.ndim == 3 and mask.shape[-1] == 1:
|
||||||
mask = mask[..., 0]
|
mask = mask[..., 0]
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user