Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
examples
pointcloud
rs-pointcloud.cpp
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2015-2017 Intel Corporation. All Rights Reserved.
3
4
#include <
librealsense2/rs.hpp
>
// Include RealSense Cross Platform API
5
#include "
example.hpp
"
// Include short list of convenience functions for rendering
6
7
#include <algorithm>
// std::min, std::max
8
9
// Helper functions
10
void
register_glfw_callbacks
(
window
& app,
glfw_state
& app_state);
11
12
int
main
(
int
argc,
char
* argv[])
try
13
{
14
// Create a simple OpenGL window for rendering:
15
window
app(1280, 720,
"RealSense Pointcloud Example"
);
16
// Construct an object to manage view state
17
glfw_state
app_state;
18
// register callbacks to allow manipulation of the pointcloud
19
register_glfw_callbacks
(app, app_state);
20
21
// Declare pointcloud object, for calculating pointclouds and texture mappings
22
rs2::pointcloud
pc
;
23
// We want the points object to be persistent so we can display the last cloud when a frame drops
24
rs2::points
points
;
25
26
// Declare RealSense pipeline, encapsulating the actual device and sensors
27
rs2::pipeline
pipe
;
28
// Start streaming with default recommended configuration
29
pipe.
start
();
30
31
while
(app)
// Application still alive?
32
{
33
// Wait for the next set of frames from the camera
34
auto
frames
= pipe.
wait_for_frames
();
35
36
auto
color
=
frames
.get_color_frame();
37
38
// For cameras that don't have RGB sensor, we'll map the pointcloud to infrared instead of color
39
if
(!
color
)
40
color
=
frames
.get_infrared_frame();
41
42
// Tell pointcloud object to map to this color frame
43
pc.
map_to
(
color
);
44
45
auto
depth
=
frames
.get_depth_frame();
46
47
// Generate the pointcloud and texture mappings
48
points = pc.
calculate
(
depth
);
49
50
// Upload the color frame to OpenGL
51
app_state.
tex
.
upload
(
color
);
52
53
// Draw the pointcloud
54
draw_pointcloud
(app.
width
(), app.
height
(), app_state,
points
);
55
}
56
57
return
EXIT_SUCCESS;
58
}
59
catch
(
const
rs2::error
&
e
)
60
{
61
std::cerr
<<
"RealSense error calling "
<< e.
get_failed_function
() <<
"("
<< e.
get_failed_args
() <<
"):\n "
<< e.what() << std::endl;
62
return
EXIT_FAILURE;
63
}
64
catch
(
const
std::exception & e)
65
{
66
std::cerr
<< e.what() << std::endl;
67
return
EXIT_FAILURE;
68
}
rs2::error
Definition:
rs_types.hpp:92
rs2::pipeline::wait_for_frames
frameset wait_for_frames(unsigned int timeout_ms=RS2_DEFAULT_TIMEOUT) const
Definition:
rs_pipeline.hpp:510
export_ply_example.pipe
pipe
Definition:
export_ply_example.py:18
glfw_state
Definition:
example.hpp:872
rs2::points
Definition:
rs_frame.hpp:735
color
GLuint color
Definition:
glad/glad/glad.h:3182
depth
GLint GLint GLsizei GLsizei GLsizei depth
Definition:
glad/glad/glad.h:2399
example.hpp
rs2::pointcloud::map_to
void map_to(frame mapped)
Definition:
rs_processing.hpp:452
rs.hpp
rmse.e
e
Definition:
rmse.py:177
rs2::error::get_failed_args
const std::string & get_failed_args() const
Definition:
rs_types.hpp:117
window::width
float width() const
Definition:
example.hpp:627
texture::upload
void upload(const rs2::video_frame &frame)
Definition:
example.hpp:406
rs2::pointcloud::calculate
points calculate(frame depth) const
Definition:
rs_processing.hpp:431
main
int main(int argc, char *argv[])
Definition:
rs-pointcloud.cpp:12
rs2::pointcloud
Definition:
rs_processing.hpp:412
window::height
float height() const
Definition:
example.hpp:628
rs2::pipeline
Definition:
rs_pipeline.hpp:362
draw_pointcloud
void draw_pointcloud(float width, float height, glfw_state &app_state, rs2::points &points)
Definition:
example.hpp:886
register_glfw_callbacks
void register_glfw_callbacks(window &app, glfw_state &app_state)
Definition:
example.hpp:1037
window
Definition:
example.hpp:498
export_ply_example.pc
pc
Definition:
export_ply_example.py:13
Catch::cerr
std::ostream & cerr()
rs2::pipeline::start
pipeline_profile start()
Definition:
rs_pipeline.hpp:392
glfw_state::tex
texture tex
Definition:
example.hpp:882
rs2::error::get_failed_function
const std::string & get_failed_function() const
Definition:
rs_types.hpp:112
points
GLdouble GLdouble GLint GLint const GLdouble * points
Definition:
glad/glad/glad.h:2109
align-depth2color.frames
frames
Definition:
align-depth2color.py:58
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:47:40