Hello,

We are trying to use the Oak-D S2 to make some highly accurate depth measurements. We are using the gen2-record-replay experiment to handle the recording since we need both color and depth at the same time. We also decided it would be best for our application to calculate depth from disparity on the host, thus we encode disparity. Encoding at 720P, we are using the following equation to calculate depth:

FOV = 71.86
Baseline = 75mm
Width = 1280

Focus = .5Width/tan(.5FOVpi/180)
depth = Focus
Baseline/disparity

We have an optical test stand setup pictured below:

We know the distance to be 433mm from the front glass of the camera to the front of the target. We even double checked it with a tape measure (seen below):

However, when we take the recording and process the disparity into depth we get around a 50mm error.

As you can see the calculated depth of the target is 490mm.

We have extended disparity set to true for close up viewing. We have tried encoding at 400P and get the same result. Are we doing something wrong in the calculation? Is the target too close to the camera?

At this stage we are not actually using the color image for anything.

Another question is: where is the reference point for the camera depth? Is it the front glass of the camera?

Thanks,

Will

  • erik replied to this.

    Hi Rondin119 ,
    What's the reason for calculating depth on the host? I think the culprit is with the depth calculations and parameters you have used (eg. for focal len in pixels, that's the 'ideal' calculation, not one received when calibrating - use device.readCalibration for that). Also when encoding, some data could be lost (if not encoded with lossless). So I would first use this example to check the accuracy, and then fine-tune your application to convert disparity->depth.
    Reference point for depth is right mono camera (by default), but you can change it (example here).
    Thoughts?
    Thansk ,Erik

    Hi Erik,

    Thanks so much for the reply! The issue was our focal length calculation, just as you predicted. When we got it from the camera using device.readCalibration and used that in the depth calculation it agreed with the spatial location calculator example within 1mm and with our physical measurement within 5mm (which is likely explained by us using the front glass of the OAK-D and not the lens of the mono camera as reference).

    We wanted to calculate depth on the host because we wanted to use the record_replay experiment but didn't want to have to handle rosbags. Perhaps not the best reason.

    Thanks Again

    Great that you got it working, and thanks for circlign back!🙂