2 #include <visp3/core/vpImage.h>
3 #include <visp3/gui/vpDisplayGDI.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/gui/vpDisplayX.h>
6 #include <visp3/sensor/vpPylonFactory.h>
8 #include "record_helper.h"
15 int main(
int argc,
const char *argv[])
17 #ifdef VISP_HAVE_PYLON
19 unsigned int opt_camera = 0;
20 std::string opt_device(
"GigE");
21 std::string opt_seqname;
22 int opt_record_mode = 0;
23 bool opt_change_settings =
false;
25 for (
int i = 0; i < argc; i++) {
26 if (std::string(argv[i]) ==
"--camera")
27 opt_camera = (
unsigned int)atoi(argv[i + 1]);
28 else if (std::string(argv[i]) ==
"--device")
29 opt_device = std::string(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]) ==
"--change_settings")
35 opt_change_settings =
true;
36 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
37 std::cout <<
"\nUsage: " << argv[0]
38 <<
" [--camera <0...9> (default: 0)] [--device <\"GigE\"|\"USB\" (default: GigE)>]"
39 <<
" [--seqname <sequence name (default: empty>] [--record <0: continuous | 1: single shot (default: 0)>]"
40 <<
" [--change_settings] [--help] [-h]\n"
41 <<
"\nExample to visualize images:\n"
42 <<
" " << argv[0] <<
" \n"
43 <<
" " << argv[0] <<
" --device GigE --camera 0\n"
44 <<
"\nExamples to record a sequence:\n"
45 <<
" " << argv[0] <<
" --seqname I%04d.png \n"
46 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 0\n"
47 <<
"\nExamples to record single shot images:\n"
48 <<
" " << argv[0] <<
" --seqname I%04d.png --record 1\n"
49 <<
" " << argv[0] <<
" --seqname folder/I%04d.png --record 1\n"
55 std::cout <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << std::endl;
56 std::cout <<
"Recording : " << (opt_seqname.empty() ?
"disabled" :
"enabled") << std::endl;
58 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
60 if (! opt_seqname.empty()) {
61 std::cout << text_record_mode << std::endl;
62 std::cout <<
"Record name: " << opt_seqname << std::endl;
70 if (opt_device ==
"GigE" || opt_device ==
"gige") {
72 std::cout <<
"Opening Basler GigE camera: " << opt_camera << std::endl;
73 }
else if (opt_device ==
"USB" || opt_device ==
"usb") {
75 std::cout <<
"Opening Basler USB camera: " << opt_camera << std::endl;
77 std::cout <<
"Error: only Basler GigE or USB cameras are supported." << std::endl;
84 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
88 #elif defined(VISP_HAVE_GDI)
90 #elif defined(VISP_HAVE_OPENCV)
93 std::cout <<
"No image viewer is available..." << std::endl;
103 quit = record_helper(opt_seqname, opt_record_mode, I);
105 std::stringstream ss;
111 std::cout <<
"Catch an exception: " << e << std::endl;
116 std::cout <<
"Install Basler Pylon SDK, configure and build ViSP again to use this example" << std::endl;