Visual Servoing Platform  version 3.6.1 under development (2024-04-26)
vpRealSense Class Reference

#include <visp3/sensor/vpRealSense.h>

Classes

struct  vpRsStreamParams
 

Public Member Functions

 vpRealSense ()
 
virtual ~vpRealSense ()
 
void acquire (std::vector< vpColVector > &pointcloud)
 
void acquire (vpImage< unsigned char > &grey)
 
void acquire (vpImage< unsigned char > &grey, std::vector< vpColVector > &pointcloud)
 
void acquire (vpImage< unsigned char > &grey, vpImage< uint16_t > &infrared, vpImage< uint16_t > &depth, std::vector< vpColVector > &pointcloud)
 
void acquire (vpImage< vpRGBa > &color)
 
void acquire (vpImage< vpRGBa > &color, std::vector< vpColVector > &pointcloud)
 
void acquire (vpImage< vpRGBa > &color, vpImage< uint16_t > &infrared, vpImage< uint16_t > &depth, std::vector< vpColVector > &pointcloud)
 
void acquire (unsigned char *const data_image, unsigned char *const data_depth, std::vector< vpColVector > *const data_pointCloud, unsigned char *const data_infrared, unsigned char *const data_infrared2=nullptr, const rs::stream &stream_color=rs::stream::color, const rs::stream &stream_depth=rs::stream::depth, const rs::stream &stream_infrared=rs::stream::infrared, const rs::stream &stream_infrared2=rs::stream::infrared2)
 
void close ()
 
vpCameraParameters getCameraParameters (const rs::stream &stream, vpCameraParameters::vpCameraParametersProjType type=vpCameraParameters::perspectiveProjWithDistortion) const
 
rs::device * getHandler () const
 
rs::extrinsics getExtrinsics (const rs::stream &from, const rs::stream &to) const
 
rs::intrinsics getIntrinsics (const rs::stream &stream) const
 
float getInvalidDepthValue () const
 
int getNumDevices () const
 
std::string getSerialNumber () const
 
vpHomogeneousMatrix getTransformation (const rs::stream &from, const rs::stream &to) const
 
void open ()
 
void setDeviceBySerialNumber (const std::string &serial_no)
 
void setEnableStream (const rs::stream &stream, bool status)
 
void setInvalidDepthValue (float value)
 
void setStreamSettings (const rs::stream &stream, const rs::preset &preset)
 
void setStreamSettings (const rs::stream &stream, const vpRsStreamParams &params)
 

Protected Member Functions

void initStream ()
 

Protected Attributes

rs::context m_context
 
rs::device * m_device
 
int m_num_devices
 
std::string m_serial_no
 
std::map< rs::stream, rs::intrinsics > m_intrinsics
 
float m_max_Z
 
std::map< rs::stream, bool > m_enableStreams
 
std::map< rs::stream, bool > m_useStreamPresets
 
std::map< rs::stream, rs::preset > m_streamPresets
 
std::map< rs::stream, vpRsStreamParamsm_streamParams
 
float m_invalidDepthValue
 

Friends

VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpRealSense &rs)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const vpRealSense &rs)
 

Detailed Description

This class is a wrapper over the Intel librealsense library https://github.com/IntelRealSense/librealsense. It allows to capture data from the Intel RealSense cameras.

The usage of vpRealSense class is enabled when librealsense 3rd party is successfully installed. Installation instructions are provided following https://github.com/IntelRealSense/librealsense#installation-guide.

Moreover, if Point Cloud Library (PCL) 3rd party is installed we also propose interfaces to retrieve point cloud as pcl::PointCloud<pcl::PointXYZ> or pcl::PointCloud<pcl::PointXYZRGB> data structures.

Warning
Notice that the usage of this class requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 compiler option. Hereafter we give an example of a CMakeLists.txt file that allows to build sample-realsense.cpp that uses vpRealSense class.
project(sample)
cmake_minimum_required(VERSION 3.5)
find_package(VISP REQUIRED)
include_directories(${VISP_INCLUDE_DIRS})
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
add_executable(sample-realsense sample-realsense.cpp)
target_link_libraries(sample-realsense ${VISP_LIBRARIES})

To acquire images from the RealSense color camera and convert them into grey level images, a good starting is to use the following code that corresponds to the content of sample-realsense.cpp:

#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.open();
vpImage<unsigned char> I(rs.getIntrinsics(rs::stream::color).height, rs.getIntrinsics(rs::stream::color).width);
#ifdef VISP_HAVE_X11
vpDisplayX d(I);
#elif defined(VISP_HAVE_GDI)
#endif
while (1) {
rs.acquire(I);
if (vpDisplay::getClick(I, false))
break;
}
return 0;
}
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:128
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)
void acquire(std::vector< vpColVector > &pointcloud)
rs::intrinsics getIntrinsics(const rs::stream &stream) const

If you want to acquire color images, in the previous sample replace:

vpImage<unsigned char> I(rs.getIntrinsics(rs::stream::color).height, rs.getIntrinsics(rs::stream::color).width);

by

vpImage<vpRGBa> I(rs.getIntrinsics(rs::stream::color).height, rs.getIntrinsics(rs::stream::color).width);

If you are interested in the point cloud and if ViSP is build with PCL support, you can start from the following example where we use PCL library to visualize the point cloud:

#include <visp3/sensor/vpRealSense.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/visualization/pcl_visualizer.h>
int main()
{
rs.open();
std::cout << rs << std::endl;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointcloud(new pcl::PointCloud<pcl::PointXYZRGB>);
rs.acquire(pointcloud);
pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(pointcloud);
viewer->setBackgroundColor (0, 0, 0);
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
viewer->setCameraPosition(0,0,-0.5, 0,-1,0);
while (1) {
rs.acquire(pointcloud);
static bool update = false;
if (! update) {
viewer->addPointCloud<pcl::PointXYZRGB> (pointcloud, rgb, "sample cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
update = true;
}
else {
viewer->updatePointCloud<pcl::PointXYZRGB> (pointcloud, rgb, "sample cloud");
}
viewer->spinOnce (100);
}
return 0;
}

If you want to change the default stream parameters, you can use setEnableStream() to enable only the desired stream and setStreamSettings() to set the stream settings. The following code allows to capture the color stream in 1920x1080 also with the infrared stream:

#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vpRealSense.h>
int main() {
rs.setEnableStream(rs::stream::color, true);
rs.setEnableStream(rs::stream::depth, false);
rs.setEnableStream(rs::stream::infrared, true);
rs.setEnableStream(rs::stream::infrared2, false);
rs.setStreamSettings(rs::stream::color, vpRealSense::vpRsStreamParams(1920, 1080, rs::format::rgba8, 30));
rs.setStreamSettings(rs::stream::infrared, vpRealSense::vpRsStreamParams(640, 480, rs::format::y8, 30));
rs.open();
vpImage<vpRGBa> Ic(rs.getIntrinsics(rs::stream::color).height, rs.getIntrinsics(rs::stream::color).width);
vpImage<unsigned char> Ii(rs.getIntrinsics(rs::stream::infrared).height,
rs.getIntrinsics(rs::stream::infrared).width);
#ifdef VISP_HAVE_X11
vpDisplayX dc(Ic, 0, 0, "Color");
vpDisplayX di(Ii, 100, 100, "Infrared");
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI dc(Ic, 0, 0, "Color");
vpDisplayGDI di(Ii, 100, 100, "Infrared");
#endif
while (1) {
rs.acquire((unsigned char *) Ic.bitmap, nullptr, nullptr, Ii.bitmap);
if (vpDisplay::getClick(Ic, false) || vpDisplay::getClick(Ii, false))
break;
}
return 0;
}
void setStreamSettings(const rs::stream &stream, const rs::preset &preset)
void setEnableStream(const rs::stream &stream, bool status)

This example shows how to get depth stream aligned on color stream:

#include <visp3/core/vpImageConvert.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vpRealSense.h>
int main() {
rs.setEnableStream(rs::stream::color, true);
rs.setEnableStream(rs::stream::depth, true);
rs.setEnableStream(rs::stream::infrared, false);
rs.setEnableStream(rs::stream::infrared2, false);
rs.setStreamSettings(rs::stream::color, vpRealSense::vpRsStreamParams(640, 480, rs::format::rgba8, 30));
rs.setStreamSettings(rs::stream::depth, vpRealSense::vpRsStreamParams(640, 480, rs::format::z16, 30));
rs.open();
vpImage<vpRGBa> Ic(rs.getIntrinsics(rs::stream::color).height, rs.getIntrinsics(rs::stream::color).width);
vpImage<uint16_t> Id_raw(rs.getIntrinsics(rs::stream::depth).height, rs.getIntrinsics(rs::stream::depth).width);
vpImage<vpRGBa> Id(rs.getIntrinsics(rs::stream::depth).height, rs.getIntrinsics(rs::stream::depth).width);
#ifdef VISP_HAVE_X11
vpDisplayX dc(Ic, 0, 0, "Color");
vpDisplayX dd(Id, 100, 100, "Depth aligned to color");
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI dc(Ic, 0, 0, "Color");
vpDisplayGDI dd(Id, 100, 100, "Depth aligned to color");
#endif
while (1) {
rs.acquire((unsigned char *) Ic.bitmap, (unsigned char *) Id_raw.bitmap, nullptr, nullptr, nullptr,
rs::stream::color, rs::stream::depth_aligned_to_color);
if (vpDisplay::getClick(Ic, false) || vpDisplay::getClick(Id, false))
break;
}
return 0;
}
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)

This is how you get intrinsics for non native stream (the native stream has to be enabled!):

#include <visp3/sensor/vpRealSense.h>
int main() {
rs.setEnableStream(rs::stream::color, true);
rs.setEnableStream(rs::stream::depth, true);
rs.setEnableStream(rs::stream::infrared, false);
rs.setEnableStream(rs::stream::infrared2, false);
rs.setStreamSettings(rs::stream::color, vpRealSense::vpRsStreamParams(640, 480, rs::format::rgba8, 30));
rs.setStreamSettings(rs::stream::depth, vpRealSense::vpRsStreamParams(640, 480, rs::format::z16, 30));
rs.open();
rs::device * dev = rs.getHandler();
rs::intrinsics depth_aligned_intrinsic = dev->get_stream_intrinsics(rs::stream::depth_aligned_to_color);
std::cout << "Intrinsics [fx, fy, ppx, ppy]: " << depth_aligned_intrinsic.fx << " ; " << depth_aligned_intrinsic.fy
<< " ; " << depth_aligned_intrinsic.ppx << " ; " << depth_aligned_intrinsic.ppy << std::endl; return 0;
}
rs::device * getHandler() const
Get access to device handler.
Definition: vpRealSense.h:393

Useful information can be retrieved using getHandler():

#include <librealsense/rs.hpp>
#include <visp3/sensor/vpRealSense.h>
int main() {
rs.open();
rs::device *device = rs.getHandler();
std::cout << "Stream width: " << device->get_stream_width(rs::stream::color) << std::endl;
std::cout << "Stream height: " << device->get_stream_height(rs::stream::color) << std::endl;
std::cout << "Stream format: " << device->get_stream_format(rs::stream::color) << std::endl;
std::cout << "Stream framerate: " << device->get_stream_framerate(rs::stream::color) << std::endl;
std::cout << "API version: " << rs_get_api_version(nullptr) << std::endl;
std::cout << "Firmware: " << rs_get_device_firmware_version((const rs_device *) device, nullptr) << std::endl;
std::cout << "RealSense sensor characteristics: \n" << rs << std::endl;
return 0;
}

Camera parameters can be set in the following manner:

rs::device * dev = rs.getHandler();
dev->set_option(rs::option::r200_lr_auto_exposure_enabled, 1); //enable lr auto exposure for the R200
Note
This class has been tested with the Intel RealSense SR300 (Firmware: 3.15.0.0) and R200 (Firmware: 1.0.71.06) using librealsense (API version: 1.12.01). The following streams are enabled by default:
  • Color stream with preset: best quality
  • Depth stream with preset: best quality
  • Infrared stream with preset: best quality
  • Infrared2 if supported with preset: best quality
Examples
saveRealSenseData.cpp, servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp, and tutorial-grabber-realsense.cpp.

Definition at line 331 of file vpRealSense.h.

Constructor & Destructor Documentation

◆ vpRealSense()

vpRealSense::vpRealSense ( )

Default constructor.

Definition at line 49 of file vpRealSense.cpp.

References initStream().

◆ ~vpRealSense()

vpRealSense::~vpRealSense ( )
virtual

Default destructor that stops the streaming.

See also
stop()

Definition at line 60 of file vpRealSense.cpp.

References close().

Member Function Documentation

◆ acquire() [1/8]

void vpRealSense::acquire ( std::vector< vpColVector > &  pointcloud)

Acquire data from RealSense device.

Parameters
pointcloud: Point cloud data as a vector of column vectors. Each column vector is 4-dimension and contains X,Y,Z,1 normalized coordinates of a point.
Examples
saveRealSenseData.cpp, servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp, and tutorial-grabber-realsense.cpp.

Definition at line 423 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ acquire() [2/8]

void vpRealSense::acquire ( unsigned char *const  data_image,
unsigned char *const  data_depth,
std::vector< vpColVector > *const  data_pointCloud,
unsigned char *const  data_infrared,
unsigned char *const  data_infrared2 = nullptr,
const rs::stream &  stream_color = rs::stream::color,
const rs::stream &  stream_depth = rs::stream::depth,
const rs::stream &  stream_infrared = rs::stream::infrared,
const rs::stream &  stream_infrared2 = rs::stream::infrared2 
)

Acquire data from RealSense device.

Parameters
data_image: Color image buffer or nullptr if not wanted.
data_depth: Depth image buffer or nullptr if not wanted.
data_pointCloud: Point cloud vector pointer or nullptr if not wanted.
data_infrared: Infrared image buffer or nullptr if not wanted.
data_infrared2: Infrared (for the second IR camera if available) image buffer or nullptr if not wanted.
stream_color: Type of color stream (e.g. rs::stream::color, rs::stream::rectified_color, rs::stream::color_aligned_to_depth).
stream_depth: Type of depth stream (e.g. rs::stream::depth, rs::stream::depth_aligned_to_color, rs::stream::depth_aligned_to_rectified_color, rs::stream::depth_aligned_to_infrared2).
stream_infrared: Type of infrared stream (only rs::stream::infrared should be possible).
stream_infrared2: Type of infrared2 stream (e.g. rs::stream::infrared2, rs::stream::infrared2_aligned_to_depth) if supported by the camera.

Definition at line 567 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ acquire() [3/8]

void vpRealSense::acquire ( vpImage< unsigned char > &  grey)

Acquire data from RealSense device.

Parameters
grey: Grey level image.

Definition at line 377 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, and open().

◆ acquire() [4/8]

void vpRealSense::acquire ( vpImage< unsigned char > &  grey,
std::vector< vpColVector > &  pointcloud 
)

Acquire data from RealSense device.

Parameters
grey: Grey level image.
pointcloud: Point cloud data as a vector of column vectors. Each column vector is 4-dimension and contains X,Y,Z,1 normalized coordinates of a point.

Definition at line 399 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ acquire() [5/8]

void vpRealSense::acquire ( vpImage< unsigned char > &  grey,
vpImage< uint16_t > &  infrared,
vpImage< uint16_t > &  depth,
std::vector< vpColVector > &  pointcloud 
)

Acquire data from RealSense device.

Parameters
grey: Grey level image.
infrared: Infrared image.
depth: Depth image.
pointcloud: Point cloud data as a vector of column vectors. Each column vector is 4-dimension and contains X,Y,Z,1 normalized coordinates of a point.

Definition at line 500 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ acquire() [6/8]

void vpRealSense::acquire ( vpImage< vpRGBa > &  color)

Acquire data from RealSense device.

Parameters
color: Color image.

Definition at line 442 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, and open().

◆ acquire() [7/8]

void vpRealSense::acquire ( vpImage< vpRGBa > &  color,
std::vector< vpColVector > &  pointcloud 
)

Acquire data from RealSense device.

Parameters
color: Color image.
pointcloud: Point cloud data as a vector of column vectors. Each column vector is 4-dimension and contains X,Y,Z,1 normalized coordinates of a point.

Definition at line 532 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ acquire() [8/8]

void vpRealSense::acquire ( vpImage< vpRGBa > &  color,
vpImage< uint16_t > &  infrared,
vpImage< uint16_t > &  depth,
std::vector< vpColVector > &  pointcloud 
)

Acquire data from RealSense device.

Parameters
color: Color image.
infrared: Infrared image.
depth: Depth image.
pointcloud: Point cloud data as a vector of column vectors. Each column vector is 4-dimension and contains X,Y,Z,1 normalized coordinates of a point.

Definition at line 466 of file vpRealSense.cpp.

References vpException::fatalError, m_device, m_intrinsics, m_invalidDepthValue, m_max_Z, and open().

◆ close()

void vpRealSense::close ( )

Stop device streaming.

Definition at line 242 of file vpRealSense.cpp.

References m_device.

Referenced by ~vpRealSense().

◆ getCameraParameters()

vpCameraParameters vpRealSense::getCameraParameters ( const rs::stream &  stream,
vpCameraParameters::vpCameraParametersProjType  type = vpCameraParameters::perspectiveProjWithDistortion 
) const

Return camera parameters corresponding to a specific stream. This function has to be called after open().

Parameters
stream: color, depth, infrared or infrared2 stream for which camera intrinsic parameters are returned.
type: Indicate if the model should include distortion paramater or not.
See also
getIntrinsics()
Examples
saveRealSenseData.cpp, servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp, and tutorial-grabber-realsense.cpp.

Definition at line 288 of file vpRealSense.cpp.

References getIntrinsics(), vpCameraParameters::initPersProjWithDistortion(), vpCameraParameters::initPersProjWithoutDistortion(), and vpCameraParameters::perspectiveProjWithDistortion.

◆ getExtrinsics()

rs::extrinsics vpRealSense::getExtrinsics ( const rs::stream &  from,
const rs::stream &  to 
) const

Get extrinsic transformation from one stream to an other. This function has to be called after open().

Parameters
from,to: color, depth, infrared or infrared2 stream between which camera extrinsic parameters are returned.
See also
getTransformation()

Definition at line 331 of file vpRealSense.cpp.

References vpException::fatalError, and m_device.

Referenced by getTransformation().

◆ getHandler()

rs::device* vpRealSense::getHandler ( ) const
inline

Get access to device handler.

Definition at line 393 of file vpRealSense.h.

◆ getIntrinsics()

rs::intrinsics vpRealSense::getIntrinsics ( const rs::stream &  stream) const

Get intrinsic parameters corresponding to the stream. This function has to be called after open().

Parameters
stream: color, depth, infrared or infrared2 stream for which camera intrinsic parameters are returned.
See also
getCameraParameters()

Definition at line 314 of file vpRealSense.cpp.

References vpException::fatalError, and m_device.

Referenced by getCameraParameters().

◆ getInvalidDepthValue()

float vpRealSense::getInvalidDepthValue ( ) const
inline

Get the value used when the pixel value (u, v) in the depth map is invalid for the point cloud. For instance, the Point Cloud Library (PCL) uses NAN values for points where the depth is invalid.

Definition at line 401 of file vpRealSense.h.

◆ getNumDevices()

int vpRealSense::getNumDevices ( ) const
inline

Get number of devices that are detected.

Definition at line 404 of file vpRealSense.h.

◆ getSerialNumber()

std::string vpRealSense::getSerialNumber ( ) const
inline

Get device serial number.

See also
setDeviceBySerialNumber()

Definition at line 407 of file vpRealSense.h.

◆ getTransformation()

vpHomogeneousMatrix vpRealSense::getTransformation ( const rs::stream &  from,
const rs::stream &  to 
) const

Get extrinsic transformation from one stream to an other. This function has to be called after open().

Parameters
from,to: color, depth, infrared or infrared2 stream between which camera extrinsic parameters are returned.
See also
getExtrinsics()
Examples
saveRealSenseData.cpp.

Definition at line 359 of file vpRealSense.cpp.

References getExtrinsics().

◆ initStream()

void vpRealSense::initStream ( )
protected

Definition at line 62 of file vpRealSense.cpp.

References m_enableStreams, m_streamParams, m_streamPresets, and m_useStreamPresets.

Referenced by vpRealSense().

◆ open()

void vpRealSense::open ( )

◆ setDeviceBySerialNumber()

void vpRealSense::setDeviceBySerialNumber ( const std::string &  serial_no)

Set active RealSence device using its serial number.

Parameters
serial_no: Device serial number.
#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.setDeviceBySerialNumber("541142003219");
rs.open();
}
void setDeviceBySerialNumber(const std::string &serial_no)

Definition at line 267 of file vpRealSense.cpp.

References vpException::fatalError, m_num_devices, and m_serial_no.

◆ setEnableStream()

void vpRealSense::setEnableStream ( const rs::stream &  stream,
bool  status 
)

Enable or disable a stream.

Parameters
stream: Stream type (color / depth / infrared).
status: Stream status.
#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.setEnableStream(rs::stream::color, true);
rs.setEnableStream(rs::stream::depth, false);
rs.setEnableStream(rs::stream::infrared, false);
rs.setStreamSettings(rs::stream::color, vpRealSense::vpRsStreamParams(1920, 1080, rs::format::rgba8, 30));
rs.open();
//[...]
}
Examples
servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp.

Definition at line 671 of file vpRealSense.cpp.

References m_enableStreams.

◆ setInvalidDepthValue()

void vpRealSense::setInvalidDepthValue ( float  value)
inline

Set the value used when the pixel value (u, v) in the depth map is invalid for the point cloud. For instance, the Point Cloud Library (PCL) uses NAN values for points where the depth is invalid.

Definition at line 439 of file vpRealSense.h.

◆ setStreamSettings() [1/2]

void vpRealSense::setStreamSettings ( const rs::stream &  stream,
const rs::preset &  preset 
)

Set stream settings.

Parameters
stream: Stream type (color / depth / infrared).
preset: Preset to use.
Examples
saveRealSenseData.cpp, servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp, and tutorial-grabber-realsense.cpp.

Definition at line 609 of file vpRealSense.cpp.

References m_streamPresets, and m_useStreamPresets.

◆ setStreamSettings() [2/2]

void vpRealSense::setStreamSettings ( const rs::stream &  stream,
const vpRsStreamParams params 
)

Set stream settings.

Parameters
stream: Stream type (color / depth / infrared).
params: Stream parameters to use.
Note
You can find the stream settings of the different Intel RealSense cameras at this url.
#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.setEnableStream(rs::stream::color, true);
rs.setEnableStream(rs::stream::depth, false);
rs.setEnableStream(rs::stream::infrared, false);
rs.setStreamSettings(rs::stream::color, vpRealSense::vpRsStreamParams(1920, 1080, rs::format::rgba8, 30));
rs.open();
//[...]
}

Definition at line 642 of file vpRealSense.cpp.

References m_streamParams, and m_useStreamPresets.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream &  os,
const vpRealSense rs 
)
friend

Return information from sensor.

Parameters
os: Input stream.
rs: RealSense interface.

The following example shows how to use this method.

#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.open();
std::cout << "RealSense sensor characteristics: \n" << rs << std::endl;
return 0;
}

Definition at line 1029 of file vpRealSense.cpp.

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
const vpRealSense rs 
)
related

Return information from sensor.

Parameters
os: Input stream.
rs: RealSense interface.

The following example shows how to use this method.

#include <visp3/sensor/vpRealSense.h>
int main()
{
rs.open();
std::cout << "RealSense sensor characteristics: \n" << rs << std::endl;
return 0;
}

Definition at line 1029 of file vpRealSense.cpp.

Member Data Documentation

◆ m_context

rs::context vpRealSense::m_context
protected

Definition at line 445 of file vpRealSense.h.

Referenced by open().

◆ m_device

rs::device* vpRealSense::m_device
protected

Definition at line 446 of file vpRealSense.h.

Referenced by acquire(), close(), getExtrinsics(), getIntrinsics(), and open().

◆ m_enableStreams

std::map<rs::stream, bool> vpRealSense::m_enableStreams
protected

Definition at line 451 of file vpRealSense.h.

Referenced by initStream(), open(), and setEnableStream().

◆ m_intrinsics

std::map<rs::stream, rs::intrinsics> vpRealSense::m_intrinsics
protected

Definition at line 449 of file vpRealSense.h.

Referenced by acquire(), and open().

◆ m_invalidDepthValue

float vpRealSense::m_invalidDepthValue
protected

Definition at line 455 of file vpRealSense.h.

Referenced by acquire().

◆ m_max_Z

float vpRealSense::m_max_Z
protected

Maximal Z depth in meter.

Definition at line 450 of file vpRealSense.h.

Referenced by acquire().

◆ m_num_devices

int vpRealSense::m_num_devices
protected

Definition at line 447 of file vpRealSense.h.

Referenced by open(), and setDeviceBySerialNumber().

◆ m_serial_no

std::string vpRealSense::m_serial_no
protected

Definition at line 448 of file vpRealSense.h.

Referenced by open(), and setDeviceBySerialNumber().

◆ m_streamParams

std::map<rs::stream, vpRsStreamParams> vpRealSense::m_streamParams
protected

Definition at line 454 of file vpRealSense.h.

Referenced by initStream(), open(), and setStreamSettings().

◆ m_streamPresets

std::map<rs::stream, rs::preset> vpRealSense::m_streamPresets
protected

Definition at line 453 of file vpRealSense.h.

Referenced by initStream(), open(), and setStreamSettings().

◆ m_useStreamPresets

std::map<rs::stream, bool> vpRealSense::m_useStreamPresets
protected

Definition at line 452 of file vpRealSense.h.

Referenced by initStream(), open(), and setStreamSettings().