# How to convert sl::Mat point cloud to pcl::PointCloud?

**URL:** <https://community.stereolabs.com/t/how-to-convert-sl-mat-point-cloud-to-pcl-pointcloud/1893>\
**Category:** C++\
**Tags:** depth, windows\
**Created:** [December 8, 2022, 1:57pm UTC](https://community.stereolabs.com/t/how-to-convert-sl-mat-point-cloud-to-pcl-pointcloud/1893 "2022-12-08T13:57:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![candy1](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/41988e/32.png) [@candy1](https://community.stereolabs.com/u/candy1)\
**Post date:** [December 8, 2022, 1:57pm UTC](https://community.stereolabs.com/t/how-to-convert-sl-mat-point-cloud-to-pcl-pointcloud/1893/1 "2022-12-08T13:57:02Z")

</div>

Hi, my friends. i got a problem that how to convert sl::Mat point cloud to pcl::PointCloud.

![image](https://community.stereolabs.com/uploads/default/original/1X/1a19b114aaa96b27699be83e030e22ff1ed3490e.png)

The method i used to convert it shows in picture. But it spend much times,and a lot of points in the sl::Mat  
is NAN, do you have a approach to convert it efficiently?  
Please help.Thanks!

---

<div class="post-metadata">

**Author:** ![alassagne](https://community.stereolabs.com/user_avatar/community.stereolabs.com/alassagne/32/2428_2.png) [@alassagne](https://community.stereolabs.com/u/alassagne)\
**Post date:** [December 8, 2022, 3:39pm UTC](https://community.stereolabs.com/t/how-to-convert-sl-mat-point-cloud-to-pcl-pointcloud/1893/2 "2022-12-08T15:39:09Z")

</div>

Hello,  
a very generic way to speed up for loops like that is to multithread them. You can basically add  
`#pragma omp parallel for`  
on top on your for loop for that.

> **[OpenMP on Ubuntu](https://medium.com/swlh/openmp-on-ubuntu-1145355eeb2)**
>
> OpenMP is a library for executing C, C++ and Fortran code on multiple processors at the same time. This makes your code much faster if it…

Antoine
