2#include <visp3/core/vpConfig.h>
3#include <visp3/core/vpImage.h>
4#include <visp3/gui/vpDisplayFactory.h>
5#include <visp3/io/vpImageStorageWorker.h>
6#include <visp3/sensor/vp1394TwoGrabber.h>
8void usage(
const char *argv[],
int error);
10void 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 acquire 640x480 images in M0NO8 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;
61int main(
int argc,
const char *argv[])
63#if defined(VISP_HAVE_DC1394) && defined(VISP_HAVE_THREADS)
64#ifdef ENABLE_VISP_NAMESPACE
67#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
68 std::shared_ptr<vpDisplay> display;
73 std::string opt_seqname;
74 int opt_record_mode = 0;
75 bool opt_change_settings =
false;
76 bool opt_display =
true;
78 for (
int i = 1;
i < argc;
i++) {
79 if (std::string(argv[i]) ==
"--change-settings") {
80 opt_change_settings =
true;
82 else if (std::string(argv[i]) ==
"--seqname" && i + 1 < argc) {
83 opt_seqname = std::string(argv[++i]);
86 else if (std::string(argv[i]) ==
"--record" && i + 1 < argc) {
87 opt_record_mode = std::atoi(argv[++i]);
90 else if (std::string(argv[i]) ==
"--no-display") {
93 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
103 if ((!opt_display) && (!opt_seqname.empty())) {
107 std::cout <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << std::endl;
108 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
109 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
111 std::string text_record_mode =
112 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
114 if (!opt_seqname.empty()) {
115 std::cout << text_record_mode << std::endl;
116 std::cout <<
"Record name: " << opt_seqname << std::endl;
126 if (opt_change_settings) {
132 std::cout <<
"Warning: cannot modify camera settings" << std::endl;
140 std::cout <<
"Image size : " << I.getWidth() <<
" " << I.getHeight() << std::endl;
143#if !(defined(VISP_HAVE_DISPLAY))
144 std::cout <<
"No image viewer is available..." << std::endl;
149#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
156 vpImageQueue<vpRGBa> image_queue(opt_seqname, opt_record_mode);
168 quit = image_queue.record(I);
170 std::stringstream ss;
175 image_queue.cancel();
176 image_storage_thread.join();
179 std::cout <<
"Catch an exception: " <<
e << std::endl;
181#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
182 if (display !=
nullptr) {
189#ifndef VISP_HAVE_DC1394
190 std::cout <<
"Install libdc1394, configure and build ViSP again to use this example" << std::endl;
192#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
193 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
void open(vpImage< unsigned char > &I)
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.
Definition of the vpImage class member functions.
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()