```python:inference/enterprise/workflows/enterprise_blocks/sinks/event_writer/v1.py
import cv2
import logging
import numpy as np
from typing import Any, Dict, List


def _detections_to_v2_instance_segmentations(detections: Any) -> List[Dict[str, Any]]:
    """Convert Supervision Detections with masks to v2 instanceSegmentations format."""
    if detections is None:
        return []
    results = []
    try:
        xyxy = detections.xyxy
        confidence = detections.confidence
        class_names = detections.data.get("class_name", [])
        masks = detections.mask
        if masks is None:
            return results
        for i, (box, mask) in enumerate(zip(xyxy, masks)):
            if mask is None:
                continue
            mask = mask.astype(np.uint8)
            contours, _ = cv2.findContours(
                mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
            )
            if not contours:
                continue
            largest = max(contours, key=cv2.contourArea)
            pts = np.asarray(largest).reshape(-1, 2)
            if pts.shape[0] < 3:
                continue
            x1, y1, x2, y2 = box
            w = float(x2 - x1)
            h = float(y2 - y1)
            entry = {
                "class": class_names[i] if i < len(class_names) else "unknown",
                "x": float((x1 + x2) / 2),
                "y": float((y1 + y2) / 2),
                "width": w,
                "height": h,
                "confidence": float(confidence[i]) if confidence is not None else 0.0,
                "points": pts.astype(float).tolist(),
            }
            results.append(entry)
    except Exception as e:
        logging.warning(f"Failed to convert instance segmentations: {e}")
    return results
```