Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-131

XYXY to XYWH

Problem

Convert a box from [x1, y1, x2, y2] to [x, y, w, h] with w = x2 - x1 and h = y2 - y1. Round each value to 4 decimal places.

Test cases

case 1
in: [[1,2,4,6]]
expected: [1,2,3,4]
case 2
in: [[0,0,0,0]]
expected: [0,0,0,0]
case 3
in: [[2.5,3.5,3.5,5.5]]
expected: [2.5,3.5,1,2]
Starter codePython
def xyxy_to_xywh(box):
    # Your code here
    pass

3 test cases · run your code against them in the editor