3 #include <visp3/core/vpImageConvert.h> 4 #include <visp3/gui/vpDisplayOpenCV.h> 5 #include <visp3/io/vpImageStorageWorker.h> 12 int main(
int argc,
char **argv)
15 std::string opt_seqname;
16 int opt_record_mode = 0;
18 for (
int i = 0; i < argc; i++) {
19 if (std::string(argv[i]) ==
"--camera_device")
20 opt_device = std::atoi(argv[i + 1]);
21 else if (std::string(argv[i]) ==
"--seqname")
22 opt_seqname = std::string(argv[i + 1]);
23 else if (std::string(argv[i]) ==
"--record")
24 opt_record_mode = std::atoi(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
26 std::cout <<
"\nUsage: " << argv[0]
27 <<
" [--camera_device <camera device (default: 0>]" 28 <<
" [--seqname <sequence name (default: empty>] [--record <0: continuous | 1: single shot (default: 0)>]" 30 <<
"\nExample to visualize images:\n" 31 <<
" " << argv[0] <<
"\n" 32 <<
"\nExample to visualize images from a second camera:\n" 33 <<
" " << argv[0] <<
" --camera_device 1\n" 34 <<
"\nExamples to record a sequence:\n" 35 <<
" " << argv[0] <<
" --seqname I%04d.png \n" 36 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0\n" 37 <<
"\nExamples to record single shot images:\n" 38 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n" 39 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n" 45 std::cout <<
"Use device : " << opt_device << std::endl;
46 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
48 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") :
std::string(
"continuous"));
50 if (! opt_seqname.empty()) {
51 std::cout << text_record_mode << std::endl;
52 std::cout <<
"Record name: " << opt_seqname << std::endl;
55 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 57 cv::VideoCapture cap(opt_device);
58 if (!cap.isOpened()) {
59 std::cout <<
"Failed to open the camera" << std::endl;
64 while ((i++ < 20) && !cap.read(frame)) {
67 std::cout <<
"Image size : " << frame.rows <<
" " << frame.cols << std::endl;
97 quit = image_queue.record(I);
104 image_queue.cancel();
105 image_storage_thread.join();
107 std::cout <<
"Catch an exception: " << e << std::endl;
112 #if (VISP_HAVE_OPENCV_VERSION < 0x020100) 113 std::cout <<
"Install OpenCV, configure and build ViSP again to use this example" << std::endl;
115 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) 116 std::cout <<
"This turorial should be built with c++11 support" << std::endl;
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
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...
unsigned int getHeight() const