stereolabs / zed-csharp-api

C# API for the ZED SDK
MIT License
10 stars 3 forks source link

Get detected objects distance #7

Closed LudoTexx closed 3 years ago

LudoTexx commented 4 years ago

Hello,

Please could you tell me what the best way to get the position of an dtected object please?

I have try with ObjectDataSDK with :

obj.rootWorldPosition.Z

but the returned value are really "unstable", and sometimes false (if too close).

I also tried that :

                            distMat = new ZEDMat();

                            distMat.Create(res, MAT_TYPE.MAT_8U_C4, MEM.MEM_GPU);

                            camAR.RetrieveMeasure(distMat, MEASURE.DEPTH, MEM.MEM_GPU);
                            float depthCenter;

                            distMat.GetValue(960, 540, out depthCenter, MEM.MEM_GPU);
                            distMat.Free(MEM.MEM_GPU);

The accuracy seem better, (here i get the distance of the center of my image), but i'm not sure about how get the real distance of my object in my zone area, because of this : (maybe write an algo for trying an average or something, but i prefere ask before loosing time for maybe nothing)

CameraVue

CameraDessus

Maybe all my try are totally false, but the value look good, the API doc do not match really with the C# API content.

Thank you in advance.

LudoTexx commented 4 years ago

Back from holidays.. no answer, bump please !

obraun-sl commented 4 years ago

Hi, The obj.rootWorldPosition already gives (X,Y,Z) position of the root body, based on median value of points inside the bounding box. If you want to do something similar using the depth map, best will be to use the median value to avoid averaging outliers values.

LudoTexx commented 4 years ago

Yea, i have use that, is just weird if the object is too close, that do not return NaN, or null, but return a random value.