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/robot/vpRobotBebop2.h>
8 #include "record_helper.h"
13 int main(
int argc,
char **argv)
15 #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG)
17 std::string opt_seqname;
18 int opt_record_mode = 0;
20 std::string ip_address =
"192.168.42.1";
22 for (
int i = 1; i < argc; i++) {
23 if (std::string(argv[i]) ==
"--seqname")
24 opt_seqname = std::string(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--record")
26 opt_record_mode = std::atoi(argv[i + 1]);
27 else if (std::string(argv[i]) ==
"--ip" && i + 1 < argc) {
28 ip_address = std::string(argv[i + 1]);
30 }
else if (std::string(argv[i]) ==
"--hd_resolution")
32 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
33 std::cout <<
"\nUsage:\n"
34 <<
" " << argv[0] <<
" [--seqname <sequence name>] [--record <0: continuous | 1: single shot>]"
35 <<
" [--ip <drone ip>] [--hd_resolution]"
39 <<
" --seqname <sequence name>\n"
40 <<
" Desired name for picture sequence (default: empty).\n\n"
41 <<
" --record <0: continuous | 1: single shot>\n"
42 <<
" Record mode (default : 0, continuous).\n\n"
43 <<
" --ip <drone ip>\n"
44 <<
" IP address of the drone to which you want to connect (default : 192.168.42.1).\n\n"
45 <<
" --hd_resolution\n"
46 <<
" Enables HD 720p images instead of default 480p.\n"
47 <<
" Caution : camera calibration settings are different for the two resolutions.\n\n"
49 <<
" Print help message.\n\n"
51 <<
"\nExample to visualize images:\n"
52 <<
" " << argv[0] <<
"\n"
53 <<
"\nExamples to record a sequence of 720p images from drone with ip different from default:\n"
54 <<
" " << argv[0] <<
" --seqname I%04d.png --ip 192.168.42.3 --hd_resolution\n"
55 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0 --ip 192.168.42.3 --hd_resolution\n"
56 <<
"\nExamples to record single shot images:\n"
57 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
58 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n"
62 std::cout <<
"Error : unknown parameter " << argv[i] << std::endl
63 <<
"See " << argv[0] <<
" --help" << std::endl;
68 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
70 std::string text_record_mode =
71 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
73 if (!opt_seqname.empty()) {
74 std::cout << text_record_mode << std::endl;
75 std::cout <<
"Record name: " << opt_seqname << std::endl;
77 std::cout <<
"Image resolution : " << (image_res == 0 ?
"480p." :
"720p.") << std::endl << std::endl;
83 if (drone.isRunning()) {
85 drone.setVideoResolution(image_res);
87 drone.startStreaming();
88 drone.setExposure(1.5f);
89 drone.getGrayscaleImage(I);
91 std::cout <<
"Error : failed to setup drone control" << std::endl;
95 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
99 #elif defined(VISP_HAVE_GDI)
101 #elif defined(VISP_HAVE_OPENCV)
104 std::cout <<
"No image viewer is available..." << std::endl;
110 drone.getGrayscaleImage(I);
114 quit = record_helper(opt_seqname, opt_record_mode, I);
116 std::stringstream ss;
122 std::cout <<
"Caught an exception: " << e << std::endl;
127 std::cout <<
"Install Parrot ARSDK3 and ffmpeg, configure and build ViSP again to use this example" << std::endl;
128 #endif // #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG)