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>
8 #ifdef VISP_HAVE_MODULE_ROBOT
9 #include <visp3/robot/vpRobotBebop2.h>
14 int main(
int argc,
char **argv)
16 #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
18 std::string opt_seqname;
19 int opt_record_mode = 0;
21 std::string ip_address =
"192.168.42.1";
23 for (
int i = 1; i < argc; i++) {
24 if (std::string(argv[i]) ==
"--seqname")
25 opt_seqname = std::string(argv[i + 1]);
26 else if (std::string(argv[i]) ==
"--record")
27 opt_record_mode = std::atoi(argv[i + 1]);
28 else if (std::string(argv[i]) ==
"--ip" && i + 1 < argc) {
29 ip_address = std::string(argv[i + 1]);
31 }
else if (std::string(argv[i]) ==
"--hd_resolution")
33 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
34 std::cout <<
"\nUsage:\n"
35 <<
" " << argv[0] <<
" [--seqname <sequence name>] [--record <0: continuous | 1: single shot>]"
36 <<
" [--ip <drone ip>] [--hd_resolution]"
40 <<
" --seqname <sequence name>\n"
41 <<
" Desired name for picture sequence (default: empty).\n\n"
42 <<
" --record <0: continuous | 1: single shot>\n"
43 <<
" Record mode (default : 0, continuous).\n\n"
44 <<
" --ip <drone ip>\n"
45 <<
" IP address of the drone to which you want to connect (default : 192.168.42.1).\n\n"
46 <<
" --hd_resolution\n"
47 <<
" Enables HD 720p images instead of default 480p.\n"
48 <<
" Caution : camera calibration settings are different for the two resolutions.\n\n"
50 <<
" Print help message.\n\n"
52 <<
"\nExample to visualize images:\n"
53 <<
" " << argv[0] <<
"\n"
54 <<
"\nExamples to record a sequence of 720p images from drone with ip different from default:\n"
55 <<
" " << argv[0] <<
" --seqname I%04d.png --ip 192.168.42.3 --hd_resolution\n"
56 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0 --ip 192.168.42.3 --hd_resolution\n"
57 <<
"\nExamples to record single shot images:\n"
58 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
59 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n"
63 std::cout <<
"Error : unknown parameter " << argv[i] << std::endl
64 <<
"See " << argv[0] <<
" --help" << std::endl;
69 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
71 std::string text_record_mode =
72 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
74 if (!opt_seqname.empty()) {
75 std::cout << text_record_mode << std::endl;
76 std::cout <<
"Record name: " << opt_seqname << std::endl;
78 std::cout <<
"Image resolution : " << (image_res == 0 ?
"480p." :
"720p.") << std::endl << std::endl;
84 if (drone.isRunning()) {
86 drone.setVideoResolution(image_res);
88 drone.startStreaming();
89 drone.setExposure(1.5f);
90 drone.getGrayscaleImage(I);
92 std::cout <<
"Error : failed to setup drone control" << std::endl;
96 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
100 #elif defined(VISP_HAVE_GDI)
102 #elif defined(VISP_HAVE_OPENCV)
105 std::cout <<
"No image viewer is available..." << std::endl;
115 drone.getGrayscaleImage(I);
119 quit = image_queue.record(I);
121 std::stringstream ss;
126 image_queue.cancel();
127 image_storage_thread.join();
129 std::cout <<
"Caught an exception: " << e << std::endl;
134 #ifndef VISP_HAVE_ARSDK
135 std::cout <<
"Install Parrot ARSDK3, configure and build ViSP again to use this example" << std::endl;
137 #ifndef VISP_HAVE_FFMPEG
138 std::cout <<
"Install ffmpeg, configure and build ViSP again to use this example" << std::endl;
140 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
141 std::cout <<
"This turorial should be built with c++11 support" << std::endl;
148 std::cout <<
"This tutorial needs visp_robot module that is not built." << 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
VISP_EXPORT double measureTimeMs()