42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && (defined(VISP_HAVE_PCL)) && defined(VISP_HAVE_PCL_VISUALIZATION)
46 #include <pcl/visualization/cloud_viewer.h>
47 #include <pcl/visualization/pcl_visualizer.h>
49 #include <visp3/core/vpImageConvert.h>
50 #include <visp3/gui/vpDisplayGDI.h>
51 #include <visp3/gui/vpDisplayX.h>
52 #include <visp3/sensor/vpOccipitalStructure.h>
56 #ifdef ENABLE_VISP_NAMESPACE
60 unsigned int display_scale = 1;
63 ST::CaptureSessionSettings settings;
64 settings.source = ST::CaptureSessionSourceId::StructureCore;
65 settings.structureCore.visibleEnabled =
true;
66 settings.applyExpensiveCorrection =
true;
74 #if defined(VISP_HAVE_X11)
75 vpDisplayX display_visible;
76 #elif defined(VISP_HAVE_GDI)
82 display_visible.setDownScalingFactor(display_scale);
83 display_visible.init(I_visible,
static_cast<int>(I_visible.getWidth() / display_scale) + 80, 10,
"Color image");
85 pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointcloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
87 sc.
acquire((
unsigned char *)I_visible.bitmap,
nullptr,
nullptr, pointcloud);
89 pcl::visualization::PCLVisualizer::Ptr viewer(
new pcl::visualization::PCLVisualizer(
"3D Viewer"));
90 pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(pointcloud);
92 viewer->setBackgroundColor(0, 0, 0);
93 viewer->initCameraParameters();
94 viewer->setCameraPosition(0, 0, -0.5, 0, -1, 0);
100 sc.
acquire((
unsigned char *)I_visible.bitmap,
nullptr,
nullptr, pointcloud);
108 static bool update =
false;
110 viewer->addPointCloud<pcl::PointXYZRGB>(pointcloud, rgb,
"sample cloud");
111 viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1,
"sample cloud");
115 viewer->updatePointCloud<pcl::PointXYZRGB>(pointcloud, rgb,
"sample cloud");
118 viewer->spinOnce(30);
124 std::cerr <<
"Structure SDK error " << e.
what() << std::endl;
126 catch (
const std::exception &e) {
127 std::cerr << e.what() << std::endl;
135 #if !defined( VISP_HAVE_OCCIPITAL_STRUCTURE )
136 std::cout <<
"You do not have Occipital Structure SDK functionality enabled..." << std::endl;
137 std::cout <<
"Tip:" << std::endl;
138 std::cout <<
"- Install libStructure, configure again ViSP using cmake and build again this example" << std::endl;
140 #elif ( VISP_CXX_STANDARD < VISP_CXX_STANDARD_11 )
141 std::cout <<
"You do not build ViSP with c++11 or higher compiler flag" << std::endl;
142 std::cout <<
"Tip:" << std::endl;
143 std::cout <<
"- Configure ViSP again using cmake -DUSE_CXX_STANDARD=11, and build again this example" << std::endl;
144 #elif !defined( VISP_HAVE_PCL )
145 std::cout <<
"You do not have PCL 3rd party installed." << std::endl;
146 #elif !defined( VISP_HAVE_PCL_VISUALIZATION )
147 std::cout <<
"You do not have PCL visualization module." << std::endl;
Display for windows using GDI (available on any windows 32 platform).
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
const char * what() const
unsigned int getHeight(vpOccipitalStructureStream stream_type)
vpCameraParameters getCameraParameters(const vpOccipitalStructureStream stream_type, vpCameraParameters::vpCameraParametersProjType type=vpCameraParameters::perspectiveProjWithoutDistortion)
void acquire(vpImage< unsigned char > &gray, bool undistorted=false, double *ts=nullptr)
unsigned int getWidth(vpOccipitalStructureStream stream_type)
bool open(const ST::CaptureSessionSettings &settings)
VISP_EXPORT double measureTimeMs()