42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_REALSENSE2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) \
45 && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
47 #include <visp3/core/vpImage.h>
48 #include <visp3/core/vpImageConvert.h>
49 #include <visp3/gui/vpDisplayGDI.h>
50 #include <visp3/gui/vpDisplayX.h>
51 #include <visp3/sensor/vpRealSense2.h>
53 int main(
int argc,
char *argv[])
55 bool show_info =
false;
57 for (
int i = 1; i < argc; i++) {
58 if (std::string(argv[i]) ==
"--show_info") {
66 std::cout <<
"RealSense:\n" << rs << std::endl;
70 int width = 1280, height = 720, fps = 30;
73 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
74 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
75 config.enable_stream(RS2_STREAM_INFRARED, 1, width, height, RS2_FORMAT_Y8, fps);
76 config.enable_stream(RS2_STREAM_INFRARED, 2, width, height, RS2_FORMAT_Y8, fps);
79 vpImage<vpRGBa> color(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
80 vpImage<vpRGBa> depth_color(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
81 vpImage<uint16_t> depth_raw(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
90 d1.
init(color, 0, 0,
"Color");
91 d2.
init(depth_color, color.getWidth(), 0,
"Depth");
92 d3.
init(infrared1, 0, color.getHeight() + 100,
"Infrared left");
93 d4.
init(infrared2, color.getWidth(), color.getHeight() + 100,
"Infrared right");
95 std::vector<vpColVector> pointcloud_colvector;
97 std::vector<double> time_vector;
102 rs.
acquire(
reinterpret_cast<unsigned char *
>(color.bitmap),
reinterpret_cast<unsigned char *
>(depth_raw.bitmap),
103 &pointcloud_colvector,
reinterpret_cast<unsigned char *
>(infrared1.bitmap),
104 reinterpret_cast<unsigned char *
>(infrared2.bitmap),
nullptr);
133 d2.
close(depth_color);
137 std::cout <<
"Acquisition1 - Mean time: " <<
vpMath::getMean(time_vector)
138 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
143 config.disable_all_streams();
144 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
145 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
146 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
149 color.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
150 depth_color.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
151 depth_raw.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
152 infrared1.init(
static_cast<unsigned int>(height),
static_cast<unsigned int>(width));
154 d1.
init(color, 0, 0,
"Color");
155 d2.
init(depth_color, color.getWidth(), 0,
"Depth");
156 d3.
init(infrared1, 0, color.getHeight() + 100,
"Infrared");
163 rs.
acquire(
reinterpret_cast<unsigned char *
>(color.bitmap),
reinterpret_cast<unsigned char *
>(depth_raw.bitmap),
164 nullptr,
reinterpret_cast<unsigned char *
>(infrared1.bitmap));
187 std::cout <<
"Acquisition2 - Mean time: " <<
vpMath::getMean(time_vector)
188 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
196 #if !defined(VISP_HAVE_REALSENSE2)
197 std::cout <<
"Install librealsense2 to make this test work." << std::endl;
199 #if !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_GDI)
200 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 void close(vpImage< unsigned char > &I)
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)
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)
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()