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),
103 reinterpret_cast<unsigned char *>(depth_raw.bitmap),
104 &pointcloud_colvector,
105 reinterpret_cast<unsigned char *>(infrared1.bitmap),
106 reinterpret_cast<unsigned char *>(infrared2.bitmap),
138 d2.
close(depth_color);
142 std::cout <<
"Acquisition1 - Mean time: " <<
vpMath::getMean(time_vector)
143 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
148 config.disable_all_streams();
149 config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
150 config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
151 config.enable_stream(RS2_STREAM_INFRARED, width, height, RS2_FORMAT_Y8, fps);
154 color.init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
155 depth_color.init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
156 depth_raw.init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
157 infrared1.init(static_cast<unsigned int>(height), static_cast<unsigned int>(width));
159 d1.
init(color, 0, 0,
"Color");
160 d2.
init(depth_color, color.getWidth(), 0,
"Depth");
161 d3.
init(infrared1, 0, color.getHeight() + 100,
"Infrared");
168 rs.
acquire(reinterpret_cast<unsigned char *>(color.bitmap),
169 reinterpret_cast<unsigned char *>(depth_raw.bitmap),
171 reinterpret_cast<unsigned char *>(infrared1.bitmap));
195 std::cout <<
"Acquisition2 - Mean time: " <<
vpMath::getMean(time_vector)
196 <<
" ms ; Median time: " <<
vpMath::getMedian(time_vector) <<
" ms" << std::endl;
204 #if !defined(VISP_HAVE_REALSENSE2) 205 std::cout <<
"Install librealsense2 to make this test work." << std::endl;
207 #if !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 208 std::cout <<
"Build ViSP with c++11 or higher compiler flag (cmake -DUSE_CXX_STANDARD=11) " 209 "to make this test work" 212 #if !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_GDI) 213 std::cout <<
"X11 or GDI are needed." << std::endl;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void close(vpImage< unsigned char > &I)
static double getMedian(const std::vector< double > &v)
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
static void flush(const vpImage< unsigned char > &I)
bool open(const rs2::config &cfg=rs2::config())
VISP_EXPORT double measureTimeMs()
static double getMean(const std::vector< double > &v)
static void display(const vpImage< unsigned char > &I)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void acquire(vpImage< unsigned char > &grey, double *ts=NULL)
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)