Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
tutorial-mb-generic-tracker-rgbd-realsense.cpp
1 #include <iostream>
3 
4 #include <visp3/core/vpConfig.h>
5 
6 #if defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_OPENCV)
7 #include <visp3/core/vpDisplay.h>
8 #include <visp3/core/vpIoTools.h>
9 #include <visp3/core/vpXmlParserCamera.h>
10 #include <visp3/gui/vpDisplayX.h>
11 #include <visp3/gui/vpDisplayGDI.h>
12 #include <visp3/gui/vpDisplayOpenCV.h>
13 #include <visp3/mbt/vpMbGenericTracker.h>
14 #include <visp3/sensor/vpRealSense2.h>
15 #include <visp3/vision/vpKeyPoint.h>
16 
17 int main(int argc, char *argv[])
18 {
19  std::string config_color = "", config_depth = "";
20  std::string model_color = "", model_depth = "";
21  std::string init_file = "";
22  bool use_ogre = false;
23  bool use_scanline = false;
24  bool use_edges = true;
25  bool use_klt = false;
26  bool use_depth = true;
27  bool learn = false;
28  bool auto_init = false;
29  double proj_error_threshold = 25;
30  std::string learning_data = "learning/data-learned.bin";
31  bool display_projection_error = false;
32 
33  for (int i = 1; i < argc; i++) {
34  if (std::string(argv[i]) == "--config_color" && i+1 < argc) {
35  config_color = std::string(argv[i+1]);
36  } else if (std::string(argv[i]) == "--config_depth" && i+1 < argc) {
37  config_depth = std::string(argv[i+1]);
38  } else if (std::string(argv[i]) == "--model_color" && i+1 < argc) {
39  model_color = std::string(argv[i+1]);
40  } else if (std::string(argv[i]) == "--model_depth" && i+1 < argc) {
41  model_depth = std::string(argv[i+1]);
42  } else if (std::string(argv[i]) == "--init_file" && i+1 < argc) {
43  init_file = std::string(argv[i+1]);
44  } else if (std::string(argv[i]) == "--proj_error_threshold" && i+1 < argc) {
45  proj_error_threshold = std::atof(argv[i+1]);
46  } else if (std::string(argv[i]) == "--use_ogre") {
47  use_ogre = true;
48  } else if (std::string(argv[i]) == "--use_scanline") {
49  use_scanline = true;
50  } else if (std::string(argv[i]) == "--use_edges" && i+1 < argc) {
51  use_edges = (std::atoi(argv[i+1]) == 0 ? false : true);
52  } else if (std::string(argv[i]) == "--use_klt" && i+1 < argc) {
53  use_klt = (std::atoi(argv[i+1]) == 0 ? false : true);
54  } else if (std::string(argv[i]) == "--use_depth" && i+1 < argc) {
55  use_depth = (std::atoi(argv[i+1]) == 0 ? false : true);
56  } else if (std::string(argv[i]) == "--learn") {
57  learn = true;
58  } else if (std::string(argv[i]) == "--learning_data" && i+1 < argc) {
59  learning_data = argv[i+1];
60  } else if (std::string(argv[i]) == "--auto_init") {
61  auto_init = true;
62  } else if (std::string(argv[i]) == "--display_proj_error") {
63  display_projection_error = true;
64  } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
65  std::cout << "Usage: \n" << argv[0]
66  << " [--config_color <object.xml>] [--config_depth <object.xml>] [--model_color <object.cao>] [--model_depth <object.cao>]"
67  " [--init_file <object.init>] [--use_ogre] [--use_scanline]"
68  " [--proj_error_threshold <threshold between 0 and 90> (default: "<< proj_error_threshold << ")]"
69  " [--use_edges <0|1> (default: 1)] [--use_klt <0|1> (default: 0)] [--use_depth <0|1> (default: 1)]"
70  " [--learn] [--auto_init] [--learning_data <path to .bin> (default: learning/data-learned.bin)]"
71  " [--display_proj_error]" << std::endl;
72  std::cout << "\nExample to track a 4.2 cm width cube with manual initialization:\n" << argv[0]
73  << " --config_color cube.xml --config_depth cube_depth.xml"
74  << " --model_color cube.cao --model_depth cube.cao"
75  << " --init_file cube.init"
76  << " --use_edges 1 --use_klt 1 --use_depth 1"
77  << std::endl;
78  std::cout << "\nExample to learn the 4.2 cm width cube:\n" << argv[0]
79  << " --config_color cube.xml --config_depth cube_depth.xml"
80  << " --model_color cube.cao --model_depth cube.cao"
81  << " --init_file cube.init"
82  << " --use_edges 1 --use_klt 1 --use_depth 1"
83  << " --learn"
84  << std::endl;
85  std::cout << "\nExample to track a 4.2 cm width cube with initialization from learning database:\n" << argv[0]
86  << " --config_color cube.xml --config_depth cube_depth.xml"
87  << " --model_color cube.cao --model_depth cube.cao"
88  << " --init_file cube.init"
89  << " --use_edges 1 --use_klt 1 --use_depth 1"
90  << " --auto_init"
91  << std::endl;
92  return 0;
93  }
94  }
95 
96  std::cout << "Tracked features: " << std::endl;
97  std::cout << " Use edges : " << use_edges << std::endl;
98  std::cout << " Use klt : " << use_klt << std::endl;
99  std::cout << " Use depth : " << use_depth << std::endl;
100  std::cout << "Tracker options: " << std::endl;
101  std::cout << " Use ogre : " << use_ogre << std::endl;
102  std::cout << " Use scanline: " << use_scanline << std::endl;
103  std::cout << " Proj. error : " << proj_error_threshold << std::endl;
104  std::cout << " Display proj. error: " << display_projection_error << std::endl;
105  std::cout << "Config files: " << std::endl;
106  std::cout << " Config color: " << "\"" << config_color << "\"" << std::endl;
107  std::cout << " Config depth: " << "\"" << config_depth << "\"" << std::endl;
108  std::cout << " Model color : " << "\"" << model_color << "\"" << std::endl;
109  std::cout << " Model depth : " << "\"" << model_depth << "\"" << std::endl;
110  std::cout << " Init file : " << "\"" << init_file << "\"" << std::endl;
111  std::cout << "Learning options : " << std::endl;
112  std::cout << " Learn : " << learn << std::endl;
113  std::cout << " Auto init : " << auto_init << std::endl;
114  std::cout << " Learning data: " << learning_data << std::endl;
115 
116  if (!use_edges && !use_klt && !use_depth) {
117  std::cout << "You must choose at least one visual features between edge, KLT and depth." << std::endl;
118  return EXIT_FAILURE;
119  }
120 
121  if (config_color.empty() || config_depth.empty() || model_color.empty() || model_depth.empty() || init_file.empty()) {
122  std::cout << "config_color.empty() || config_depth.empty() || model_color.empty() || model_depth.empty() || init_file.empty()" << std::endl;
123  return EXIT_FAILURE;
124  }
125 
126  vpRealSense2 realsense;
127  int width = 640, height = 480;
128  int fps = 30;
129  rs2::config config;
130  config.enable_stream(RS2_STREAM_COLOR, width, height, RS2_FORMAT_RGBA8, fps);
131  config.enable_stream(RS2_STREAM_DEPTH, width, height, RS2_FORMAT_Z16, fps);
132 
133  try {
134  realsense.open(config);
135  }
136  catch (const vpException &e) {
137  std::cout << "Catch an exception: " << e.what() << std::endl;
138  std::cout << "Check if the Realsense camera is connected..." << std::endl;
139  return EXIT_SUCCESS;
140  }
141 
144 
145  std::cout << "Sensor internal camera parameters for color camera: " << cam_color << std::endl;
146  std::cout << "Sensor internal camera parameters for depth camera: " << cam_depth << std::endl;
147 
148  vpImage<vpRGBa> I_color(height, width);
149  vpImage<unsigned char> I_gray(height, width);
150  vpImage<unsigned char> I_depth(height, width);
151  vpImage<uint16_t> I_depth_raw(height, width);
152 
153  unsigned int _posx = 100, _posy = 50;
154 
155 #ifdef VISP_HAVE_X11
156  vpDisplayX d1, d2;
157 #elif defined(VISP_HAVE_GDI)
158  vpDisplayGDI d1, d2;
159 #elif defined(VISP_HAVE_OPENCV)
160  vpDisplayOpenCV d1, d2;
161 #endif
162  if (use_edges || use_klt)
163  d1.init(I_gray, _posx, _posy, "Color stream");
164  if (use_depth)
165  d2.init(I_depth, _posx + I_gray.getWidth()+10, _posy, "Depth stream");
166 
167  while (true) {
168  realsense.acquire((unsigned char *) I_color.bitmap, (unsigned char *) I_depth_raw.bitmap, NULL, NULL);
169 
170  if (use_edges || use_klt) {
171  vpImageConvert::convert(I_color, I_gray);
172  vpDisplay::display(I_gray);
173  vpDisplay::displayText(I_gray, 20, 20, "Click when ready.", vpColor::red);
174  vpDisplay::flush(I_gray);
175 
176  if (vpDisplay::getClick(I_gray, false)) {
177  break;
178  }
179  }
180  if (use_depth) {
181  vpImageConvert::createDepthHistogram(I_depth_raw, I_depth);
182 
183  vpDisplay::display(I_depth);
184  vpDisplay::displayText(I_depth, 20, 20, "Click when ready.", vpColor::red);
185  vpDisplay::flush(I_depth);
186 
187  if (vpDisplay::getClick(I_depth, false)) {
188  break;
189  }
190  }
191  }
192 
193  std::vector<int> trackerTypes;
194  if (use_edges && use_klt)
196  else if (use_edges)
197  trackerTypes.push_back(vpMbGenericTracker::EDGE_TRACKER );
198  else if (use_klt)
199  trackerTypes.push_back(vpMbGenericTracker::KLT_TRACKER);
200 
201  if (use_depth)
202  trackerTypes.push_back(vpMbGenericTracker::DEPTH_DENSE_TRACKER);
203 
204  vpHomogeneousMatrix depth_M_color = realsense.getTransformation(RS2_STREAM_COLOR, RS2_STREAM_DEPTH);
205  std::map<std::string, vpHomogeneousMatrix> mapOfCameraTransformations;
206  std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
207  std::map<std::string, std::string> mapOfInitFiles;
208  std::map<std::string, const std::vector<vpColVector> *> mapOfPointclouds;
209  std::map<std::string, unsigned int> mapOfWidths, mapOfHeights;
210  std::map<std::string, vpHomogeneousMatrix> mapOfCameraPoses;
211 
212  std::vector<vpColVector> pointcloud;
213 
214  vpMbGenericTracker tracker(trackerTypes);
215 
216  if ((use_edges || use_klt) && use_depth) {
217  tracker.loadConfigFile(config_color, config_depth);
218  tracker.loadModel(model_color, model_depth);
219  std::cout << "Sensor internal depth_M_color: \n" << depth_M_color << std::endl;
220  mapOfCameraTransformations["Camera2"] = depth_M_color;
221  tracker.setCameraTransformationMatrix(mapOfCameraTransformations);
222  mapOfImages["Camera1"] = &I_gray;
223  mapOfImages["Camera2"] = &I_depth;
224  mapOfInitFiles["Camera1"] = init_file;
225  tracker.setCameraParameters(cam_color, cam_depth);
226  }
227  else if (use_edges || use_klt) {
228  tracker.loadConfigFile(config_color);
229  tracker.loadModel(model_color);
230  tracker.setCameraParameters(cam_color);
231  }
232  else if (use_depth) {
233  tracker.loadConfigFile(config_depth);
234  tracker.loadModel(model_depth);
235  tracker.setCameraParameters(cam_depth);
236  }
237 
238  tracker.setDisplayFeatures(true);
239  tracker.setOgreVisibilityTest(use_ogre);
240  tracker.setScanLineVisibilityTest(use_scanline);
241  tracker.setProjectionErrorComputation(true);
242  tracker.setProjectionErrorDisplay(display_projection_error);
243 
244 #if (defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D))
245  std::string detectorName = "SIFT";
246  std::string extractorName = "SIFT";
247  std::string matcherName = "BruteForce";
248 #else
249  std::string detectorName = "FAST";
250  std::string extractorName = "ORB";
251  std::string matcherName = "BruteForce-Hamming";
252 #endif
253  vpKeyPoint keypoint;
254  if (learn || auto_init) {
255  keypoint.setDetector(detectorName);
256  keypoint.setExtractor(extractorName);
257  keypoint.setMatcher(matcherName);
258 #if !(defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D))
259 # if (VISP_HAVE_OPENCV_VERSION < 0x030000)
260  keypoint.setDetectorParameter("ORB", "nLevels", 1);
261 # else
262  cv::Ptr<cv::ORB> orb_detector = keypoint.getDetector("ORB").dynamicCast<cv::ORB>();
263  if (orb_detector) {
264  orb_detector->setNLevels(1);
265  }
266 # endif
267 #endif
268  }
269 
270  if (auto_init) {
271  if (!vpIoTools::checkFilename(learning_data)) {
272  std::cout << "Cannot enable auto detection. Learning file \"" << learning_data << "\" doesn't exist" << std::endl;
273  return EXIT_FAILURE;
274  }
275  keypoint.loadLearningData(learning_data, true);
276  } else {
277  if ((use_edges || use_klt) && use_depth)
278  tracker.initClick(mapOfImages, mapOfInitFiles, true);
279  else if (use_edges || use_klt)
280  tracker.initClick(I_gray, init_file, true);
281  else if (use_depth)
282  tracker.initClick(I_depth, init_file, true);
283 
284  if (learn)
286  }
287 
288 
289  bool run_auto_init = false;
290  if (auto_init) {
291  run_auto_init = true;
292  }
293  std::vector<double> times_vec;
294 
295  try {
296  //To be able to display keypoints matching with test-detection-rs2
297  int learn_id = 1;
298  bool quit = false;
299  bool learn_position = false;
300  double loop_t = 0;
302 
303  while (!quit) {
304  double t = vpTime::measureTimeMs();
305  bool tracking_failed = false;
306 
307  // Acquire images and update tracker input data
308  realsense.acquire((unsigned char *) I_color.bitmap, (unsigned char *) I_depth_raw.bitmap, &pointcloud, NULL, NULL);
309 
310  if (use_edges || use_klt || run_auto_init) {
311  vpImageConvert::convert(I_color, I_gray);
312  vpDisplay::display(I_gray);
313  }
314  if (use_depth) {
315  vpImageConvert::createDepthHistogram(I_depth_raw, I_depth);
316  vpDisplay::display(I_depth);
317  }
318 
319  if ((use_edges || use_klt) && use_depth) {
320  mapOfImages["Camera1"] = &I_gray;
321  mapOfPointclouds["Camera2"] = &pointcloud;
322  mapOfWidths["Camera2"] = width;
323  mapOfHeights["Camera2"] = height;
324  } else if (use_edges || use_klt) {
325  mapOfImages["Camera"] = &I_gray;
326  } else if (use_depth) {
327  mapOfPointclouds["Camera"] = &pointcloud;
328  mapOfWidths["Camera"] = width;
329  mapOfHeights["Camera"] = height;
330  }
331 
332  // Run auto initialization from learned data
333  if (run_auto_init) {
334  if (keypoint.matchPoint(I_gray, cam_color, cMo)) {
335  std::cout << "Auto init succeed" << std::endl;
336  if ((use_edges || use_klt) && use_depth) {
337  mapOfCameraPoses["Camera1"] = cMo;
338  mapOfCameraPoses["Camera2"] = depth_M_color *cMo;
339  tracker.initFromPose(mapOfImages, mapOfCameraPoses);
340  } else if (use_edges || use_klt) {
341  tracker.initFromPose(I_gray, cMo);
342  } else if (use_depth) {
343  tracker.initFromPose(I_depth, depth_M_color*cMo);
344  }
345  } else {
346  if (use_edges || use_klt) {
347  vpDisplay::flush(I_gray);
348  }
349  if (use_depth) {
350  vpDisplay::flush(I_depth);
351  }
352  continue;
353  }
354  }
355 
356  // Run the tracker
357  try {
358  if (run_auto_init) {
359  // Turn display features off just after auto init to not display wrong moving-edge if the tracker fails
360  tracker.setDisplayFeatures(false);
361 
362  run_auto_init = false;
363  }
364  if ((use_edges || use_klt) && use_depth) {
365  tracker.track(mapOfImages, mapOfPointclouds, mapOfWidths, mapOfHeights);
366  } else if (use_edges || use_klt) {
367  tracker.track(I_gray);
368  } else if (use_depth) {
369  tracker.track(mapOfImages, mapOfPointclouds, mapOfWidths, mapOfHeights);
370  }
371  } catch (const vpException &e) {
372  std::cout << "Tracker exception: " << e.getStringMessage() << std::endl;
373  tracking_failed = true;
374  if (auto_init) {
375  std::cout << "Tracker needs to restart (tracking exception)" << std::endl;
376  run_auto_init = true;
377  }
378  }
379 
380  // Get object pose
381  cMo = tracker.getPose();
382 
383  // Check tracking errors
384  double proj_error = 0;
385  if (tracker.getTrackerType() & vpMbGenericTracker::EDGE_TRACKER) {
386  // Check tracking errors
387  proj_error = tracker.getProjectionError();
388  }
389  else {
390  proj_error = tracker.computeCurrentProjectionError(I_gray, cMo, cam_color);
391  }
392 
393  if (auto_init && proj_error > proj_error_threshold) {
394  std::cout << "Tracker needs to restart (projection error detected: " << proj_error << ")" << std::endl;
395  run_auto_init = true;
396  tracking_failed = true;
397  }
398 
399  // Display tracking results
400  if (!tracking_failed) {
401  // Turn display features on
402  tracker.setDisplayFeatures(true);
403 
404  if ((use_edges || use_klt) && use_depth) {
405  tracker.display(I_gray, I_depth, cMo, depth_M_color*cMo, cam_color, cam_depth, vpColor::red, 3);
406  vpDisplay::displayFrame(I_gray, cMo, cam_color, 0.05, vpColor::none, 3);
407  vpDisplay::displayFrame(I_depth, depth_M_color*cMo, cam_depth, 0.05, vpColor::none, 3);
408  } else if (use_edges || use_klt) {
409  tracker.display(I_gray, cMo, cam_color, vpColor::red, 3);
410  vpDisplay::displayFrame(I_gray, cMo, cam_color, 0.05, vpColor::none, 3);
411  } else if (use_depth) {
412  tracker.display(I_depth, cMo, cam_depth, vpColor::red, 3);
413  vpDisplay::displayFrame(I_depth, cMo, cam_depth, 0.05, vpColor::none, 3);
414  }
415 
416  if (use_edges || use_klt) {
417  std::stringstream ss;
418  ss << "Nb features: " << tracker.getError().getRows();
419  vpDisplay::displayText(I_gray, 20, I_gray.getWidth() - 150, ss.str(), vpColor::red);
420  } else if (use_depth) {
421  std::stringstream ss;
422  ss << "Nb features: " << tracker.getError().getRows();
423  vpDisplay::displayText(I_depth, 20, I_depth.getWidth() - 150, ss.str(), vpColor::red);
424  }
425  }
426 
427  std::stringstream ss;
428  ss << "Loop time: " << loop_t << " ms";
429 
431  if (use_edges || use_klt) {
432  vpDisplay::displayText(I_gray, 20, 20, ss.str(), vpColor::red);
433  if (learn)
434  vpDisplay::displayText(I_gray, 35, 20, "Left click: learn Right click: quit", vpColor::red);
435  else if (auto_init)
436  vpDisplay::displayText(I_gray, 35, 20, "Left click: auto_init Right click: quit", vpColor::red);
437  else
438  vpDisplay::displayText(I_gray, 35, 20, "Right click: quit", vpColor::red);
439 
440  vpDisplay::flush(I_gray);
441 
442  if (vpDisplay::getClick(I_gray, button, false)) {
443  if (button == vpMouseButton::button3) {
444  quit = true;
445  } else if (button == vpMouseButton::button1 && learn) {
446  learn_position = true;
447  } else if (button == vpMouseButton::button1 && auto_init && !learn) {
448  run_auto_init = true;
449  }
450  }
451  }
452  if (use_depth) {
453  vpDisplay::displayText(I_depth, 20, 20, ss.str(), vpColor::red);
454  vpDisplay::displayText(I_depth, 40, 20, "Click to quit", vpColor::red);
455  vpDisplay::flush(I_depth);
456 
457  if (vpDisplay::getClick(I_depth, false)) {
458  quit = true;
459  }
460  }
461 
462  if (learn_position) {
463  // Detect keypoints on the current image
464  std::vector<cv::KeyPoint> trainKeyPoints;
465  keypoint.detect(I_gray, trainKeyPoints);
466 
467  // Keep only keypoints on the cube
468  std::vector<vpPolygon> polygons;
469  std::vector<std::vector<vpPoint> > roisPt;
470  std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > pair = tracker.getPolygonFaces();
471  polygons = pair.first;
472  roisPt = pair.second;
473 
474  // Compute the 3D coordinates
475  std::vector<cv::Point3f> points3f;
476  vpKeyPoint::compute3DForPointsInPolygons(cMo, cam_color, trainKeyPoints, polygons, roisPt, points3f);
477 
478  // Build the reference keypoints
479  keypoint.buildReference(I_gray, trainKeyPoints, points3f, true, learn_id++);
480 
481  // Display learned data
482  for (std::vector<cv::KeyPoint>::const_iterator it = trainKeyPoints.begin(); it != trainKeyPoints.end(); ++it) {
483  vpDisplay::displayCross(I_gray, (int)it->pt.y, (int)it->pt.x, 10, vpColor::yellow, 3);
484  }
485  learn_position = false;
486  std::cout << "Data learned" << std::endl;
487  }
488  loop_t = vpTime::measureTimeMs() - t;
489  times_vec.push_back(loop_t);
490  }
491  if (learn) {
492  std::cout << "Save learning file: " << learning_data << std::endl;
493  keypoint.saveLearningData(learning_data, true, true);
494  }
495  } catch (const vpException &e) {
496  std::cout << "Catch an exception: " << e.what() << std::endl;
497  }
498 
499  if (!times_vec.empty()) {
500  std::cout << "\nProcessing time, Mean: " << vpMath::getMean(times_vec) << " ms ; Median: " << vpMath::getMedian(times_vec)
501  << " ; Std: " << vpMath::getStdev(times_vec) << " ms" << std::endl;
502  }
503 
504  return EXIT_SUCCESS;
505 }
506 #elif defined(VISP_HAVE_REALSENSE2)
507 int main() {
508  std::cout << "Install OpenCV 3rd party, configure and build ViSP again to use this example" << std::endl;
509  return 0;
510 }
511 #else
512 int main() {
513  std::cout << "Install librealsense2 3rd party, configure and build ViSP again to use this example" << std::endl;
514  return 0;
515 }
516 #endif
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static double getStdev(const std::vector< double > &v, const bool useBesselCorrection=false)
Definition: vpMath.cpp:252
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static double getMedian(const std::vector< double > &v)
Definition: vpMath.cpp:222
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:129
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...
Definition: vpDisplayX.h:151
static const vpColor none
Definition: vpColor.h:192
error that can be emited by ViSP classes.
Definition: vpException.h:71
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void open(const rs2::config &cfg=rs2::config())
static std::string getParent(const std::string &pathname)
Definition: vpIoTools.cpp:1477
Real-time 6D object pose tracking using its CAD model.
static void flush(const vpImage< unsigned char > &I)
vpCameraParameters getCameraParameters(const rs2_stream &stream, vpCameraParameters::vpCameraParametersProjType type=vpCameraParameters::perspectiveProjWithDistortion) const
VISP_EXPORT double measureTimeMs()
Definition: vpTime.cpp:88
static const vpColor red
Definition: vpColor.h:180
static void makeDirectory(const char *dirname)
Definition: vpIoTools.cpp:597
static bool checkFilename(const char *filename)
Definition: vpIoTools.cpp:675
void setMatcher(const std::string &matcherName)
Definition: vpKeyPoint.h:868
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=NULL)
Definition: vpKeyPoint.cpp:528
static double getMean(const std::vector< double > &v)
Definition: vpMath.cpp:202
const char * what() const
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Generic class defining intrinsic camera parameters.
void setDetector(const vpFeatureDetectorType &detectorType)
Definition: vpKeyPoint.h:734
unsigned int buildReference(const vpImage< unsigned char > &I)
Definition: vpKeyPoint.cpp:236
void acquire(vpImage< unsigned char > &grey)
unsigned int matchPoint(const vpImage< unsigned char > &I)
vpHomogeneousMatrix getTransformation(const rs2_stream &from, const rs2_stream &to) const
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
void loadLearningData(const std::string &filename, const bool binaryMode=false, const bool append=false)
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))
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
Definition: vpKeyPoint.h:228
void saveLearningData(const std::string &filename, const bool binaryMode=false, const bool saveTrainingImages=true)
const std::string & getStringMessage(void) const
Send a reference (constant) related the error message (can be empty).
Definition: vpException.cpp:92
static const vpColor yellow
Definition: vpColor.h:188
cv::Ptr< cv::FeatureDetector > getDetector(const vpFeatureDetectorType &type) const
Definition: vpKeyPoint.h:461
void setExtractor(const vpFeatureDescriptorType &extractorType)
Definition: vpKeyPoint.h:792
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
void detect(const vpImage< unsigned char > &I, std::vector< cv::KeyPoint > &keyPoints, const vpRect &rectangle=vpRect())