Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-149

Box Encode Offsets

Problem

Encode a ground-truth box relative to an anchor for object detection.

Both boxes are [cx, cy, w, h]. Return [(gcx - acx) / aw, (gcy - acy) / ah, log(gw / aw), log(gh / ah)] with each value rounded to 4 decimal places.

Test cases

case 1
in: [[0,0,10,10],[0,0,10,10]]
expected: [0,0,0,0]
case 2
in: [[5,5,10,10],[7,4,20,5]]
expected: [0.2,-0.1,0.6931,-0.6931]
case 3
in: [[1,1,2,4],[2,3,4,2]]
expected: [0.5,0.5,0.6931,-0.6931]
Starter codePython
def encode_box(anchor, gt):
    # Your code here
    pass

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