40#include <visp3/core/vpConfig.h>
42#if defined(VISP_HAVE_REALSENSE2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) \
43 && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
45#include <visp3/core/vpImage.h>
46#include <visp3/core/vpImageConvert.h>
47#include <visp3/gui/vpDisplayGDI.h>
48#include <visp3/gui/vpDisplayX.h>
49#include <visp3/sensor/vpRealSense2.h>
51int main(
int argc,
char *argv[])
53#ifdef ENABLE_VISP_NAMESPACE
56 bool show_info =
false;
58 for (
int i = 1;
i < argc;
i++) {
59 if (std::string(argv[i]) ==
"--show_info") {
67 std::cout <<
"RealSense:\n" << rs << std::endl;
74 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
75 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
76 config.enable_stream(RS2_STREAM_INFRARED, 1, width, height, RS2_FORMAT_Y8, fps);
77 config.enable_stream(RS2_STREAM_INFRARED, 2, width, height, RS2_FORMAT_Y8, fps);
81 vpImage<vpRGBa> depth_color(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
82 vpImage<uint16_t> depth_raw(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
91 d1.
init(color, 0, 0,
"Color");
92 d2.
init(depth_color,
color.getWidth(), 0,
"Depth");
93 d3.
init(infrared1, 0,
color.getHeight() + 100,
"Infrared left");
94 d4.
init(infrared2,
color.getWidth(),
color.getHeight() + 100,
"Infrared right");
96 std::vector<vpColVector> pointcloud_colvector;
98 std::vector<double> time_vector;
103 rs.
acquire(
reinterpret_cast<unsigned char *
>(
color.bitmap),
reinterpret_cast<unsigned char *
>(depth_raw.bitmap),
104 &pointcloud_colvector,
reinterpret_cast<unsigned char *
>(infrared1.bitmap),
105 reinterpret_cast<unsigned char *
>(infrared2.bitmap),
nullptr);
134 d2.
close(depth_color);
138 std::cout <<
"Acquisition1 - Mean time: " <<
vpMath::getMean(time_vector)
139 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
144 config.disable_all_streams();
145 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
146 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
147 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
150 color.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
151 depth_color.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
152 depth_raw.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
153 infrared1.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
155 d1.
init(color, 0, 0,
"Color");
156 d2.
init(depth_color,
color.getWidth(), 0,
"Depth");
157 d3.
init(infrared1, 0,
color.getHeight() + 100,
"Infrared");
164 rs.
acquire(
reinterpret_cast<unsigned char *
>(
color.bitmap),
reinterpret_cast<unsigned char *
>(depth_raw.bitmap),
165 nullptr,
reinterpret_cast<unsigned char *
>(infrared1.bitmap));
188 std::cout <<
"Acquisition2 - Mean time: " <<
vpMath::getMean(time_vector)
189 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
197#if !defined(VISP_HAVE_REALSENSE2)
198 std::cout <<
"Install librealsense2 to make this test work." << std::endl;
200#if !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_GDI)
201 std::cout <<
"X11 or GDI are needed." << std::endl;
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="") VP_OVERRIDE
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void close(vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
Definition of the vpImage class member functions.
static double getMedian(const std::vector< double > &v)
static double getMean(const std::vector< double > &v)
void acquire(vpImage< unsigned char > &grey, double *ts=nullptr)
bool open(const rs2::config &cfg=rs2::config())
VISP_EXPORT double measureTimeMs()