I want to create a Depth Map in order to obtain the 3D position of each pixels so that I can have 3D position of some selected Item on my picture. In order to see if my depth data is correct, I visualize it with MeshLab.
I use the stereo data of KITTI dataset so the images are rectified and the calibration for each camera is provided.
The process is the following:
Image left + image right --> Compute disparity using Stereo Semi Global Matching (SGBM) --> Compute the depth Map using cv::reprojectImageTo3D() with the Q initialized thanks to the parameters of the calibration and thanks to this function:
cv::stereoRectify(cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, imgSize, R, T, R1, R2, P1, P2, Q);
My problem is the following:
The road is okey but the sign board have some distortion. I don't understand and I tried to change the parameters but without success. I always have this distortion. It's annoying because I cannot compute a good 3D position of the sign board. I tried also with the classic block matching but It's the same and the results is not that good in comparison with the semi global one.
However my disparity looks like this (Which seems good to me) :
The parameters of the disparity computation is the following:
StereoSGBM sgbm;
sgbm.SADWindowSize = 3;
sgbm.numberOfDisparities = 128;
sgbm.preFilterCap = 10;
sgbm.minDisparity = 0;
sgbm.uniquenessRatio = 10.0;
sgbm.speckleWindowSize = 100;
sgbm.speckleRange = 32;
sgbm.disp12MaxDiff = 1;
sgbm.fullDP = 1;
sgbm.P1 = sgbm.SADWindowSize*sgbm.SADWindowSize*4;
sgbm.P2 = sgbm.SADWindowSize*sgbm.SADWindowSize*32;
sgbm(gray1, gray2, disp);
Do you have an idea why that's happened ? How I can solve that ? I would like to have a well planar surface of the sign board.