Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpPclViewer.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 * Description:
30 * Real-time 3D point clouds plotter based on the PCL library.
31 */
32
33#ifndef VP_PCL_VIEWER_H
34#define VP_PCL_VIEWER_H
35
36#include <visp3/core/vpConfig.h>
37
38#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_VISUALIZATION) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS)
39// System
40#include <thread>
41#include <mutex>
42
43// ViSP
44#include <visp3/core/vpColVector.h>
45
46// PCL
47#include <pcl/visualization/pcl_visualizer.h>
48
66class VISP_EXPORT VP_DEPRECATED vpPclViewer
67{
68public:
72 typedef struct legendParams
73 {
74 std::string m_text;
75 unsigned int m_posU;
76 unsigned int m_posV;
77 unsigned int m_size;
78 double m_rRatio;
79 double m_gRatio;
80 double m_bRatio;
81 }legendParams;
82
94 vpPclViewer(const std::string &title, const int &width = 640, const int &height = 480, const int &posU = 720, const int &posV = 560, const std::string &outFolder = std::string(), const double &ignoreThreshold = 0.95);
96
102 void setNameWindow(const std::string &nameWindow);
103
109 void setOutFolder(const std::string &outputFolder);
110
116 void setIgnoreThreshold(const double &thresh);
117
126 unsigned int addSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const std::string &name = "",
127 const std::vector<unsigned char> &v_color = std::vector<unsigned char>());
128
139 unsigned int addSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const vpColVector &weights,
140 const std::string &name = "",
141 const std::vector<unsigned char> &v_color = std::vector<unsigned char>());
142
150 void updateSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id,
151 const bool &hasToKeepColor = false);
152
161 void updateSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id,
162 const vpColVector &weights, const bool &hasToKeepColor = false);
163
169 void display(const bool &blocking = false);
170
175
180
181protected:
189 void threadUpdateSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id);
190
198 void threadUpdateSurfaceOriginalColor(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id);
199
208 void threadUpdateSurface(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id,
209 const vpColVector &weights);
210
219 void threadUpdateSurfaceOriginalColor(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &surface, const unsigned int &id,
220 const vpColVector &weights);
221
222
229 static void runThread(vpPclViewer *p_viewer);
230
236
237 std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> m_vPointClouds;
238 std::vector<std::vector<double>> m_vhandler;
239 pcl::visualization::PCLVisualizer::Ptr mp_viewer;
242 int m_posU;
243 int m_posV;
245 std::vector<std::string> m_vmeshid;
246 std::vector<legendParams> m_vlegends;
247 std::vector<std::mutex *> m_vpmutex;
248 std::vector<vpColVector> m_vweights;
249 std::thread m_threadDisplay;
251 std::string m_title;
253 std::string m_outFolder;
254};
255END_VISP_NAMESPACE
256#endif // #if defined(VISP_HAVE_PCL)
257#endif // _vpPclVisualizer_h_
Implementation of column vector and the associated operations.
static void runThread(vpPclViewer *p_viewer)
Internal method that is called by vpPclViewer::launchThread to launch the drawing thread.
std::string m_title
double m_ignoreThresh
void threadUpdateSurfaceOriginalColor(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights)
Method to update a point cloud known by the viewer when the drawing thread is running....
void display(const bool &blocking=false)
Blocking-mode display of the viewer.
void loopThread()
The internal loop of the non-blocking drawing thread.
void updateSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const bool &hasToKeepColor=false)
Update the surface known by id by the viewer.
vpPclViewer(const std::string &title, const int &width=640, const int &height=480, const int &posU=720, const int &posV=560, const std::string &outFolder=std::string(), const double &ignoreThreshold=0.95)
Construct a new vpPclViewer object.
void updateSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights, const bool &hasToKeepColor=false)
Update the surface known by id by the viewer.
std::thread m_threadDisplay
void setOutFolder(const std::string &outputFolder)
Set the path to the output folder. If different from the empty string, the point clouds will be saved...
std::vector< std::mutex * > m_vpmutex
std::vector< std::string > m_vmeshid
std::vector< vpColVector > m_vweights
void threadUpdateSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights)
Method to update a point cloud known by the viewer when the drawing thread is running....
void launchThread()
Start the drawing thread that permits to have a non-blocking display.
void setNameWindow(const std::string &nameWindow)
Set the name of the PCL viewer window.
bool m_hasToSavePCDs
void threadUpdateSurfaceOriginalColor(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id)
Method to update a point cloud known by the viewer when the drawing thread is running....
void threadUpdateSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id)
Method to update a point cloud known by the viewer when the drawing thread is running....
std::vector< std::vector< double > > m_vhandler
std::string m_outFolder
unsigned int addSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const std::string &name="", const std::vector< unsigned char > &v_color=std::vector< unsigned char >())
Add a surface to the list of point clouds known by the viewer.
unsigned int addSurface(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const vpColVector &weights, const std::string &name="", const std::vector< unsigned char > &v_color=std::vector< unsigned char >())
Add a surface to the list of point clouds known by the viewer. The points whose weights are below the...
std::vector< pcl::PointCloud< pcl::PointXYZRGB >::Ptr > m_vPointClouds
std::vector< legendParams > m_vlegends
void stopThread()
Stop the drawing thread that permits to have a non-blocking display.
pcl::visualization::PCLVisualizer::Ptr mp_viewer
void setIgnoreThreshold(const double &thresh)
Set the threshold below which a point must be displayed in black.
Structure that contains all the required parameters to display a legend on the viewer.
Definition vpPclViewer.h:73