1 #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/vpFlyCaptureGrabber.h>
9 void usage(
const char *argv[],
int error)
11 std::cout <<
"SYNOPSIS" << std::endl
12 <<
" " << argv[0] <<
" [--change-settings]"
13 <<
" [--seqname <sequence name>]"
14 <<
" [--record <mode>]"
16 <<
" [--help] [-h]" << std::endl
18 std::cout <<
"DESCRIPTION" << std::endl
19 <<
" --change-settings" << std::endl
20 <<
" Force camera settings to auto shutter, auto gain and 640x480 MONO8 image" << std::endl
21 <<
" acquisition at 60 fps." << std::endl
23 <<
" --seqname <sequence name>" << std::endl
24 <<
" Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl
25 <<
" Default: empty." << std::endl
27 <<
" --record <mode>" << std::endl
28 <<
" Allowed values for mode are:" << std::endl
29 <<
" 0: record all the captures images (continuous mode)," << std::endl
30 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
31 <<
" Default mode: 0" << std::endl
33 <<
" --no-display" << std::endl
34 <<
" Disable displaying captured images." << std::endl
35 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
38 <<
" --help, -h" << std::endl
39 <<
" Print this helper message." << std::endl
41 std::cout <<
"USAGE" << std::endl
42 <<
" Example to visualize images:" << std::endl
43 <<
" " << argv[0] << std::endl
45 <<
" Examples to record a sequence:" << std::endl
46 <<
" " << argv[0] <<
" --seqname I%04d.png" << std::endl
47 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0" << std::endl
49 <<
" Examples to record single shot images:\n"
50 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
51 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1" << std::endl
55 std::cout <<
"Error" << std::endl
57 <<
"Unsupported parameter " << argv[error] << std::endl;
61 int main(
int argc,
const char *argv[])
63 #if defined(VISP_HAVE_FLYCAPTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
65 std::string opt_seqname;
66 int opt_record_mode = 0;
67 bool opt_change_settings =
false;
68 bool opt_display =
true;
70 for (
int i = 1; i < argc; i++) {
71 if (std::string(argv[i]) ==
"--change-settings") {
72 opt_change_settings =
true;
73 }
else if (std::string(argv[i]) ==
"--seqname") {
74 opt_seqname = std::string(argv[i + 1]);
76 }
else if (std::string(argv[i]) ==
"--record") {
77 opt_record_mode = std::atoi(argv[i + 1]);
79 }
else if (std::string(argv[i]) ==
"--no-display") {
81 }
else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
90 if ((!opt_display) && (!opt_seqname.empty())) {
94 std::cout <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << std::endl;
95 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
96 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
98 std::string text_record_mode =
99 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
101 if (!opt_seqname.empty()) {
102 std::cout << text_record_mode << std::endl;
103 std::cout <<
"Record name: " << opt_seqname << std::endl;
112 if (opt_change_settings) {
119 std::cout <<
"Warning: cannot modify camera settings" << std::endl;
127 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
131 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
132 std::cout <<
"No image viewer is available..." << std::endl;
139 #elif defined(VISP_HAVE_GDI)
141 #elif defined(HAVE_OPENCV_HIGHGUI)
160 quit = image_queue.record(I);
162 std::stringstream ss;
167 image_queue.cancel();
168 image_storage_thread.join();
179 #ifndef VISP_HAVE_FLYCAPTURE
180 std::cout <<
"Install Flycapture SDK, configure and build ViSP again to use this example" << std::endl;
182 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
183 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.
const std::string & getStringMessage() const
float setGain(bool gain_auto, float gain_value=0)
float setShutter(bool auto_shutter, float shutter_ms=10)
void open(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
unsigned int getWidth() const
unsigned int getHeight() const
VISP_EXPORT double measureTimeMs()