1 #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>
8 #include <visp3/sensor/vpFlyCaptureGrabber.h>
10 void usage(
const char *argv[],
int error)
12 std::cout <<
"SYNOPSIS" << std::endl
13 <<
" " << argv[0] <<
" [--change-settings]"
14 <<
" [--seqname <sequence name>]"
15 <<
" [--record <mode>]"
17 <<
" [--help] [-h]" << std::endl
19 std::cout <<
"DESCRIPTION" << std::endl
20 <<
" --change-settings" << std::endl
21 <<
" Force camera settings to auto shutter, auto gain and 640x480 MONO8 image" << std::endl
22 <<
" acquisition at 60 fps." << std::endl
24 <<
" --seqname <sequence name>" << std::endl
25 <<
" Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl
26 <<
" Default: empty." << std::endl
28 <<
" --record <mode>" << std::endl
29 <<
" Allowed values for mode are:" << std::endl
30 <<
" 0: record all the captures images (continuous mode)," << std::endl
31 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
32 <<
" Default mode: 0" << std::endl
34 <<
" --no-display" << std::endl
35 <<
" Disable displaying captured images." << std::endl
36 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
39 <<
" --help, -h" << std::endl
40 <<
" Print this helper message." << std::endl
42 std::cout <<
"USAGE" << std::endl
43 <<
" Example to visualize images:" << std::endl
44 <<
" " << argv[0] << std::endl
46 <<
" Examples to record a sequence:" << std::endl
47 <<
" " << argv[0] <<
" --seqname I%04d.png" << std::endl
48 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0" << std::endl
50 <<
" Examples to record single shot images:\n"
51 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
52 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1" << std::endl
56 std::cout <<
"Error" << std::endl
58 <<
"Unsupported parameter " << argv[error] << std::endl;
62 int main(
int argc,
const char *argv[])
64 #if defined(VISP_HAVE_FLYCAPTURE) && defined(VISP_HAVE_THREADS)
65 #ifdef ENABLE_VISP_NAMESPACE
69 std::string opt_seqname;
70 int opt_record_mode = 0;
71 bool opt_change_settings =
false;
72 bool opt_display =
true;
74 for (
int i = 1; i < argc; i++) {
75 if (std::string(argv[i]) ==
"--change-settings") {
76 opt_change_settings =
true;
78 else if (std::string(argv[i]) ==
"--seqname") {
79 opt_seqname = std::string(argv[i + 1]);
82 else if (std::string(argv[i]) ==
"--record") {
83 opt_record_mode = std::atoi(argv[i + 1]);
86 else if (std::string(argv[i]) ==
"--no-display") {
89 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
99 if ((!opt_display) && (!opt_seqname.empty())) {
103 std::cout <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << std::endl;
104 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
105 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
107 std::string text_record_mode =
108 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
110 if (!opt_seqname.empty()) {
111 std::cout << text_record_mode << std::endl;
112 std::cout <<
"Record name: " << opt_seqname << std::endl;
121 if (opt_change_settings) {
129 std::cout <<
"Warning: cannot modify camera settings" << std::endl;
137 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
141 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
142 std::cout <<
"No image viewer is available..." << std::endl;
148 d =
new vpDisplayX(I);
149 #elif defined(VISP_HAVE_GDI)
151 #elif defined(HAVE_OPENCV_HIGHGUI)
156 vpImageQueue<vpRGBa> image_queue(opt_seqname, opt_record_mode);
170 quit = image_queue.record(I);
172 std::stringstream ss;
177 image_queue.cancel();
178 image_storage_thread.join();
190 #ifndef VISP_HAVE_FLYCAPTURE
191 std::cout <<
"Install Flycapture SDK, configure and build ViSP again to use this example" << std::endl;
193 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
194 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...
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()