3 #include <visp3/core/vpImageConvert.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
6 #include "record_helper.h"
11 int main(
int argc,
char **argv)
14 std::string opt_seqname;
15 int opt_record_mode = 0;
17 for (
int i = 0; i < argc; i++) {
18 if (std::string(argv[i]) ==
"--camera_device")
19 opt_device = std::atoi(argv[i + 1]);
20 else if (std::string(argv[i]) ==
"--seqname")
21 opt_seqname = std::string(argv[i + 1]);
22 else if (std::string(argv[i]) ==
"--record")
23 opt_record_mode = std::atoi(argv[i + 1]);
24 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
25 std::cout <<
"\nUsage: " << argv[0]
26 <<
" [--camera_device <camera device (default: 0>]"
27 <<
" [--seqname <sequence name (default: empty>] [--record <0: continuous | 1: single shot (default: 0)>]"
29 <<
"\nExample to visualize images:\n"
30 <<
" " << argv[0] <<
"\n"
31 <<
"\nExample to visualize images from a second camera:\n"
32 <<
" " << argv[0] <<
" --camera_device 1\n"
33 <<
"\nExamples to record a sequence:\n"
34 <<
" " << argv[0] <<
" --seqname I%04d.png \n"
35 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0\n"
36 <<
"\nExamples to record single shot images:\n"
37 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
38 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n"
44 std::cout <<
"Use device : " << opt_device << std::endl;
45 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
47 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
49 if (! opt_seqname.empty()) {
50 std::cout << text_record_mode << std::endl;
51 std::cout <<
"Record name: " << opt_seqname << std::endl;
54 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100)
56 cv::VideoCapture cap(opt_device);
57 if (!cap.isOpened()) {
58 std::cout <<
"Failed to open the camera" << std::endl;
63 while ((i++ < 20) && !cap.read(frame)) {
66 std::cout <<
"Image size : " << frame.rows <<
" " << frame.cols << std::endl;
83 quit = record_helper(opt_seqname, opt_record_mode, I);
91 std::cout <<
"Catch an exception: " << e << std::endl;
96 std::cout <<
"Install OpenCV, configure and build ViSP again to use this example" << std::endl;