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