20 #define STB_IMAGE_WRITE_IMPLEMENTATION 25 for (
int i = 0; i < width *
height; ++i)
27 if (
auto d = depth_image[i])
29 uint8_t
v = d * 255 / std::numeric_limits<uint16_t>::max();
30 rgb_image[i*3 + 0] = 255 -
v;
31 rgb_image[i*3 + 1] = 255 -
v;
32 rgb_image[i*3 + 2] = 255 -
v;
36 rgb_image[i*3 + 0] = 0;
37 rgb_image[i*3 + 1] = 0;
38 rgb_image[i*3 + 2] = 0;
69 printf(
"There are %d connected RealSense devices.\n", ctx.
get_device_count());
73 printf(
"\nUsing device 0, an %s\n", dev->
get_name());
74 printf(
" Serial number: %s\n", dev->
get_serial());
77 std::vector<stream_record> supported_streams;
111 for (
auto & captured : supported_streams)
113 std::stringstream ss;
114 ss <<
"cpp-headless-output-" << captured.stream <<
".png";
116 std::cout <<
"Writing " << ss.str().data() <<
", " << captured.intrinsics.width <<
" x " << captured.intrinsics.height <<
" pixels" << std::endl;
119 captured.intrinsics.width,captured.intrinsics.height,
125 printf(
"wrote frames to current working directory.\n");
133 catch(
const std::exception & e)
135 std::cerr << e.what() << std::endl;
void log_to_console(log_severity min_severity)
Provides convenience methods relating to devices.
intrinsics get_stream_intrinsics(stream stream) const
Retrieves intrinsic camera parameters for specific stream.
void enable_stream(stream stream, int width, int height, format format, int framerate, output_buffer_format output_buffer_type=output_buffer_format::continous)
Enables specific stream and requests specific properties.
unsigned char * frame_data
const std::string & get_failed_args() const
GLint GLint GLsizei GLsizei height
const char * get_firmware_version() const
Retrieves version of firmware currently installed on device.
GLint GLint GLsizei GLsizei GLsizei depth
Exposes librealsense functionality for C++ compilers.
std::map< rs::stream, int > components_map
void normalize_depth_to_rgb(uint8_t rgb_image[], const uint16_t depth_image[], int width, int height)
const void * get_frame_data(stream stream) const
Retrieves contents of latest frame on a stream.
stream
Streams are different types of data provided by RealSense devices.
const char * get_name() const
Retrieves human-readable device model string.
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void start(rs::source source=rs::source::video)
Begins streaming on all enabled streams for this device.
GLsizei const GLfloat * value
const char * get_serial() const
Retrieves unique serial number of device.
rs::intrinsics intrinsics
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
stream_record(rs::stream value)
GLint GLint GLsizei width
bool supports(capabilities capability) const
Determines device capabilities.
device * get_device(int index)
const std::string & get_failed_function() const
capabilities
Specifies various capabilities of a RealSense device.
void wait_for_frames()
Blocks until new frames are available.
int get_device_count() const