40 #include <visp3/core/vpConfig.h>
42 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_THREADS)
44 #include <visp3/core/vpImageConvert.h>
75 pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, std::mutex *pointcloud_mutex,
79 int size =
static_cast<int>(depth_raw.
getSize());
80 unsigned int width = depth_raw.
getWidth();
81 unsigned int height = depth_raw.
getHeight();
83 const unsigned int index_0 = 0;
84 const unsigned int index_1 = 1;
85 const unsigned int index_2 = 2;
91 if (pointcloud_mutex) {
92 pointcloud_mutex->lock();
97 #pragma omp parallel for
99 for (
int p = 0; p < size; ++p) {
100 if (depth_mask->
bitmap[p]) {
101 if (
static_cast<int>(depth_raw.
bitmap[p])) {
102 float Z =
static_cast<float>(depth_raw.
bitmap[p]) * depth_scale;
106 unsigned int j = p % width;
107 unsigned int i = (p - j) / width;
110 if (point_3D[index_2] > Z_min) {
112 std::lock_guard<std::mutex> lock(mutex);
114 pointcloud->push_back(pcl::PointXYZ(point_3D[index_0], point_3D[index_1], point_3D[index_2]));
120 pcl_size = pointcloud->size();
121 if (pointcloud_mutex) {
122 pointcloud_mutex->unlock();
126 if (pointcloud_mutex) {
127 pointcloud_mutex->lock();
132 #pragma omp parallel for
134 for (
int p = 0; p < size; ++p) {
135 if (
static_cast<int>(depth_raw.
bitmap[p])) {
136 float Z =
static_cast<float>(depth_raw.
bitmap[p]) * depth_scale;
140 unsigned int j = p % width;
141 unsigned int i = (p - j) / width;
144 if (point_3D[index_2] >= 0.1) {
146 std::lock_guard<std::mutex> lock(mutex);
148 pointcloud->push_back(pcl::PointXYZ(point_3D[index_0], point_3D[index_1], point_3D[index_2]));
153 pcl_size = pointcloud->size();
154 if (pointcloud_mutex) {
155 pointcloud_mutex->unlock();
187 pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointcloud, std::mutex *pointcloud_mutex,
190 int size =
static_cast<int>(depth_raw.
getSize());
191 unsigned int width = depth_raw.
getWidth();
192 unsigned int height = depth_raw.
getHeight();
194 const unsigned int index_0 = 0;
195 const unsigned int index_1 = 1;
196 const unsigned int index_2 = 2;
202 if (pointcloud_mutex) {
203 pointcloud_mutex->lock();
208 #pragma omp parallel for
210 for (
int p = 0; p < size; ++p) {
211 if (depth_mask->
bitmap[p]) {
212 if (
static_cast<int>(depth_raw.
bitmap[p])) {
213 float Z =
static_cast<float>(depth_raw.
bitmap[p]) * depth_scale;
217 unsigned int j = p % width;
218 unsigned int i = (p - j) / width;
221 if (point_3D[index_2] > Z_min) {
223 std::lock_guard<std::mutex> lock(mutex);
225 #if PCL_VERSION_COMPARE(>=,1,14,1)
226 pointcloud->push_back(pcl::PointXYZRGB(point_3D[index_0], point_3D[index_1], point_3D[index_2],
230 pt.x = point_3D[index_0];
231 pt.y = point_3D[index_1];
232 pt.z = point_3D[index_2];
233 pointcloud->push_back(pcl::PointXYZRGB(pt));
240 pcl_size = pointcloud->size();
241 if (pointcloud_mutex) {
242 pointcloud_mutex->unlock();
246 if (pointcloud_mutex) {
247 pointcloud_mutex->lock();
252 #pragma omp parallel for
254 for (
int p = 0; p < size; ++p) {
255 if (
static_cast<int>(depth_raw.
bitmap[p])) {
256 float Z =
static_cast<float>(depth_raw.
bitmap[p]) * depth_scale;
260 unsigned int j = p % width;
261 unsigned int i = (p - j) / width;
264 if (point_3D[index_2] >= 0.1) {
266 std::lock_guard<std::mutex> lock(mutex);
268 #if PCL_VERSION_COMPARE(>=,1,14,1)
269 pointcloud->push_back(pcl::PointXYZRGB(point_3D[index_0], point_3D[index_1], point_3D[index_2],
273 pt.x = point_3D[index_0];
274 pt.y = point_3D[index_1];
275 pt.z = point_3D[index_2];
276 pointcloud->push_back(pcl::PointXYZRGB(pt));
282 pcl_size = pointcloud->size();
283 if (pointcloud_mutex) {
284 pointcloud_mutex->unlock();
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
static int depthToPointCloud(const vpImage< uint16_t > &depth_raw, float depth_scale, const vpCameraParameters &cam_depth, pcl::PointCloud< pcl::PointXYZ >::Ptr pointcloud, std::mutex *pointcloud_mutex=nullptr, const vpImage< unsigned char > *mask=nullptr, float Z_min=0.2, float Z_max=2.5)
Error that can be emitted by the vpImage class and its derivatives.
@ notInitializedError
Image not initialized.
Definition of the vpImage class member functions.
unsigned int getWidth() const
unsigned int getSize() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.