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> 7 #include <visp3/io/vpImageStorageWorker.h> 14 int main(
int argc,
const char *argv[])
16 #if defined(VISP_HAVE_PYLON) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 18 unsigned int opt_camera = 0;
19 std::string opt_device(
"GigE");
20 std::string opt_seqname;
21 int opt_record_mode = 0;
22 bool opt_change_settings =
false;
24 for (
int i = 0; i < argc; i++) {
25 if (std::string(argv[i]) ==
"--camera")
26 opt_camera = (
unsigned int)atoi(argv[i + 1]);
27 else if (std::string(argv[i]) ==
"--device")
28 opt_device = std::string(argv[i + 1]);
29 else if (std::string(argv[i]) ==
"--seqname")
30 opt_seqname = std::string(argv[i + 1]);
31 else if (std::string(argv[i]) ==
"--record")
32 opt_record_mode = std::atoi(argv[i + 1]);
33 else if (std::string(argv[i]) ==
"--change_settings")
34 opt_change_settings =
true;
35 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
36 std::cout <<
"\nUsage: " << argv[0]
37 <<
" [--camera <0...9> (default: 0)] [--device <\"GigE\"|\"USB\" (default: GigE)>]" 38 <<
" [--seqname <sequence name (default: empty)>] [--record <0: continuous | 1: single shot (default: 0)>]" 39 <<
" [--change_settings] [--help] [-h]\n" 40 <<
"\nExample to visualize images:\n" 41 <<
" " << argv[0] <<
" \n" 42 <<
" " << argv[0] <<
" --device GigE --camera 0\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 <<
"Settings : " << (opt_change_settings ?
"modified" :
"current") << 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;
69 if (opt_device ==
"GigE" || opt_device ==
"gige") {
71 std::cout <<
"Opening Basler GigE camera: " << opt_camera << std::endl;
72 }
else if (opt_device ==
"USB" || opt_device ==
"usb") {
74 std::cout <<
"Opening Basler USB camera: " << opt_camera << std::endl;
76 std::cout <<
"Error: only Basler GigE or USB cameras are supported." << std::endl;
83 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
87 #elif defined(VISP_HAVE_GDI) 89 #elif defined(VISP_HAVE_OPENCV) 92 std::cout <<
"No image viewer is available..." << std::endl;
106 quit = image_queue.record(I);
108 std::stringstream ss;
113 image_queue.cancel();
114 image_storage_thread.join();
116 std::cout <<
"Catch an exception: " << e << std::endl;
121 #ifndef VISP_HAVE_PYLON 122 std::cout <<
"Install Basler Pylon SDK, configure and build ViSP again to use this example" << std::endl;
124 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) 125 std::cout <<
"This turorial should be built with c++11 support" << std::endl;
virtual void open(vpImage< unsigned char > &I)=0
Display for windows using GDI (available on any windows 32 platform).
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...
error that can be emited by ViSP classes.
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
Factory singleton class to create vpPylonGrabber subclass instances.
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
virtual void acquire(vpImage< unsigned char > &I)=0
static vpPylonFactory & instance()
Get the vpPylonFactory singleton.
virtual void setCameraIndex(unsigned int index)=0
unsigned int getHeight() const
vpPylonGrabber * createPylonGrabber(DeviceClass dev_class)
Create an object of vpPylonGrabber.
unsigned int getWidth() const