Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches

#include <vpPclViewer.h>

Classes

struct  legendParams

Public Types

typedef struct vpPclViewer::legendParams legendParams

Public Member Functions

 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)
 ~vpPclViewer ()
void setNameWindow (const std::string &nameWindow)
void setOutFolder (const std::string &outputFolder)
void setIgnoreThreshold (const double &thresh)
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 >())
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 >())
void updateSurface (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const bool &hasToKeepColor=false)
void updateSurface (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights, const bool &hasToKeepColor=false)
void display (const bool &blocking=false)
void launchThread ()
void stopThread ()

Protected Member Functions

void threadUpdateSurface (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id)
void threadUpdateSurfaceOriginalColor (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id)
void threadUpdateSurface (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights)
void threadUpdateSurfaceOriginalColor (const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &surface, const unsigned int &id, const vpColVector &weights)
void loopThread ()

Static Protected Member Functions

static void runThread (vpPclViewer *p_viewer)

Protected Attributes

std::vector< pcl::PointCloud< pcl::PointXYZRGB >::Ptr > m_vPointClouds
std::vector< std::vector< double > > m_vhandler
pcl::visualization::PCLVisualizer::Ptr mp_viewer
int m_width
int m_height
int m_posU
int m_posV
double m_ignoreThresh
std::vector< std::string > m_vmeshid
std::vector< legendParamsm_vlegends
std::vector< std::mutex * > m_vpmutex
std::vector< vpColVectorm_vweights
std::thread m_threadDisplay
bool m_hasToRun
std::string m_title
bool m_hasToSavePCDs
std::string m_outFolder

Detailed Description

This class enables real time plotting of 3D point clouds. It relies on the PCL library. To see how to install PCL library, please refer to the Point Cloud Library (PCL) section. You can either plot in a non-blocking threaded manner or in a blocking manner. The point clouds can be displayed using their original colors, or using uniform colors to match a legend. Additionally, it is possible to use confidence weights to hide points that are not trusted. These weights can result from a robust estimation using for instance the vpRobust class.

Warning
If you face some runtime errors with the following class, please refer to the Known issues section to see if it is a known problem.
See also
Tutorial: Threaded PCL viewer

Definition at line 66 of file vpPclViewer.h.

Member Typedef Documentation

◆ legendParams

typedef struct vpPclViewer::legendParams vpPclViewer::legendParams

Structure that contains all the required parameters to display a legend on the viewer.

Constructor & Destructor Documentation

◆ vpPclViewer()

vpPclViewer::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.

Parameters
titleThe title of the window of the viewer.
widthThe width of the window of the viewer.
heightThe height of the window of the viewer.
posUThe position on the horizontal axis of the screen of the window of the viewer.
posVThe position on the vertical axis of the screen of the window of the viewer.
outFolderIf different from the empty string, the point clouds will be saved in this folder.
ignoreThresholdA point for which the weight is below this threshold will be displayed in black.

Referenced by runThread().

◆ ~vpPclViewer()

vpPclViewer::~vpPclViewer ( )

Member Function Documentation

◆ addSurface() [1/2]

unsigned int vpPclViewer::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.

Parameters
surfaceThe surface that must be knwon to be displayed by the PCL viewer.
nameThe name of the surface that will be displayed in the legend. If empty, it will be automatically generated.
v_colorA vector containing the 3 RGB values.
Returns
unsigned int The ID by which is known the point cloud by the viewer.

◆ addSurface() [2/2]

unsigned int vpPclViewer::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 vpPclViewer::s_ignoreThresh wil be displayed in black.

Parameters
surfaceThe surface that must be knwon to be displayed by the PCL viewer.
weightsThe confidence weights of each points. Must be between 0 and 1.
nameThe name of the surface that will be displayed in the legend. If empty, it will be automatically generated.
v_colorA vector containing the 3 RGB values.
Returns
unsigned int The ID by which is known the point cloud by the viewer.

◆ display()

void vpPclViewer::display ( const bool & blocking = false)

Blocking-mode display of the viewer.

Parameters
blockingTrue if we must wait for the user to press 'Q' to leave the method, false otherwise.

◆ launchThread()

void vpPclViewer::launchThread ( )

Start the drawing thread that permits to have a non-blocking display.

◆ loopThread()

void vpPclViewer::loopThread ( )
protected

The internal loop of the non-blocking drawing thread.

◆ runThread()

void vpPclViewer::runThread ( vpPclViewer * p_viewer)
staticprotected

Internal method that is called by vpPclViewer::launchThread to launch the drawing thread.

Parameters
p_viewerThe pointer of the vpPclViewer object that will run the thread (is equal to this ).

References vpPclViewer().

◆ setIgnoreThreshold()

void vpPclViewer::setIgnoreThreshold ( const double & thresh)

Set the threshold below which a point must be displayed in black.

Parameters
threshThe threshold below which a point must be displayed in black.

◆ setNameWindow()

void vpPclViewer::setNameWindow ( const std::string & nameWindow)

Set the name of the PCL viewer window.

Parameters
nameWindowThe name of the PCL viewer window.

◆ setOutFolder()

void vpPclViewer::setOutFolder ( const std::string & outputFolder)

Set the path to the output folder. If different from the empty string, the point clouds will be saved in this folder.

Parameters
outputFolderThe path towards to the output folder, or empty if the point clouds must not be saved.

◆ stopThread()

void vpPclViewer::stopThread ( )

Stop the drawing thread that permits to have a non-blocking display.

◆ threadUpdateSurface() [1/2]

void vpPclViewer::threadUpdateSurface ( const pcl::PointCloud< pcl::PointXYZRGB >::Ptr & surface,
const unsigned int & id )
protected

Method to update a point cloud known by the viewer when the drawing thread is running. The updated surface will be drawn with the default color that was affected to it.

Parameters
surfaceThe updated surface.
idThe ID of the point cloud that must be updated.

◆ threadUpdateSurface() [2/2]

void vpPclViewer::threadUpdateSurface ( const pcl::PointCloud< pcl::PointXYZRGB >::Ptr & surface,
const unsigned int & id,
const vpColVector & weights )
protected

Method to update a point cloud known by the viewer when the drawing thread is running. The updated surface will be drawn with the default color that was affected to it.

Parameters
surfaceThe updated surface.
idThe ID of the point cloud that must be updated.
weightsThe confidence weights of each point. Must be between 0 and 1.

◆ threadUpdateSurfaceOriginalColor() [1/2]

void vpPclViewer::threadUpdateSurfaceOriginalColor ( const pcl::PointCloud< pcl::PointXYZRGB >::Ptr & surface,
const unsigned int & id )
protected

Method to update a point cloud known by the viewer when the drawing thread is running. The updated surface will be drawn with the color it contains.

Parameters
surfaceThe updated surface.
idThe ID of the point cloud that must be updated.

◆ threadUpdateSurfaceOriginalColor() [2/2]

void vpPclViewer::threadUpdateSurfaceOriginalColor ( const pcl::PointCloud< pcl::PointXYZRGB >::Ptr & surface,
const unsigned int & id,
const vpColVector & weights )
protected

Method to update a point cloud known by the viewer when the drawing thread is running. The updated surface will be drawn with the color it contains.

Parameters
surfaceThe updated surface.
idThe ID of the point cloud that must be updated.
weightsThe confidence weights of each point. Must be between 0 and 1.

◆ updateSurface() [1/2]

void vpPclViewer::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.

Parameters
surfaceThe updated surface.
idThe ID of the surface that must be updated.
hasToKeepColorIf true, will be displayed in its original color. Otherwise, will be displayed in its default color.

◆ updateSurface() [2/2]

void vpPclViewer::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.

Parameters
surfaceThe updated surface.
idThe ID of the surface that must be updated.
weightsThe confidence weights of each points.
hasToKeepColorIf true, will be displayed in its original color. Otherwise, will be displayed in its default color.

Member Data Documentation

◆ m_hasToRun

bool vpPclViewer::m_hasToRun
protected

If true, the drawing thread is running. Otherwise, it is stopped.

Definition at line 250 of file vpPclViewer.h.

◆ m_hasToSavePCDs

bool vpPclViewer::m_hasToSavePCDs
protected

If true, the point clouds will be saved at each iteration of the drawing thread.

Definition at line 252 of file vpPclViewer.h.

◆ m_height

int vpPclViewer::m_height
protected

The height of the window.

Definition at line 241 of file vpPclViewer.h.

◆ m_ignoreThresh

double vpPclViewer::m_ignoreThresh
protected

The minimum value of the confidence weight of a point to allow it to be displayed.

Definition at line 244 of file vpPclViewer.h.

◆ m_outFolder

std::string vpPclViewer::m_outFolder
protected

If non empty, the path to the folders where the point clouds will be saved.

Definition at line 253 of file vpPclViewer.h.

◆ m_posU

int vpPclViewer::m_posU
protected

The position along the horizontal axis of the screen of the window.

Definition at line 242 of file vpPclViewer.h.

◆ m_posV

int vpPclViewer::m_posV
protected

The position along the vertical axis of the screen of the window.

Definition at line 243 of file vpPclViewer.h.

◆ m_threadDisplay

std::thread vpPclViewer::m_threadDisplay
protected

The non-blocking drawing thread.

Definition at line 249 of file vpPclViewer.h.

◆ m_title

std::string vpPclViewer::m_title
protected

The title of the viewer window.

Definition at line 251 of file vpPclViewer.h.

◆ m_vhandler

std::vector<std::vector<double> > vpPclViewer::m_vhandler
protected

The list of color handlers.

Definition at line 238 of file vpPclViewer.h.

◆ m_vlegends

std::vector<legendParams> vpPclViewer::m_vlegends
protected

The list of the legend items.

Definition at line 246 of file vpPclViewer.h.

◆ m_vmeshid

std::vector<std::string> vpPclViewer::m_vmeshid
protected

The list of the point cloud names, for the legend.

Definition at line 245 of file vpPclViewer.h.

◆ m_vpmutex

std::vector<std::mutex *> vpPclViewer::m_vpmutex
protected

The list of mutexes protecting the point clouds from data race when using the drawing thread.

Definition at line 247 of file vpPclViewer.h.

◆ m_vPointClouds

std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> vpPclViewer::m_vPointClouds
protected

The list of point clouds known by the viewer.

Definition at line 237 of file vpPclViewer.h.

◆ m_vweights

std::vector<vpColVector> vpPclViewer::m_vweights
protected

The list of confidence weights of each point cloud.

Definition at line 248 of file vpPclViewer.h.

◆ m_width

int vpPclViewer::m_width
protected

The width of the window.

Definition at line 240 of file vpPclViewer.h.

◆ mp_viewer

pcl::visualization::PCLVisualizer::Ptr vpPclViewer::mp_viewer
protected

The PCL viewer permitting the display.

Definition at line 239 of file vpPclViewer.h.