Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpPclViewer.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 * Description:
31 * Real-time 3D point clouds plotter based on the PCL library.
32 *
33*****************************************************************************/
34
35#ifndef _vpPclViewer_h_
36#define _vpPclViewer_h_
37
38#include <visp3/core/vpConfig.h>
39
40#if defined(VISP_HAVE_PCL) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
41// System
42#include <thread>
43#include <mutex>
44
45// ViSP
46#include <visp3/core/vpColVector.h>
47
48// PCL
49#include <pcl/visualization/pcl_visualizer.h>
50
67class VISP_EXPORT vpPclViewer
68{
69public:
70 typedef typename pcl::PointXYZRGB pclPointXYZRGB;
71 typedef typename pcl::PointCloud<pclPointXYZRGB> pclPointCloudPointXYZRGB;
72 typedef typename pclPointCloudPointXYZRGB::Ptr pclPointCloudPointXYZRGBPtr;
73
77 typedef struct legendParams
78 {
79 std::string m_text;
80 unsigned int m_posU;
81 unsigned int m_posV;
82 unsigned int m_size;
83 double m_rRatio;
84 double m_gRatio;
85 double m_bRatio;
86 }legendParams;
87
99 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);
101
107 void setNameWindow(const std::string &nameWindow);
108
114 void setOutFolder(const std::string &outputFolder);
115
121 void setIgnoreThreshold(const double &thresh);
122
131 unsigned int addSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const std::string &name = "", const std::vector<unsigned char> &v_color = std::vector<unsigned char>());
132
143 unsigned int addSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const vpColVector &weights, const std::string &name = "", const std::vector<unsigned char> &v_color = std::vector<unsigned char>());
144
152 void updateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const bool &hasToKeepColor = false);
153
162 void updateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const vpColVector &weights, const bool &hasToKeepColor = false);
163
167 void display();
168
175 void refresh(const int &timeout = 100, const bool &waitForDrawing = true);
176
181
186
187protected:
195 void threadUpdateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id);
196
204 void threadUpdateSurfaceOriginalColor(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id);
205
214 void threadUpdateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const vpColVector &weights);
215
224 void threadUpdateSurfaceOriginalColor(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const vpColVector &weights);
225
226
233 static void runThread(vpPclViewer *p_viewer);
234
240
241 std::vector<pclPointCloudPointXYZRGB::Ptr> m_vPointClouds;
242 static pcl::visualization::PCLVisualizer::Ptr sp_viewer;
243 static std::vector<std::vector<double>> s_vhandler;
244 static int s_width;
245 static int s_height;
246 static int s_posU;
247 static int s_posV;
248 static double s_ignoreThresh;
249 std::vector<std::string> m_vmeshid;
250 std::vector<legendParams> m_vlegends;
251 std::vector<std::mutex *> m_vpmutex;
252 std::vector<vpColVector> m_vweights;
253 std::thread m_threadDisplay;
255 std::string m_title;
257 std::string m_outFolder;
258};
259#endif // #if defined(VISP_HAVE_PCL)
260#endif // _vpPclVisualizer_h_
Implementation of column vector and the associated operations.
unsigned int addSurface(const pclPointCloudPointXYZRGB::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...
static void runThread(vpPclViewer *p_viewer)
Internal method that is called by vpPclViewer::launchThread to launch the drawing thread.
void updateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const vpColVector &weights, const bool &hasToKeepColor=false)
Update the surface known by id by the viewer.
std::string m_title
void display()
Blocking-mode display of the viewer.
static int s_posV
void threadUpdateSurfaceOriginalColor(const pclPointCloudPointXYZRGB::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....
static pcl::visualization::PCLVisualizer::Ptr sp_viewer
void loopThread()
The internal loop of the non-blocking drawing thread.
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.
static double s_ignoreThresh
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
pcl::PointXYZRGB pclPointXYZRGB
Definition vpPclViewer.h:70
void refresh(const int &timeout=100, const bool &waitForDrawing=true)
Refresh the display.
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.
static std::vector< std::vector< double > > s_vhandler
bool m_hasToSavePCDs
static int s_width
std::string m_outFolder
static int s_posU
void updateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id, const bool &hasToKeepColor=false)
Update the surface known by id by the viewer.
void threadUpdateSurface(const pclPointCloudPointXYZRGB::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....
unsigned int addSurface(const pclPointCloudPointXYZRGB::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.
std::vector< legendParams > m_vlegends
void threadUpdateSurfaceOriginalColor(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id)
Method to update a point cloud known by the viewer when the drawing thread is running....
static int s_height
pclPointCloudPointXYZRGB::Ptr pclPointCloudPointXYZRGBPtr
Definition vpPclViewer.h:72
pcl::PointCloud< pclPointXYZRGB > pclPointCloudPointXYZRGB
Definition vpPclViewer.h:71
void stopThread()
Stop the drawing thread that permits to have a non-blocking display.
void threadUpdateSurface(const pclPointCloudPointXYZRGB::Ptr &surface, const unsigned int &id)
Method to update a point cloud known by the viewer when the drawing thread is running....
std::vector< pclPointCloudPointXYZRGB::Ptr > m_vPointClouds
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:78