simple.cpp
Go to the documentation of this file.
1 //command line parameters
2 #include "cmd_line/cmd_line.h"
3 
4 //detectors
7 
8 //tracking
11 #include "libauto_tracker/events.h"
12 
13 //visp includes
14 #include <visp/vpImageIo.h>
15 #include <visp/vpVideoReader.h>
16 #include <visp/vpMbEdgeKltTracker.h>
17 #include <visp/vpMbKltTracker.h>
18 #include <visp/vpMbEdgeTracker.h>
19 #include <visp/vpDisplayX.h>
20 
21 int main(int argc, char**argv)
22 {
23  //Parse command line arguments
24  CmdLine cmd(argc,argv);
25 
26  if(cmd.should_exit()) return 0; //exit if needed
27 
28  //Read video from a set of images, a single image or a camera
29  vpImage<vpRGBa> I;
30  vpVideoReader reader;
31  vpMbTracker* tracker;
32 
33  vpCameraParameters cam = cmd.get_cam_calib_params();
34  if(cmd.get_verbose())
35  std::cout << "loaded camera parameters:" << cam << std::endl;
36 
37  std::string filenames((cmd.get_data_dir() + cmd.get_input_file_pattern()));
38  if(cmd.get_verbose())
39  std::cout << "Loading: " << filenames << std::endl;
40  reader.setFileName( filenames.c_str() );
41 
42  reader.setFirstFrameIndex(2);
43  reader.open(I);
44 
45  //init display
46  vpDisplayX* d = new vpDisplayX();
47  d->init(I);
48  //init hybrid tracker
49  detectors::DetectorBase* detector = NULL;
50  if (cmd.get_detector_type() == CmdLine::ZBAR)
51  detector = new detectors::qrcode::Detector;
52  else if(cmd.get_detector_type() == CmdLine::DTMX)
53  detector = new detectors::datamatrix::Detector;
54 
55  if(cmd.get_tracker_type() == CmdLine::KLT)
56  tracker = new vpMbKltTracker();
57  else if(cmd.get_tracker_type() == CmdLine::KLT_MBT)
58  tracker = new vpMbEdgeKltTracker();
59  else if(cmd.get_tracker_type() == CmdLine::MBT)
60  tracker = new vpMbEdgeTracker();
61 
62  tracking::Tracker t(cmd,detector,tracker);
63 
64  t.start();
65  reader.acquire(I);
66 
67  t.process_event(tracking::select_input(I));
68  for(int iter=0;(iter<reader.getLastFrameIndex()-1); iter++){
69  reader.acquire(I);
70  t.process_event(tracking::input_ready(I,cam,iter));
71  }
72 
73  t.process_event(tracking::finished());
74 }
d
int main(int argc, char **argv)
Definition: simple.cpp:21
string cmd
bool get_verbose() const
Definition: cmd_line.cpp:238
std::string get_input_file_pattern() const
Definition: cmd_line.cpp:166
msm::back::state_machine< Tracker_ > Tracker
Definition: tracking.h:182
bool should_exit() const
Definition: cmd_line.cpp:226
vpCameraParameters get_cam_calib_params() const
Definition: cmd_line.cpp:154
std::string get_data_dir() const
Definition: cmd_line.cpp:262
TRACKER_TYPE get_tracker_type() const
Definition: cmd_line.cpp:314
DETECTOR_TYPE get_detector_type() const
Definition: cmd_line.cpp:307


visp_auto_tracker
Author(s): Filip Novotny
autogenerated on Sat Mar 13 2021 03:20:08