All problems
Box Encode with Variance
Problem
Encode a ground-truth box relative to an anchor with variance scaling.
Boxes are [cx, cy, w, h]. Return [(gcx - acx) / (aw * v0), (gcy - acy) / (ah * v1), log(gw / aw) / v2, log(gh / ah) / v3] rounded to 4 decimal places.
Test cases
case 1
in: [[0,0,10,10],[5,5,20,20],[0.1,0.1,0.2,0.2]]
expected: [5,5,3.4657,3.4657]
case 2
in: [[5,5,10,10],[5,5,10,10],[0.1,0.1,0.2,0.2]]
expected: [0,0,0,0]
case 3
in: [[0,0,10,10],[5,5,20,20],[1,1,1,1]]
expected: [0.5,0.5,0.6931,0.6931]
Starter codePython
def encode_var(anchor, gt, variances):
# Your code here
pass3 test cases · run your code against them in the editor