Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
tutorial-mb-generic-tracker-live.cpp
1 #include <visp3/core/vpConfig.h>
3 #ifdef VISP_HAVE_MODULE_SENSOR
4 #include <visp3/sensor/vp1394CMUGrabber.h>
5 #include <visp3/sensor/vp1394TwoGrabber.h>
6 #include <visp3/sensor/vpFlyCaptureGrabber.h>
7 #include <visp3/sensor/vpRealSense2.h>
8 #include <visp3/sensor/vpV4l2Grabber.h>
9 #endif
10 #include <visp3/core/vpIoTools.h>
11 #include <visp3/core/vpXmlParserCamera.h>
12 #include <visp3/gui/vpDisplayGDI.h>
13 #include <visp3/gui/vpDisplayOpenCV.h>
14 #include <visp3/gui/vpDisplayX.h>
15 #include <visp3/io/vpImageIo.h>
16 #include <visp3/vision/vpKeyPoint.h>
18 #include <visp3/mbt/vpMbGenericTracker.h>
20 
21 #if defined(HAVE_OPENCV_VIDEOIO)
22 #include <opencv2/videoio.hpp>
23 #endif
24 
26 // #undef VISP_HAVE_V4L2
27 // #undef VISP_HAVE_DC1394
28 // #undef VISP_HAVE_CMU1394
29 // #undef VISP_HAVE_FLYCAPTURE
30 // #undef VISP_HAVE_REALSENSE2
31 // #undef VISP_HAVE_OPENCV
33 
34 int main(int argc, char **argv)
35 {
36 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && \
37  (defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \
38  defined(HAVE_OPENCV_HIGHGUI) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2))
39 #ifdef ENABLE_VISP_NAMESPACE
40  using namespace VISP_NAMESPACE_NAME;
41 #endif
42 
43  try {
44  std::string opt_modelname = "model/teabox/teabox.cao";
45  int opt_tracker = 2;
46  int opt_device = 0; // For OpenCV and V4l2 grabber to set the camera device
47  double opt_proj_error_threshold = 30.;
48  bool opt_use_ogre = false;
49  bool opt_use_scanline = false;
50  bool opt_display_projection_error = false;
51  bool opt_learn = false;
52  bool opt_auto_init = false;
53  std::string opt_learning_data = "learning/data-learned.bin";
54  std::string opt_intrinsic_file = "";
55  std::string opt_camera_name = "";
56 
57  for (int i = 0; i < argc; i++) {
58  if (std::string(argv[i]) == "--model") {
59  opt_modelname = std::string(argv[i + 1]);
60  }
61  else if (std::string(argv[i]) == "--tracker") {
62  opt_tracker = atoi(argv[i + 1]);
63  }
64  else if (std::string(argv[i]) == "--camera_device" && i + 1 < argc) {
65  opt_device = atoi(argv[i + 1]);
66  }
67  else if (std::string(argv[i]) == "--max_proj_error") {
68  opt_proj_error_threshold = atof(argv[i + 1]);
69  }
70  else if (std::string(argv[i]) == "--use_ogre") {
71  opt_use_ogre = true;
72  }
73  else if (std::string(argv[i]) == "--use_scanline") {
74  opt_use_scanline = true;
75  }
76  else if (std::string(argv[i]) == "--learn") {
77  opt_learn = true;
78  }
79  else if (std::string(argv[i]) == "--learning_data" && i + 1 < argc) {
80  opt_learning_data = argv[i + 1];
81  }
82  else if (std::string(argv[i]) == "--auto_init") {
83  opt_auto_init = true;
84  }
85  else if (std::string(argv[i]) == "--display_proj_error") {
86  opt_display_projection_error = true;
87  }
88  else if (std::string(argv[i]) == "--intrinsic" && i + 1 < argc) {
89  opt_intrinsic_file = std::string(argv[i + 1]);
90  }
91  else if (std::string(argv[i]) == "--camera_name" && i + 1 < argc) {
92  opt_camera_name = std::string(argv[i + 1]);
93  }
94  else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
95  std::cout
96  << "\nUsage: " << argv[0] << " [--camera_device <camera device> (default: 0)]"
97  << " [--intrinsic <intrinsic file> (default: empty)]"
98  << " [--camera_name <camera name> (default: empty)]"
99  << " [--model <model name> (default: teabox)]"
100  << " [--tracker <0=egde|1=keypoint|2=hybrid> (default: 2)]"
101  << " [--use_ogre] [--use_scanline]"
102  << " [--max_proj_error <allowed projection error> (default: 30)]"
103  << " [--learn] [--auto_init] [--learning_data <data-learned.bin> (default: learning/data-learned.bin)]"
104  << " [--display_proj_error]"
105  << " [--help] [-h]\n"
106  << std::endl;
107  return EXIT_SUCCESS;
108  }
109  }
110  std::string parentname = vpIoTools::getParent(opt_modelname);
111  std::string objectname = vpIoTools::getNameWE(opt_modelname);
112 
113  if (!parentname.empty())
114  objectname = parentname + "/" + objectname;
115 
116  std::cout << "Tracker requested config files: " << objectname << ".[init, cao]" << std::endl;
117  std::cout << "Tracker optional config files: " << objectname << ".[ppm]" << std::endl;
118 
119  std::cout << "Tracked features: " << std::endl;
120  std::cout << " Use edges : " << (opt_tracker == 0 || opt_tracker == 2) << std::endl;
121  std::cout << " Use klt : " << (opt_tracker == 1 || opt_tracker == 2) << std::endl;
122  std::cout << "Tracker options: " << std::endl;
123  std::cout << " Use ogre : " << opt_use_ogre << std::endl;
124  std::cout << " Use scanline: " << opt_use_scanline << std::endl;
125  std::cout << " Proj. error : " << opt_proj_error_threshold << std::endl;
126  std::cout << " Display proj. error: " << opt_display_projection_error << std::endl;
127  std::cout << "Config files: " << std::endl;
128  std::cout << " Config file : "
129  << "\"" << objectname + ".xml"
130  << "\"" << std::endl;
131  std::cout << " Model file : "
132  << "\"" << objectname + ".cao"
133  << "\"" << std::endl;
134  std::cout << " Init file : "
135  << "\"" << objectname + ".init"
136  << "\"" << std::endl;
137  std::cout << "Learning options : " << std::endl;
138  std::cout << " Learn : " << opt_learn << std::endl;
139  std::cout << " Auto init : " << opt_auto_init << std::endl;
140  std::cout << " Learning data: " << opt_learning_data << std::endl;
141 
143 #if VISP_VERSION_INT > VP_VERSION_INT(3, 2, 0)
144  vpImage<vpRGBa> I; // Since ViSP 3.2.0 we support model-based tracking on color images
145 #else
146  vpImage<unsigned char> I; // Tracking on gray level images
147 #endif
149 
151  vpCameraParameters cam;
152  cam.initPersProjWithoutDistortion(839, 839, 325, 243);
154 
155 #if defined(VISP_HAVE_PUGIXML)
156  vpXmlParserCamera parser;
157  if (!opt_intrinsic_file.empty() && !opt_camera_name.empty()) {
158  parser.parse(cam, opt_intrinsic_file, opt_camera_name, vpCameraParameters::perspectiveProjWithoutDistortion);
159  }
160 #endif
161 
165 
167 #if defined(VISP_HAVE_V4L2)
168  vpV4l2Grabber g;
169  std::ostringstream device;
170  device << "/dev/video" << opt_device;
171  std::cout << "Use Video 4 Linux grabber on device " << device.str() << std::endl;
172  g.setDevice(device.str());
173  g.setScale(1);
174  g.open(I);
175 #elif defined(VISP_HAVE_DC1394)
176  (void)opt_device; // To avoid non used warning
177  std::cout << "Use DC1394 grabber" << std::endl;
179  g.open(I);
180 #elif defined(VISP_HAVE_CMU1394)
181  (void)opt_device; // To avoid non used warning
182  std::cout << "Use CMU1394 grabber" << std::endl;
184  g.open(I);
185 #elif defined(VISP_HAVE_FLYCAPTURE)
186  (void)opt_device; // To avoid non used warning
187  std::cout << "Use FlyCapture grabber" << std::endl;
189  g.open(I);
190 #elif defined(VISP_HAVE_REALSENSE2)
191  (void)opt_device; // To avoid non used warning
192  std::cout << "Use Realsense 2 grabber" << std::endl;
193  vpRealSense2 g;
194  rs2::config config;
195  config.disable_stream(RS2_STREAM_DEPTH);
196  config.disable_stream(RS2_STREAM_INFRARED);
197  config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
198  g.open(config);
199  g.acquire(I);
200 
201  std::cout << "Read camera parameters from Realsense device" << std::endl;
203 #elif defined(HAVE_OPENCV_VIDEOIO)
204  std::cout << "Use OpenCV grabber on device " << opt_device << std::endl;
205  cv::VideoCapture g(opt_device); // Open the default camera
206  if (!g.isOpened()) { // Check if we succeeded
207  std::cout << "Failed to open the camera" << std::endl;
208  return EXIT_FAILURE;
209  }
210  cv::Mat frame;
211  g >> frame; // get a new frame from camera
212  vpImageConvert::convert(frame, I);
213 #endif
215 
216  vpDisplay *display = nullptr;
217 #if defined(VISP_HAVE_X11)
218  display = new vpDisplayX;
219 #elif defined(VISP_HAVE_GDI)
220  display = new vpDisplayGDI;
221 #elif defined(HAVE_OPENCV_HIGHGUI)
222  display = new vpDisplayOpenCV;
223 #endif
224  display->init(I, 100, 100, "Model-based tracker");
225 
226  while (true) {
227 #if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \
228  defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
229  g.acquire(I);
230 #elif defined(HAVE_OPENCV_VIDEOIO)
231  g >> frame;
232  vpImageConvert::convert(frame, I);
233 #endif
234 
236  vpDisplay::displayText(I, 20, 20, "Click when ready.", vpColor::red);
237  vpDisplay::flush(I);
238 
239  if (vpDisplay::getClick(I, false)) {
240  break;
241  }
242  }
243 
245  vpMbGenericTracker tracker;
246  if (opt_tracker == 0)
248 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
249  else if (opt_tracker == 1)
250  tracker.setTrackerType(vpMbGenericTracker::KLT_TRACKER);
251  else
252  tracker.setTrackerType(vpMbGenericTracker::EDGE_TRACKER | vpMbGenericTracker::KLT_TRACKER);
253 #else
254  else {
255 #if !defined(VISP_HAVE_MODULE_KLT)
256  std::cout << "klt and hybrid model-based tracker are not available since visp_klt module is not available. "
257  "In CMakeGUI turn visp_klt module ON, configure and build ViSP again."
258  << std::endl;
259 #else
260  std::cout << "Hybrid tracking is impossible since OpenCV is not enabled. "
261  << "Install OpenCV, configure and build ViSP again to run this tutorial." << std::endl;
262 #endif
263  return EXIT_SUCCESS;
264  }
265 #endif
267 
268  bool usexml = false;
270 #if defined(VISP_HAVE_PUGIXML)
271  if (vpIoTools::checkFilename(objectname + ".xml")) {
272  tracker.loadConfigFile(objectname + ".xml");
273  usexml = true;
274  }
275 #endif
277 
278  if (!usexml) {
280  if (opt_tracker == 0 || opt_tracker == 2) {
282  vpMe me;
283  me.setMaskSize(5);
284  me.setMaskNumber(180);
285  me.setRange(8);
287  me.setThreshold(20);
288  me.setMu1(0.5);
289  me.setMu2(0.5);
290  me.setSampleStep(4);
291  tracker.setMovingEdge(me);
293  }
294 
295 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
296  if (opt_tracker == 1 || opt_tracker == 2) {
298  vpKltOpencv klt_settings;
299  klt_settings.setMaxFeatures(300);
300  klt_settings.setWindowSize(5);
301  klt_settings.setQuality(0.015);
302  klt_settings.setMinDistance(8);
303  klt_settings.setHarrisFreeParameter(0.01);
304  klt_settings.setBlockSize(3);
305  klt_settings.setPyramidLevels(3);
306  tracker.setKltOpencv(klt_settings);
307  tracker.setKltMaskBorder(5);
309  }
310 #endif
311  }
312 
313  tracker.setCameraParameters(cam);
315 
317  tracker.loadModel(objectname + ".cao");
320  tracker.setDisplayFeatures(true);
323  tracker.setOgreVisibilityTest(opt_use_ogre);
324  tracker.setScanLineVisibilityTest(opt_use_scanline);
327  tracker.setProjectionErrorComputation(true);
328  tracker.setProjectionErrorDisplay(opt_display_projection_error);
330 
331 #if (defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D)) || \
332  (VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)
333  std::string detectorName = "SIFT";
334  std::string extractorName = "SIFT";
335  std::string matcherName = "BruteForce";
336 #else
337  std::string detectorName = "FAST";
338  std::string extractorName = "ORB";
339  std::string matcherName = "BruteForce-Hamming";
340 #endif
341  vpKeyPoint keypoint;
342  if (opt_learn || opt_auto_init) {
343  keypoint.setDetector(detectorName);
344  keypoint.setExtractor(extractorName);
345  keypoint.setMatcher(matcherName);
346 #if !(defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D))
347 #if (VISP_HAVE_OPENCV_VERSION < 0x030000)
348  keypoint.setDetectorParameter("ORB", "nLevels", 1);
349 #else
350  cv::Ptr<cv::ORB> orb_detector = keypoint.getDetector("ORB").dynamicCast<cv::ORB>();
351  if (orb_detector) {
352  orb_detector->setNLevels(1);
353  }
354 #endif
355 #endif
356  }
357 
358  if (opt_auto_init) {
359  if (!vpIoTools::checkFilename(opt_learning_data)) {
360  std::cout << "Cannot enable auto detection. Learning file \"" << opt_learning_data << "\" doesn't exist"
361  << std::endl;
362  return EXIT_FAILURE;
363  }
364  keypoint.loadLearningData(opt_learning_data, true);
365  }
366  else {
367  tracker.initClick(I, objectname + ".init", true);
368  }
369 
370  bool learn_position = false;
371  bool run_auto_init = false;
372  if (opt_auto_init) {
373  run_auto_init = true;
374  }
375 
376  // To be able to display keypoints matching with test-detection-rs2
377  int learn_id = 1;
378  unsigned int learn_cpt = 0;
379  bool quit = false;
380  bool tracking_failed = false;
381 
382  while (!quit) {
383  double t_begin = vpTime::measureTimeMs();
384 #if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \
385  defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
386  g.acquire(I);
387 #elif defined(HAVE_OPENCV_VIDEOIO)
388  g >> frame;
389  vpImageConvert::convert(frame, I);
390 #endif
392 
393  // Run auto initialization from learned data
394  if (run_auto_init) {
395  tracking_failed = false;
396  if (keypoint.matchPoint(I, cam, cMo)) {
397  std::cout << "Auto init succeed" << std::endl;
398  tracker.initFromPose(I, cMo);
399  }
400  else {
401  vpDisplay::flush(I);
402  continue;
403  }
404  }
405  else if (tracking_failed) {
406  // Manual init
407  tracking_failed = false;
408  tracker.initClick(I, objectname + ".init", true);
409  }
410 
411  // Run the tracker
412  try {
413  if (run_auto_init) {
414  // Turn display features off just after auto init to not display wrong moving-edge if the tracker fails
415  tracker.setDisplayFeatures(false);
416 
417  run_auto_init = false;
418  }
419  tracker.track(I);
420  }
421  catch (const vpException &e) {
422  std::cout << "Tracker exception: " << e.getStringMessage() << std::endl;
423  tracking_failed = true;
424  if (opt_auto_init) {
425  std::cout << "Tracker needs to restart (tracking exception)" << std::endl;
426  run_auto_init = true;
427  }
428  }
429 
430  if (!tracking_failed) {
431  double proj_error = 0;
433  // Check tracking errors
434  proj_error = tracker.getProjectionError();
435  }
436  else {
437  tracker.getPose(cMo);
438  tracker.getCameraParameters(cam);
439  proj_error = tracker.computeCurrentProjectionError(I, cMo, cam);
440  }
441  if (proj_error > opt_proj_error_threshold) {
442  std::cout << "Tracker needs to restart (projection error detected: " << proj_error << ")" << std::endl;
443  if (opt_auto_init) {
444  run_auto_init = true;
445  }
446  tracking_failed = true;
447  }
448  }
449 
450  if (!tracking_failed) {
451  tracker.setDisplayFeatures(true);
453  tracker.getPose(cMo);
456  tracker.getCameraParameters(cam);
457  tracker.display(I, cMo, cam, vpColor::green, 2, false);
459  vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3);
460 
461  { // Display estimated pose in [m] and [deg]
462  vpPoseVector pose(cMo);
463  std::stringstream ss;
464  ss << "Translation: " << std::setprecision(5) << pose[0] << " " << pose[1] << " " << pose[2] << " [m]";
465  vpDisplay::displayText(I, 80, 20, ss.str(), vpColor::green);
466  ss.str(""); // erase ss
467  ss << "Rotation tu: " << std::setprecision(4) << vpMath::deg(pose[3]) << " " << vpMath::deg(pose[4]) << " "
468  << vpMath::deg(pose[5]) << " [deg]";
469  vpDisplay::displayText(I, 100, 20, ss.str(), vpColor::green);
470  }
471  {
472  std::stringstream ss;
473  ss << "Features: edges " << tracker.getNbFeaturesEdge() << ", klt " << tracker.getNbFeaturesKlt();
474  vpDisplay::displayText(I, 120, 20, ss.str(), vpColor::red);
475  }
476  }
477 
478  if (learn_position) {
479  learn_cpt++;
480  // Detect keypoints on the current image
481  std::vector<cv::KeyPoint> trainKeyPoints;
482  keypoint.detect(I, trainKeyPoints);
483 
484  // Keep only keypoints on the cube
485  std::vector<vpPolygon> polygons;
486  std::vector<std::vector<vpPoint> > roisPt;
487  std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > pair = tracker.getPolygonFaces();
488  polygons = pair.first;
489  roisPt = pair.second;
490 
491  // Compute the 3D coordinates
492  std::vector<cv::Point3f> points3f;
493  vpKeyPoint::compute3DForPointsInPolygons(cMo, cam, trainKeyPoints, polygons, roisPt, points3f);
494 
495  // Build the reference keypoints
496  keypoint.buildReference(I, trainKeyPoints, points3f, true, learn_id++);
497 
498  // Display learned data
499  for (std::vector<cv::KeyPoint>::const_iterator it = trainKeyPoints.begin(); it != trainKeyPoints.end(); ++it) {
500  vpDisplay::displayCross(I, (int)it->pt.y, (int)it->pt.x, 10, vpColor::yellow, 3);
501  }
502  learn_position = false;
503  std::cout << "Data learned" << std::endl;
504  }
505 
506  std::stringstream ss;
507  ss << "Loop time: " << vpTime::measureTimeMs() - t_begin << " ms";
508  vpDisplay::displayText(I, 20, 20, ss.str(), vpColor::red);
509  if (opt_learn)
510  vpDisplay::displayText(I, 35, 20, "Left click: learn Right click: quit", vpColor::red);
511  else if (opt_auto_init)
512  vpDisplay::displayText(I, 35, 20, "Left click: auto_init Right click: quit", vpColor::red);
513  else
514  vpDisplay::displayText(I, 35, 20, "Right click: quit", vpColor::red);
515 
517  if (vpDisplay::getClick(I, button, false)) {
518  if (button == vpMouseButton::button3) {
519  quit = true;
520  }
521  else if (button == vpMouseButton::button1 && opt_learn) {
522  learn_position = true;
523  }
524  else if (button == vpMouseButton::button1 && opt_auto_init && !opt_learn) {
525  run_auto_init = true;
526  }
527  }
528 
529  vpDisplay::flush(I);
530  }
531  if (opt_learn && learn_cpt) {
532  std::cout << "Save learning from " << learn_cpt << " images in file: " << opt_learning_data << std::endl;
533  keypoint.saveLearningData(opt_learning_data, true, true);
534  }
535 
537  delete display;
539  }
540  catch (const vpException &e) {
541  std::cout << "Catch a ViSP exception: " << e << std::endl;
542  }
543 #elif defined(VISP_HAVE_OPENCV)
544  (void)argc;
545  (void)argv;
546  std::cout << "Install a 3rd party dedicated to frame grabbing (dc1394, cmu1394, v4l2, OpenCV, FlyCapture, "
547  "Realsense2), configure and build ViSP again to use this example"
548  << std::endl;
549 #else
550  (void)argc;
551  (void)argv;
552  std::cout << "Install OpenCV 3rd party, configure and build ViSP again to use this example" << std::endl;
553 #endif
554  }
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void open(vpImage< unsigned char > &I)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void open(vpImage< unsigned char > &I)
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
static const vpColor red
Definition: vpColor.h:217
static const vpColor none
Definition: vpColor.h:229
static const vpColor yellow
Definition: vpColor.h:225
static const vpColor green
Definition: vpColor.h:220
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:130
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Class that defines generic functionalities for display.
Definition: vpDisplay.h:178
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0), const std::string &frameName="", const vpColor &textColor=vpColor::black, const vpImagePoint &textOffset=vpImagePoint(15, 15))
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
Definition: vpException.h:60
const std::string & getStringMessage() const
Definition: vpException.cpp:67
void open(vpImage< unsigned char > &I)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static bool checkFilename(const std::string &filename)
Definition: vpIoTools.cpp:786
static std::string getNameWE(const std::string &pathname)
Definition: vpIoTools.cpp:1227
static std::string getParent(const std::string &pathname)
Definition: vpIoTools.cpp:1314
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
Definition: vpKeyPoint.h:221
unsigned int matchPoint(const vpImage< unsigned char > &I)
void setExtractor(const vpFeatureDescriptorType &extractorType)
Definition: vpKeyPoint.h:1633
void loadLearningData(const std::string &filename, bool binaryMode=false, bool append=false)
void detect(const vpImage< unsigned char > &I, std::vector< cv::KeyPoint > &keyPoints, const vpRect &rectangle=vpRect())
Definition: vpKeyPoint.cpp:975
static void compute3DForPointsInPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, std::vector< cv::KeyPoint > &candidates, const std::vector< vpPolygon > &polygons, const std::vector< std::vector< vpPoint > > &roisPt, std::vector< cv::Point3f > &points, cv::Mat *descriptors=nullptr)
Definition: vpKeyPoint.cpp:465
void setMatcher(const std::string &matcherName)
Definition: vpKeyPoint.h:1709
void saveLearningData(const std::string &filename, bool binaryMode=false, bool saveTrainingImages=true)
void setDetector(const vpFeatureDetectorType &detectorType)
Definition: vpKeyPoint.h:1575
unsigned int buildReference(const vpImage< unsigned char > &I)
Definition: vpKeyPoint.cpp:194
cv::Ptr< cv::FeatureDetector > getDetector(const vpFeatureDetectorType &type) const
Definition: vpKeyPoint.h:1007
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:74
void setBlockSize(int blockSize)
Definition: vpKltOpencv.h:267
void setQuality(double qualityLevel)
Definition: vpKltOpencv.h:356
void setHarrisFreeParameter(double harris_k)
Definition: vpKltOpencv.h:275
void setMaxFeatures(int maxCount)
Definition: vpKltOpencv.h:315
void setMinDistance(double minDistance)
Definition: vpKltOpencv.h:324
void setWindowSize(int winSize)
Definition: vpKltOpencv.h:377
void setPyramidLevels(int pyrMaxLevel)
Definition: vpKltOpencv.h:343
static double deg(double rad)
Definition: vpMath.h:119
Real-time 6D object pose tracking using its CAD model.
virtual void setCameraParameters(const vpCameraParameters &camera) VP_OVERRIDE
virtual int getTrackerType() const
virtual void setOgreVisibilityTest(const bool &v) VP_OVERRIDE
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(bool orderPolygons=true, bool useVisibility=true, bool clipPolygon=false) VP_OVERRIDE
virtual void setProjectionErrorComputation(const bool &flag) VP_OVERRIDE
virtual void setDisplayFeatures(bool displayF) VP_OVERRIDE
virtual unsigned int getNbFeaturesEdge() const
virtual double computeCurrentProjectionError(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam) VP_OVERRIDE
virtual void getCameraParameters(vpCameraParameters &camera) const VP_OVERRIDE
virtual void initFromPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo) VP_OVERRIDE
virtual void getPose(vpHomogeneousMatrix &cMo) const VP_OVERRIDE
virtual unsigned int getNbFeaturesKlt() const
virtual void setMovingEdge(const vpMe &me)
virtual void track(const vpImage< unsigned char > &I) VP_OVERRIDE
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix()) VP_OVERRIDE
virtual void setTrackerType(int type)
virtual void setScanLineVisibilityTest(const bool &v) VP_OVERRIDE
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false) VP_OVERRIDE
virtual void loadConfigFile(const std::string &configFile, bool verbose=true) VP_OVERRIDE
virtual void setProjectionErrorDisplay(bool display) VP_OVERRIDE
virtual double getProjectionError() const
Definition: vpMbTracker.h:312
Definition: vpMe.h:134
void setMu1(const double &mu_1)
Definition: vpMe.h:385
void setRange(const unsigned int &range)
Definition: vpMe.h:415
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
Definition: vpMe.h:505
void setMaskNumber(const unsigned int &mask_number)
Definition: vpMe.cpp:552
void setThreshold(const double &threshold)
Definition: vpMe.h:466
void setSampleStep(const double &sample_step)
Definition: vpMe.h:422
void setMaskSize(const unsigned int &mask_size)
Definition: vpMe.cpp:560
void setMu2(const double &mu_2)
Definition: vpMe.h:392
@ NORMALIZED_THRESHOLD
Definition: vpMe.h:145
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:203
vpCameraParameters getCameraParameters(const rs2_stream &stream, vpCameraParameters::vpCameraParametersProjType type=vpCameraParameters::perspectiveProjWithDistortion, int index=-1) const
void acquire(vpImage< unsigned char > &grey, double *ts=nullptr)
bool open(const rs2::config &cfg=rs2::config())
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void open(vpImage< unsigned char > &I)
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
void setDevice(const std::string &devname)
XML parser to load and save intrinsic camera parameters.
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, unsigned int image_width=0, unsigned int image_height=0, bool verbose=true)
VISP_EXPORT double measureTimeMs()