adujardin / zed-save-depth

ZED SDK sample to save the depth map as a file
BSD 3-Clause "New" or "Revised" License
28 stars 14 forks source link

Wrong depth estimation #9

Open yahiafarghaly opened 7 years ago

yahiafarghaly commented 7 years ago

Hi, The ZED is working great for estimating the depth of pixels beyond roughly 50 cm as a minimum distance for getting the depth. But when i tried to get it for points less than 50 cm, i was expected to get TOO_CLOSE or non available depth,But instead i was getting wrong values and even large one.

Take this case: i'm working on features extraction and wanting to get the depth of every feature, so simply i get the depth by the following code float* ptr_image_num = (float*) ((int8_t*) __current_mDepth.data + _row * __current_mDepth.step); float dist = ptr_image_num[_col]; // where row,col are the feature location in pixel. as in "with OpenCV" example in ZED directory. The distance case was this picture img_20170306_184237

and that was the extracted features,the green points which are the ZED was able to get their depth while the red where are ZED was not able to get their depth. i was expecting that they are all red points not green with these massive values in their depth (they was measured with mm with confidence of 100) as showing the in the right terminal. wrongdepth

the distance was less than 50 cm. what was interesting that when i try the same distance of the jetson carton of ZED , i was getting depth of around 500mm to 600mm. not 1000m or more.

I understand that the ZED has a minimal distance it cannot calculate the distance efficiently , but how can i figure these higher values while an object is front of the camera and i thought it's far from camera because of these reading ? . can i get rid of these false reading by any mean?

a Sample from my code

`void ZEDCamera::get_dimensions(int _row, int _col, Pixel& pix) { float dist;

ifdef GET_DEPTH_FROM_DEPTH_MAT

float* ptr_image_num = (float*) ((int8_t*) __current_mDepth.data + _row * __current_mDepth.step);
dist = ptr_image_num[_col];

else //FROM XYZ MAT

dist = ((float*) ((uint8_t*) __current_mXYZmat.data + _row * __current_mXYZmat.step))[4 * _col + 2];

endif

if (!isValidMeasure(dist)) {
    pix._x = -1;
    pix._y = -1;
    pix._z = -1;
} else {
    pix._x = (((float*) ((uint8_t*) __current_mXYZmat.data + _row * __current_mXYZmat.step))[4 * _col]);
    pix._y = (((float*) ((uint8_t*) __current_mXYZmat.data + _row * __current_mXYZmat.step))[4 * _col + 1]);
    pix._z = dist;
}

}`

the parameters which were used are

new Camera(VGA);
__parameters.mode = MODE::PERFORMANCE;
__parameters.coordinate = COORDINATE_SYSTEM::IMAGE;
__parameters.verbose = true;
__parameters.unit = UNIT::MILLIMETER;

system: jetson tk1,tegra jetpack v2.3 ,zed sdk v1.0.0 (as 1.2 is not working probably with my code in jetson). Also i made a manual calibration for the ZED , and its values are near the default calibration file.

Any help is appearched as the requirement of my project is very critical. So to summarize my questions

  1. how can i get rid of this wired behavior?

If any other information is needed to have a more diagnostics,i will provide it.

obraun-sl commented 7 years ago

Hi,

Did you try to reduce the confidence threshold with setConfidenceThreshold(50) and get the depth map with that settings? If still some points are detected, it means that there is some matching found and we cannot detect that it is under the minimum distance.

Best, OB

yahiafarghaly commented 7 years ago

@sl-braun it worked for the indoor environment, i will test it outdoor soon. but the number of depth points has been decreased. what this confidence do ? is it related to the confidence matrix ?