Test Intel RealSense D435 acquisition with librealsense2.
#include <iostream>
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_REALSENSE2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && \
(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vpRealSense2.h>
int main(int argc, char *argv[])
{
bool show_info = false;
for (int i = 1; i < argc; i++) {
if (std::string(argv[i]) == "--show_info") {
show_info = true;
}
}
if (show_info) {
std::cout << "RealSense:\n" << rs << std::endl;
return EXIT_SUCCESS;
}
int width = 1280, height = 720, fps = 30;
rs2::config config;
config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
config.enable_stream(RS2_STREAM_INFRARED, 1, width, height, RS2_FORMAT_Y8, fps);
config.enable_stream(RS2_STREAM_INFRARED, 2, width, height, RS2_FORMAT_Y8, fps);
vpImage<vpRGBa> color(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
vpImage<vpRGBa> depth_color(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
vpImage<uint16_t> depth_raw(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
#ifdef VISP_HAVE_X11
#else
#endif
d1.
init(color, 0, 0,
"Color");
std::vector<vpColVector> pointcloud_colvector;
std::vector<double> time_vector;
reinterpret_cast<unsigned char *>(depth_raw.
bitmap),
&pointcloud_colvector,
reinterpret_cast<unsigned char *>(infrared1.
bitmap),
reinterpret_cast<unsigned char *>(infrared2.
bitmap),
NULL);
break;
}
}
width = 640;
height = 480;
fps = 60;
config.disable_all_streams();
config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
color.
init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
depth_color.
init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
depth_raw.
init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
infrared1.
init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
d1.
init(color, 0, 0,
"Color");
time_vector.clear();
reinterpret_cast<unsigned char *>(depth_raw.
bitmap),
NULL,
reinterpret_cast<unsigned char *>(infrared1.
bitmap));
break;
}
}
return EXIT_SUCCESS;
}
#else
int main()
{
#if !defined(VISP_HAVE_REALSENSE2)
std::cout << "Install librealsense2 to make this test work." << std::endl;
#endif
#if !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
std::cout << "Build ViSP with c++11 or higher compiler flag (cmake -DUSE_CXX_STANDARD=11) "
"to make this test work"
<< std::endl;
#endif
#if !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_GDI)
std::cout << "X11 or GDI are needed." << std::endl;
#endif
return 0;
}
#endif