Hi, I am working with the cv2 reprojectImageTo3D to produce point cloud from disparity map. I started with the basic use of “StereoBM_create” to create the disparity map. This is the disparity map.
There are some disocclusions in the image but the final point cloud genereated looks good.
Now in order to remove the disocclusions in the disparity map I tried to post-filter the disparity using cv.createDisparityWLSFilter. The disparity map now looks much smoother.
post-filtered disparity map
But now the point cloud generated become a cone and is very different from the reality.
Sorry since I am a new user I cant insert more than 2 images here, there are some related imgs in the github repo I posted.
Here is the code I used to convert disparity map to point cloud.
# read from calib.txt
f = 3979.911
Cx, Cy = 1244.772, 1019.507
Tx = 193.001
C_x = 1369.115
Q = np.array([[1, 0, 0, -Cx],
[0, 1, 0, -Cy],
[0, 0, 0, f],
[0, 0, -1/Tx, (Cx-C_x)/Tx]])
image3d = cv2.reprojectImageTo3D(disparity=disparity, Q=Q)
imgL = cv2.imread(imgL_path)
cls = cv2.cvtColor(imgL, cv2.COLOR_BGR2RGB)
mask = disparity > disparity.min()
output_pts = image3d[mask]
output_cls = cls[mask]
create_output(output_pts, output_cls)
return image3d