2 #include <visp3/core/vpImage.h> 3 #include <visp3/gui/vpDisplayX.h> 4 #include <visp3/gui/vpDisplayOpenCV.h> 5 #include <visp3/sensor/vpV4l2Grabber.h> 7 #include "record_helper.h" 15 int main(
int argc,
const char *argv[])
20 unsigned int opt_scale = 1;
22 std::string opt_seqname;
23 int opt_record_mode = 0;
25 for (
int i = 0; i < argc; i++) {
26 if (std::string(argv[i]) ==
"--camera_device")
27 opt_device = std::atoi(argv[i + 1]);
28 else if (std::string(argv[i]) ==
"--scale")
29 opt_scale = (
unsigned int)atoi(argv[i + 1]);
30 else if (std::string(argv[i]) ==
"--seqname")
31 opt_seqname = std::string(argv[i + 1]);
32 else if (std::string(argv[i]) ==
"--record")
33 opt_record_mode = std::atoi(argv[i + 1]);
34 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
35 std::cout <<
"\nUsage: " << argv[0]
36 <<
" [--camera_device <camera device (default: 0)>] [--scale <subsampling factor (default: 1)>]" 37 " [--seqname <sequence name (default: empty>] [--record <0: continuous | 1: single shot (default: 0)>]" 39 <<
"\nExample to visualize images:\n" 40 <<
" " << argv[0] <<
"\n" 41 <<
"\nExample to visualize images from a second camera:\n" 42 <<
" " << argv[0] <<
" --camera_device 1\n" 43 <<
"\nExamples to record a sequence:\n" 44 <<
" " << argv[0] <<
" --seqname I%04d.png \n" 45 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0\n" 46 <<
"\nExamples to record single shot images:\n" 47 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n" 48 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n" 54 std::cout <<
"Use device : " << opt_device << std::endl;
55 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
57 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") :
std::string(
"continuous"));
59 if (! opt_seqname.empty()) {
60 std::cout << text_record_mode << std::endl;
61 std::cout <<
"Record name: " << opt_seqname << std::endl;
67 std::ostringstream device;
68 device <<
"/dev/video" << opt_device;
73 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
77 #elif defined(VISP_HAVE_OPENCV) 80 std::cout <<
"No image viewer is available..." << std::endl;
90 quit = record_helper(opt_seqname, opt_record_mode, I);
98 std::cout <<
"Catch an exception: " << e << std::endl;
103 std::cout <<
"Install Video 4 Linux 2 (v4l2), configure and build ViSP again to use this example" << std::endl;
void acquire(vpImage< unsigned char > &I)
void open(vpImage< unsigned char > &I)
unsigned int getWidth() const
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void setDevice(const std::string &devname)
error that can be emited by ViSP classes.
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
unsigned int getHeight() const