2 #include <visp3/core/vpImage.h>
3 #include <visp3/gui/vpDisplayGDI.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/gui/vpDisplayX.h>
6 #include <visp3/sensor/vpRealSense2.h>
7 #include <visp3/io/vpImageStorageWorker.h>
12 int main(
int argc,
char **argv)
14 #if defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
16 std::string opt_seqname_left =
"left-%04d.png", opt_seqname_right =
"right-%04d.png";
17 int opt_record_mode = 0;
20 for (
int i = 0; i < argc; i++) {
21 if (std::string(argv[i]) ==
"--record")
22 opt_record_mode = std::atoi(argv[i + 1]);
23 else if (std::string(argv[i]) ==
"--fps")
24 opt_fps = std::atoi(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
26 std::cout <<
"\nUsage: " << argv[0]
27 <<
" [--record <0: continuous | 1: single shot (default: 0)>]"
29 <<
"\nExample to visualize images:\n"
30 <<
" " << argv[0] <<
"\n"
31 <<
"\nExamples to record single shot images:\n"
32 <<
" " << argv[0] <<
" --record 1\n"
33 <<
"\nExamples to record a sequence of images:\n"
34 <<
" " << argv[0] <<
" --record 0\n"
40 std::cout <<
"Framerate : " << opt_fps << std::endl;
42 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") :
std::string(
"continuous"));
44 std::cout << text_record_mode << std::endl;
45 std::cout <<
"Left record name: " << opt_seqname_left << std::endl;
46 std::cout <<
"Right record name: " << opt_seqname_right << std::endl;
52 config.enable_stream(RS2_STREAM_FISHEYE, 1);
53 config.enable_stream(RS2_STREAM_FISHEYE, 2);
58 std::cout <<
"Image size : " << I_left.
getWidth() <<
" " << I_right.
getHeight() << std::endl;
61 vpDisplayX display_left(I_left, 10, 10,
"Left image");
63 #elif defined(VISP_HAVE_GDI)
66 #elif defined(VISP_HAVE_OPENCV)
70 std::cout <<
"No image viewer is available..." << std::endl;
89 quit = image_queue_left.record(I_left);
90 quit |= image_queue_right.record(I_right, NULL, image_queue_left.getRecordingTrigger(),
true);
98 image_queue_left.cancel();
99 image_queue_right.cancel();
100 image_left_storage_thread.join();
101 image_right_storage_thread.join();
103 std::cout <<
"Catch an exception: " << e << std::endl;
108 #if !(defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)))
109 std::cout <<
"Install librealsense version > 2.31.0, configure and build ViSP again to use this example" << std::endl;
111 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
112 std::cout <<
"This turorial should be built with c++11 support" << std::endl;
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
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)
error that can be emited by ViSP classes.
unsigned int getWidth() const
unsigned int getHeight() const
void acquire(vpImage< unsigned char > &grey, double *ts=NULL)
bool open(const rs2::config &cfg=rs2::config())
VISP_EXPORT double measureTimeMs()