# The point cloud from reprojectImageTo3D looks weired

**URL:** https://forum.opencv.org/t/the-point-cloud-from-reprojectimageto3d-looks-weired/11345
**Category:** Python
**Created:** [December 17, 2022, 5:52am UTC](https://forum.opencv.org/t/the-point-cloud-from-reprojectimageto3d-looks-weired/11345 "2022-12-17T05:52:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Chaozy\_Z](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/chaozy_z/32/5000_2.png) [@Chaozy\_Z](https://forum.opencv.org/u/Chaozy_Z)
#### Post date: [December 17, 2022, 5:52am UTC](https://forum.opencv.org/t/the-point-cloud-from-reprojectimageto3d-looks-weired/11345/1 "2022-12-17T05:52:30Z")

</div>

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.](https://github.com/chaozy/display_imgs/blob/main/disparity.png)  
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](https://github.com/chaozy/display_imgs/blob/main/filtered_disparity.png)  
But now the point cloud generated become a cone and is very different from the reality.

 ![Screenshot from 2022-12-17 05-37-24](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/8/8ab24a1add516e382e8625135a09bb996abb9fed.jpeg)

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.

```auto
    # 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

```
