depthai-experiments icon indicating copy to clipboard operation
depthai-experiments copied to clipboard

Spatial Calculation, scaling problem

Open spoilerhead opened this issue 2 years ago • 3 comments

I'm trying some code to determine real world distance between two points using an oak-d.

I've tried using gen2-calc-spatials-on-host and the SpatialLocationCalculator in the oak-d pipeline, any both give me consistent, but wrong results.

While the Z axis is within the expected tolerances (I'm seeing +/- 1%), the x and y axes are consistently about 10% to high (e.g. a distance of 200mm real life is measured as ~220mm). This seems to be independent of object distance and position within the frame. Is this a known bug? Or is there a special kind of calibration I need to perform?

I tried it on 3 different OAK-D devices and the results are always the same.

spoilerhead avatar Apr 05 '22 13:04 spoilerhead

Try using a oak-d pro PoE as the ir matrix makes it more accurate

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: @.> Sent: April 5, 2022 9:54 AM To: @.> Cc: @.***> Subject: [luxonis/depthai-experiments] Spatial Calculation, scaling problem (Issue #337)

I'm trying some code to determine real world distance between two points using an oak-d.

I've tried using gen2-calc-spatials-on-host and the SpatialLocationCalculator in the oak-d pipeline, any both give me consistent, but wrong results.

While the Z axis is within the expected tolerances (I'm seeing +/- 1%), the x and y axes are consistently about 10% to high (e.g. a distance of 200mm real life is measured as ~220mm). This seems to be independent of object distance and position within the frame. Is this a known bug? Or is there a special kind of calibration I need to perform?

I tried it on 3 different OAK-D devices and the results are always the same.

— Reply to this email directly, view it on GitHubhttps://github.com/luxonis/depthai-experiments/issues/337, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGDTSPYQJVK7MFNTFLNDJF3VDRA2HANCNFSM5SS3BP5Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>

localsailor avatar Apr 05 '22 14:04 localsailor

I'm trying some code to determine real world distance between two points using an oak-d.

I've tried using gen2-calc-spatials-on-host and the SpatialLocationCalculator in the oak-d pipeline, any both give me consistent, but wrong results.

While the Z axis is within the expected tolerances (I'm seeing +/- 1%), the x and y axes are consistently about 10% to high (e.g. a distance of 200mm real life is measured as ~220mm). This seems to be independent of object distance and position within the frame. Is this a known bug? Or is there a special kind of calibration I need to perform?

I tried it on 3 different OAK-D devices and the results are always the same.

So we have some degrees of freedom which can help here. Some of which we recently mainlined as default. Can you share what version you are running now?

Mesh calibration is one, and then using FOV from intrinsics instead of design data is another. Both of which may help here. And actually either might be enough, specifically the FOV from intrinsics instead of design data.

Thoughts?

Thanks, Brandon

Luxonis-Brandon avatar Apr 06 '22 03:04 Luxonis-Brandon

So we have some degrees of freedom which can help here. Some of which we recently mainlined as default. Can you share what version you are running now?

I'm currently using: depthai 2.15.1.0.dev0+04addaccd6edfe40e58df7156f0c5acfa2d7a6ff

Mesh calibration is one, and then using FOV from intrinsics instead of design data is another. Both of which may help here. And actually either might be enough, specifically the FOV from intrinsics instead of design data.

This was actually the hint I've been missing. computing the FOV using:

        calibData = device.readCalibration()
        ci, w ,h = calibData.getDefaultIntrinsics(dai.CameraBoardSocket.LEFT)
        calculatedMonoFOV = 2*math.atan((w/2)/ci[0][0])

        ci, w ,h = calibData.getDefaultIntrinsics(dai.CameraBoardSocket.RGB)
        calculatedRGBFOV = 2*math.atan((w/2)/ci[0][0])

and then continuing the calculation like previously gives me results in the expected accuracy!

Thanks for pointing me in the right direction.

spoilerhead avatar Apr 06 '22 06:04 spoilerhead