def scale_bounding_boxes(bounding_boxes, orig_width, new_width):
    """
    Scale a list of bounding boxes to reflect a change in image size.

    Args:
        bounding_boxes: List of lists of [x1, y1, x2, y2], where
            (x1, y1) is the upper left corner of the box, x2 is the width
            of the box, and y2 is the height of the box.
        orig_width: Width of the images to which bounding_boxes apply
        new_width: Width of the target images to which the bounding boxes
            should be translated
    Returns:
        A new list of bounding boxes with the appropriate scaling factor
        applied.
    """
    scale_factor = new_width / orig_width
    ret = []
    # Use a for loop because OpenCV doesn't play well with generators
    for bbox in bounding_boxes:
        new_bbox = []
        for elem in bbox:
            new_elem = round(float(elem) * scale_factor)
            new_bbox.append(new_elem)
        ret.append(new_bbox)
    return ret