def METHOD_NAME(
    name: str,
    confidence: Optional[float] = None,
    center: Optional[np.ndarray] = None,
    contour: Optional[np.ndarray] = None,
    rect: Optional[np.ndarray] = None,
    attributes: str = "",
):
    """
    Helper function to create a ``mil_msgs/ObjectInImage`` message.
    Only one of center, contour, or rect should be set, depending on what information
    is needed/available in your application.
    Args:
        name (str): Name of the identifed object.
        attributes (str): Attributes to attach to message, the purpose and value
            of this attribute will vary by application. Defaults to an empty string.
        confidence (Optional[float]): Float between 0 and 1 describing the confidence
            that name is correct for this object. Leave as ``None`` if confidence
            is not known (will be set to -1).
        center (Optional[np.ndarray]): ``[x, y]`` of the center point of the object.
        contour (Optional[np.ndarray]): Nx1x2 or Nx2 numpy array of pixels making up the contour
            around the object.
        rect (Optional[np.ndarray]): A 4 wide tuple/array-like representing the
            bounding box around the object as ``(X, Y, width, height)``,
            which is the representation returned by cv2.boundingRect.
    Returns:
        ObjectInImage: Message object filled as described above.
    """
    # Create message
    msg = ObjectInImage()
    # Fill name and attributes from argument
    msg.name = name
    msg.attributes = attributes
    # Fill confidence from argument if given, otherwise use -1
    if confidence is None:
        msg.confidence = -1.0
    else:
        msg.confidence = confidence
    # Fill points with contour, rect, or center depending on which is set
    if contour is not None:
        # Reshape to Nx2 in case input was given in cv's native Nx1x2 shape
        if len(contour.shape) == 3:
            contour = contour.reshape((contour.shape[0], contour.shape[2]))
        for point in contour:
            msg.points.append(numpy_to_point2d(point))
    elif rect is not None:
        # Add rectangle as upper left and bottom right points
        ul = np.array(rect[0:2])
        br = ul + np.array(rect[2:])
        msg.points.append(numpy_to_point2d(ul))
        msg.points.append(numpy_to_point2d(br))
    elif center is not None:
        # Add center tuple as single point
        msg.points.append(numpy_to_point2d(center))
    return msg