1 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImage.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/gui/vpDisplayX.h>
6 #include <visp3/io/vpImageStorageWorker.h>
7 #include <visp3/sensor/vp1394TwoGrabber.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 acquire 640x480 images in M0NO8 at 60 fps." << std::endl
22 <<
" --seqname <sequence name>" << std::endl
23 <<
" Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl
24 <<
" Default: empty." << std::endl
26 <<
" --record <mode>" << std::endl
27 <<
" Allowed values for mode are:" << std::endl
28 <<
" 0: record all the captures images (continuous mode)," << std::endl
29 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
30 <<
" Default mode: 0" << std::endl
32 <<
" --no-display" << std::endl
33 <<
" Disable displaying captured images." << std::endl
34 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
37 <<
" --help, -h" << std::endl
38 <<
" Print this helper message." << std::endl
40 std::cout <<
"USAGE" << std::endl
41 <<
" Example to visualize images:" << std::endl
42 <<
" " << argv[0] << std::endl
44 <<
" Examples to record a sequence:" << std::endl
45 <<
" " << argv[0] <<
" --seqname I%04d.png" << std::endl
46 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0" << std::endl
48 <<
" Examples to record single shot images:\n"
49 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
50 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1" << std::endl
54 std::cout <<
"Error" << std::endl
56 <<
"Unsupported parameter " << argv[error] << std::endl;
60 int main(
int argc,
const char *argv[])
62 #if defined(VISP_HAVE_DC1394) && defined(VISP_HAVE_THREADS)
63 #ifdef ENABLE_VISP_NAMESPACE
67 std::string opt_seqname;
68 int opt_record_mode = 0;
69 bool opt_change_settings =
false;
70 bool opt_display =
true;
72 for (
int i = 1; i < argc; i++) {
73 if (std::string(argv[i]) ==
"--change-settings") {
74 opt_change_settings =
true;
76 else if (std::string(argv[i]) ==
"--seqname") {
77 opt_seqname = std::string(argv[i + 1]);
80 else if (std::string(argv[i]) ==
"--record") {
81 opt_record_mode = std::atoi(argv[i + 1]);
84 else if (std::string(argv[i]) ==
"--no-display") {
87 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
97 if ((!opt_display) && (!opt_seqname.empty())) {
101 std::cout <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << std::endl;
102 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
103 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
105 std::string text_record_mode =
106 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
108 if (!opt_seqname.empty()) {
109 std::cout << text_record_mode << std::endl;
110 std::cout <<
"Record name: " << opt_seqname << std::endl;
120 if (opt_change_settings) {
127 std::cout <<
"Warning: cannot modify camera settings" << std::endl;
135 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
139 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV))
140 std::cout <<
"No image viewer is available..." << std::endl;
146 d =
new vpDisplayX(I);
147 #elif defined(HAVE_OPENCV_HIGHGUI)
152 vpImageQueue<vpRGBa> image_queue(opt_seqname, opt_record_mode);
164 quit = image_queue.record(I);
166 std::stringstream ss;
171 image_queue.cancel();
172 image_storage_thread.join();
179 std::cout <<
"Catch an exception: " << e << std::endl;
184 #ifndef VISP_HAVE_DC1394
185 std::cout <<
"Install libdc1394, configure and build ViSP again to use this example" << std::endl;
187 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
188 std::cout <<
"This tutorial should be built with c++11 support" << std::endl;
Class for firewire ieee1394 video devices using libdc1394-2.x api.
@ vpVIDEO_MODE_640x480_MONO8
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()