20 #include <boost/date_time/posix_time/posix_time.hpp> 21 #include <boost/thread/thread.hpp> 28 #include <pcl/io/pcd_io.h> 29 #include <pcl/point_types.h> 30 #include <pcl/filters/passthrough.h> 31 #include <pcl/common/common_headers.h> 32 #include <pcl/features/normal_3d.h> 33 #include <pcl/visualization/pcl_visualizer.h> 34 #include <pcl/console/parse.h> 35 #include <boost/thread/thread.hpp> 36 #include <pcl/io/io.h> 37 #include <pcl/visualization/cloud_viewer.h> 73 int x_value =
min(max(
int(Texture_XY.
u * width + .5f), 0), width - 1);
74 int y_value =
min(max(
int(Texture_XY.
v * height + .5f), 0), height - 1);
78 int Text_Index = (bytes +
strides);
80 const auto New_Texture =
reinterpret_cast<const uint8_t*
>(texture.
get_data());
83 int NT1 = New_Texture[Text_Index];
84 int NT2 = New_Texture[Text_Index + 1];
85 int NT3 = New_Texture[Text_Index + 2];
87 return std::tuple<int, int, int>(NT1, NT2, NT3);
102 std::tuple<uint8_t, uint8_t, uint8_t> RGB_Color;
111 cloud->height =
static_cast<uint32_t>( sp.height() );
112 cloud->is_dense =
false;
113 cloud->points.resize( points.
size() );
120 for (
int i = 0;
i < points.
size();
i++)
134 cloud->points[
i].r = get<2>(RGB_Color);
135 cloud->points[
i].g = get<1>(RGB_Color);
136 cloud->points[
i].b = get<0>(RGB_Color);
149 bool captureLoop =
true;
154 pcl::PointCloud<pcl::PointXYZRGB>::Ptr newCloud (
new pcl::PointCloud<pcl::PointXYZRGB>);
197 while(captureLoop ==
true) {
201 if (captureLoop ==
false) {
break; }
205 for (
int i = 0;
i < 30;
i++) {
212 auto RGB =
frames.get_color_frame();
226 pcl::PassThrough<pcl::PointXYZRGB> Cloud_Filter;
227 Cloud_Filter.setInputCloud (cloud);
228 Cloud_Filter.setFilterFieldName (
"z");
229 Cloud_Filter.setFilterLimits (0.0, 1.0);
230 Cloud_Filter.filter (*newCloud);
238 cout <<
"Generating PCD Point Cloud File... " << endl;
239 pcl::io::savePCDFileASCII(
cloudFile, *cloud);
248 cout <<
"Exiting Program... " << endl;
256 catch (
const std::exception & e)
268 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudView (
new pcl::PointCloud<pcl::PointXYZRGB>);
270 openFileName =
"Captured_Frame" +
to_string(
i) +
".pcd";
271 pcl::io::loadPCDFile (openFileName, *cloudView);
280 viewer->setBackgroundColor (0, 0, 0);
282 viewer->addPointCloud<pcl::PointXYZRGB> (cloudView,
"Cloud");
284 viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1,
"Cloud");
286 viewer->initCameraParameters();
289 cout <<
"Press [Q] in viewer to continue. " << endl;
307 bool inputCheck =
false;
313 cout <<
"Generate a Point Cloud? [y/n] ";
317 if (takeFrame ==
'y' || takeFrame ==
'Y') {
323 else if (takeFrame ==
'n' || takeFrame ==
'N') {
331 cout <<
"Invalid Input." << endl;
334 }
while(inputCheck ==
false);
pcl::PointCloud< RGB_Cloud > point_cloud
frameset wait_for_frames(unsigned int timeout_ms=RS2_DEFAULT_TIMEOUT) const
std::tuple< int, int, int > RGB_Texture(rs2::video_frame texture, rs2::texture_coordinate Texture_XY)
stream_profile get_profile() const
int get_bytes_per_pixel() const
GLint GLint GLsizei GLsizei GLsizei depth
const void * get_data() const
void map_to(frame mapped)
const texture_coordinate * get_texture_coordinates() const
const std::string & get_failed_args() const
pcl::PointXYZRGB RGB_Cloud
GLsizei const GLuint const GLintptr const GLsizei * strides
points calculate(frame depth) const
GLint GLsizei GLsizei height
const vertex * get_vertices() const
cloud_pointer PCL_Conversion(const rs2::points &points, const rs2::video_frame &color)
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
device get_device() const
point_cloud::Ptr cloud_pointer
int get_stride_in_bytes() const
point_cloud::Ptr prevCloud
const std::string & get_failed_function() const
GLdouble GLdouble GLint GLint const GLdouble * points
std::string to_string(T value)