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/io/vpImageStorageWorker.h>
7 #include <visp3/sensor/vpRealSense2.h>
9 void usage(
const char *argv[],
int error)
11 std::cout <<
"SYNOPSIS" << std::endl
12 <<
" " << argv[0] <<
" [--fps <6|15|30|60>]"
13 <<
" [--record <mode>]"
15 <<
" [--help] [-h]" << std::endl
17 std::cout <<
"DESCRIPTION" << std::endl
18 <<
" --fps <6|15|30|60>" << std::endl
19 <<
" Frames per second." << std::endl
20 <<
" Default: 30." << std::endl
22 <<
" --record <mode>" << std::endl
23 <<
" Allowed values for mode are:" << std::endl
24 <<
" 0: record all the captures images (continuous mode)," << std::endl
25 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
26 <<
" Default mode: 0" << std::endl
28 <<
" --no-display" << std::endl
29 <<
" Disable displaying captured images." << std::endl
30 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
33 <<
" --help, -h" << std::endl
34 <<
" Print this helper message." << std::endl
36 std::cout <<
"USAGE" << std::endl
37 <<
" Example to visualize images:" << std::endl
38 <<
" " << argv[0] << std::endl
40 <<
" Example to record a sequence of images:" << std::endl
41 <<
" " << argv[0] <<
" --record 0" << std::endl
43 <<
" Example to record single shot images:\n"
44 <<
" " << argv[0] <<
" --record 1" << std::endl
48 std::cout <<
"Error" << std::endl
50 <<
"Unsupported parameter " << argv[error] << std::endl;
57 int main(
int argc,
const char *argv[])
59 #if defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) && \
60 (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
62 std::string opt_seqname_left =
"left-%04d.png", opt_seqname_right =
"right-%04d.png";
63 int opt_record_mode = 0;
65 bool opt_display =
true;
67 for (
int i = 1; i < argc; i++) {
68 if (std::string(argv[i]) ==
"--fps") {
69 opt_fps = std::atoi(argv[i + 1]);
71 }
else if (std::string(argv[i]) ==
"--record") {
72 opt_record_mode = std::atoi(argv[i + 1]);
74 }
else if (std::string(argv[i]) ==
"--no-display") {
76 }
else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
89 std::cout <<
"Framerate : " << opt_fps << std::endl;
90 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
92 std::string text_record_mode =
93 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
95 std::cout << text_record_mode << std::endl;
96 std::cout <<
"Left record name: " << opt_seqname_left << std::endl;
97 std::cout <<
"Right record name: " << opt_seqname_right << std::endl;
103 config.enable_stream(RS2_STREAM_FISHEYE, 1);
104 config.enable_stream(RS2_STREAM_FISHEYE, 2);
109 std::cout <<
"Image size : " << I_left.
getWidth() <<
" " << I_right.
getHeight() << std::endl;
111 vpDisplay *display_left = NULL, *display_right = NULL;
113 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
114 std::cout <<
"No image viewer is available..." << std::endl;
120 display_left =
new vpDisplayX(I_left, 10, 10,
"Left image");
122 #elif defined(VISP_HAVE_GDI)
123 display_left =
new vpDisplayGDI(I_left, 10, 10,
"Left image");
125 #elif defined(HAVE_OPENCV_HIGHGUI)
147 quit = image_queue_left.record(I_left);
148 quit |= image_queue_right.record(I_right, NULL, image_queue_left.getRecordingTrigger(),
true);
150 std::stringstream ss;
156 image_queue_left.cancel();
157 image_queue_right.cancel();
158 image_left_storage_thread.join();
159 image_right_storage_thread.join();
165 delete display_right;
168 std::cout <<
"Catch an exception: " << e << std::endl;
173 #if !(defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)))
174 std::cout <<
"Install librealsense version > 2.31.0, configure and build ViSP again to use this example" << std::endl;
176 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
177 std::cout <<
"This tutorial 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...
Class that defines generic functionalities for display.
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 emitted 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()