from typing import Dict


def rb2coco_bbox(
    rb_label: Dict,
    label_id: int,
    image_id: int,
    category_id: int,
    width: int,
    height: int,
) -> Dict:
    """Convert rb bbox to coco bbox."""
    assert rb_label["bbox2d"]

    xnorm = rb_label["bbox2d"]["xnorm"]
    ynorm = rb_label["bbox2d"]["ynorm"]
    wnorm = rb_label["bbox2d"]["wnorm"]
    hnorm = rb_label["bbox2d"]["hnorm"]
    return {
        "id": label_id,
        "image_id": image_id,
        "category_id": category_id,
        "bbox": [
            int(xnorm * width),
            int(ynorm * height),
            int(wnorm * width),
            int(hnorm * height),
        ],
        "iscrowd": 0,
        "area": int(wnorm * width) * int(hnorm * height),
        "segmentation": [],
    }