2 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImage.h>
4 #include <visp3/gui/vpDisplayGDI.h>
5 #include <visp3/gui/vpDisplayOpenCV.h>
6 #include <visp3/gui/vpDisplayX.h>
7 #include <visp3/io/vpImageStorageWorker.h>
9 #ifdef VISP_HAVE_MODULE_ROBOT
10 #include <visp3/robot/vpRobotBebop2.h>
12 void usage(
const char *argv[],
int error)
14 std::cout <<
"SYNOPSIS" << std::endl
15 <<
" " << argv[0] <<
" [--ip <address>]"
16 <<
" [--hd-resolution]"
17 <<
" [--seqname <sequence name>]"
18 <<
" [--record <mode>]"
20 <<
" [--help] [-h]" << std::endl
22 std::cout <<
"DESCRIPTION" << std::endl
23 <<
" --ip <address>" << std::endl
24 <<
" IP address of the drone to which you want to connect." << std::endl
25 <<
" Default: 192.168.42.1" << std::endl
27 <<
" --hd-resolution" << std::endl
28 <<
" Enables HD 720p images instead of default 480p." << std::endl
29 <<
" Caution : The camera settings are different depending on whether the resolution is 720p or 480p."
32 <<
" --seqname <sequence name>" << std::endl
33 <<
" Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl
34 <<
" Default: empty." << std::endl
36 <<
" --record <mode>" << std::endl
37 <<
" Allowed values for mode are:" << std::endl
38 <<
" 0: record all the captures images (continuous mode)," << std::endl
39 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
40 <<
" Default mode: 0" << std::endl
42 <<
" --no-display" << std::endl
43 <<
" Disable displaying captured images." << std::endl
44 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
47 <<
" --help, -h" << std::endl
48 <<
" Print this helper message." << std::endl
50 std::cout <<
"USAGE" << std::endl
51 <<
" Example to visualize images:" << std::endl
52 <<
" " << argv[0] << std::endl
54 <<
" Examples to record a sequence of 720p images from drone with ip different from default:" << std::endl
55 <<
" " << argv[0] <<
" --seqname I%04d.png --ip 192.168.42.3 --hd_resolution" << std::endl
56 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0 --ip 192.168.42.3 --hd-resolution"
59 <<
" Examples to record single shot images:" << std::endl
60 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1" << std::endl
61 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1" << std::endl
65 std::cout <<
"Error" << std::endl
67 <<
"Unsupported parameter " << argv[error] << std::endl;
74 int main(
int argc,
const char **argv)
76 #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG) && defined(VISP_HAVE_THREADS)
77 #ifdef ENABLE_VISP_NAMESPACE
81 std::string opt_seqname;
82 int opt_record_mode = 0;
84 std::string ip_address =
"192.168.42.1";
85 bool opt_display =
true;
87 for (
int i = 1; i < argc; i++) {
88 if (std::string(argv[i]) ==
"--seqname") {
89 opt_seqname = std::string(argv[i + 1]);
92 else if (std::string(argv[i]) ==
"--record") {
93 opt_record_mode = std::atoi(argv[i + 1]);
96 else if (std::string(argv[i]) ==
"--ip" && i + 1 < argc) {
97 ip_address = std::string(argv[i + 1]);
100 else if (std::string(argv[i]) ==
"--hd-resolution") {
103 else if (std::string(argv[i]) ==
"--no-display") {
106 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
116 if ((!opt_display) && (!opt_seqname.empty())) {
120 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
121 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
123 std::string text_record_mode =
124 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
126 if (!opt_seqname.empty()) {
127 std::cout << text_record_mode << std::endl;
128 std::cout <<
"Record name: " << opt_seqname << std::endl;
130 std::cout <<
"Image resolution : " << (image_res == 0 ?
"480p." :
"720p.") << std::endl << std::endl;
136 if (drone.isRunning()) {
138 drone.setVideoResolution(image_res);
140 drone.startStreaming();
141 drone.setExposure(1.5f);
142 drone.getRGBaImage(I);
145 std::cout <<
"Error : failed to setup drone control" << std::endl;
149 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
153 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
154 std::cout <<
"No image viewer is available..." << std::endl;
160 d =
new vpDisplayX(I);
161 #elif defined(VISP_HAVE_GDI)
163 #elif defined(HAVE_OPENCV_HIGHGUI)
168 vpImageQueue<vpRGBa> image_queue(opt_seqname, opt_record_mode);
175 drone.getRGBaImage(I);
179 quit = image_queue.record(I);
181 std::stringstream ss;
186 image_queue.cancel();
187 image_storage_thread.join();
194 std::cout <<
"Caught an exception: " << e << std::endl;
199 #ifndef VISP_HAVE_ARSDK
200 std::cout <<
"Install Parrot ARSDK3, configure and build ViSP again to use this example" << std::endl;
202 #ifndef VISP_HAVE_FFMPEG
203 std::cout <<
"Install ffmpeg, configure and build ViSP again to use this example" << std::endl;
205 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
206 std::cout <<
"This tutorial should be built with c++11 support" << std::endl;
211 int main() { 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...
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
VISP_EXPORT double measureTimeMs()