UniDepth icon indicating copy to clipboard operation
UniDepth copied to clipboard

Bug in setting known intrinsic parameters

Open PhilFM opened this issue 9 months ago • 3 comments

It seems that there is a bug that setting the intrinsics doesn't seem to affect the run. The relevant code fragment I use is

    intrinsics = np.zeros((3,3), dtype=np.float32)
    Fdx = (1.)/math.tan(0.5*args.fov_horiz_degrees*math.pi/180.0) # focal distance with range [-1,1] in x
    Fdpix = 0.5*Fdx*img.width
    np.put(intrinsics, 0, Fdpix)
    np.put(intrinsics, 4, Fdpix)
    np.put(intrinsics, 2, 0.5*img.width)
    np.put(intrinsics, 5, 0.5*img.height)
    np.put(intrinsics, 8, 1.)
    predictions = model.infer(rgb, torch.from_numpy(intrinsics))

No error is reported but whatever value I use for the fov_horiz_degrees parameter doesn't seem to affect the result. I've tried the V1 and V2 models. I've also tried the (1,3,3) shape for the intrinsics array, which is the shape returned by the prediction. No difference. Am I doing something wrong or is it a bug?

I check the output intrinsics from the prediction (predictions["intrinsics"] for V1 and predictions["K"] for V2). I expected that this would return the intrinsics passed in. However the intrinsics returned by the prediction appear to stay the same as passing no intrinsics. Also the depth maps look the same independent of the FOV.

Thanks for any help.

Phil

PhilFM avatar May 24 '24 15:05 PhilFM