2 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImage.h>
4 #include <visp3/gui/vpDisplayFactory.h>
5 #include <visp3/io/vpImageStorageWorker.h>
7 #ifdef VISP_HAVE_MODULE_ROBOT
8 #include <visp3/robot/vpRobotBebop2.h>
10 void usage(
const char *argv[],
int error)
12 std::cout <<
"SYNOPSIS" << std::endl
13 <<
" " << argv[0] <<
" [--ip <address>]"
14 <<
" [--hd-resolution]"
15 <<
" [--seqname <sequence name>]"
16 <<
" [--record <mode>]"
18 <<
" [--help] [-h]" << std::endl
20 std::cout <<
"DESCRIPTION" << std::endl
21 <<
" --ip <address>" << std::endl
22 <<
" IP address of the drone to which you want to connect." << std::endl
23 <<
" Default: 192.168.42.1" << std::endl
25 <<
" --hd-resolution" << std::endl
26 <<
" Enables HD 720p images instead of default 480p." << std::endl
27 <<
" Caution : The camera settings are different depending on whether the resolution is 720p or 480p."
30 <<
" --seqname <sequence name>" << std::endl
31 <<
" Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl
32 <<
" Default: empty." << std::endl
34 <<
" --record <mode>" << std::endl
35 <<
" Allowed values for mode are:" << std::endl
36 <<
" 0: record all the captures images (continuous mode)," << std::endl
37 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
38 <<
" Default mode: 0" << std::endl
40 <<
" --no-display" << std::endl
41 <<
" Disable displaying captured images." << std::endl
42 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
45 <<
" --help, -h" << std::endl
46 <<
" Print this helper message." << std::endl
48 std::cout <<
"USAGE" << std::endl
49 <<
" Example to visualize images:" << std::endl
50 <<
" " << argv[0] << std::endl
52 <<
" Examples to record a sequence of 720p images from drone with ip different from default:" << std::endl
53 <<
" " << argv[0] <<
" --seqname I%04d.png --ip 192.168.42.3 --hd_resolution" << std::endl
54 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0 --ip 192.168.42.3 --hd-resolution"
57 <<
" Examples to record single shot images:" << std::endl
58 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1" << std::endl
59 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1" << std::endl
63 std::cout <<
"Error" << std::endl
65 <<
"Unsupported parameter " << argv[error] << std::endl;
72 int main(
int argc,
const char **argv)
74 #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG) && defined(VISP_HAVE_THREADS)
75 #ifdef ENABLE_VISP_NAMESPACE
78 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
79 std::shared_ptr<vpDisplay> display;
84 std::string opt_seqname;
85 int opt_record_mode = 0;
87 std::string ip_address =
"192.168.42.1";
88 bool opt_display =
true;
90 for (
int i = 1; i < argc; i++) {
91 if (std::string(argv[i]) ==
"--seqname" && i + 1 < argc) {
92 opt_seqname = std::string(argv[++i]);
95 else if (std::string(argv[i]) ==
"--record" && i + 1 < argc) {
96 opt_record_mode = std::atoi(argv[++i]);
99 else if (std::string(argv[i]) ==
"--ip" && i + 1 < argc) {
100 ip_address = std::string(argv[++i]);
103 else if (std::string(argv[i]) ==
"--hd-resolution") {
106 else if (std::string(argv[i]) ==
"--no-display") {
109 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
119 if ((!opt_display) && (!opt_seqname.empty())) {
123 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
124 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
126 std::string text_record_mode =
127 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
129 if (!opt_seqname.empty()) {
130 std::cout << text_record_mode << std::endl;
131 std::cout <<
"Record name: " << opt_seqname << std::endl;
133 std::cout <<
"Image resolution : " << (image_res == 0 ?
"480p." :
"720p.") << std::endl << std::endl;
139 if (drone.isRunning()) {
141 drone.setVideoResolution(image_res);
143 drone.startStreaming();
144 drone.setExposure(1.5f);
145 drone.getRGBaImage(I);
148 std::cout <<
"Error : failed to setup drone control" << std::endl;
152 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
155 #if !(defined(VISP_HAVE_DISPLAY))
156 std::cout <<
"No image viewer is available..." << std::endl;
161 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
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();
190 std::cout <<
"Caught an exception: " << e << std::endl;
192 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
193 if (display !=
nullptr) {
200 #ifndef VISP_HAVE_ARSDK
201 std::cout <<
"Install Parrot ARSDK3, configure and build ViSP again to use this example" << std::endl;
203 #ifndef VISP_HAVE_FFMPEG
204 std::cout <<
"Install ffmpeg, configure and build ViSP again to use this example" << std::endl;
206 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
207 std::cout <<
"This tutorial should be built with c++11 support" << std::endl;
212 int main() { std::cout <<
"This tutorial needs visp_robot module that is not built." << std::endl; }
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
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
VISP_EXPORT double measureTimeMs()