Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
mbtGenericTracking.cpp
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Example of Hybrid Tracking of MBT and MBT KTL.
33 *
34*****************************************************************************/
35
43#include <iostream>
44#include <visp3/core/vpConfig.h>
45
46#if (defined(VISP_HAVE_MODULE_MBT) && defined(VISP_HAVE_DISPLAY)) && \
47 (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
48
49#include <visp3/core/vpDebug.h>
50#include <visp3/core/vpHomogeneousMatrix.h>
51#include <visp3/core/vpIoTools.h>
52#include <visp3/core/vpMath.h>
53#include <visp3/gui/vpDisplayD3D.h>
54#include <visp3/gui/vpDisplayGDI.h>
55#include <visp3/gui/vpDisplayGTK.h>
56#include <visp3/gui/vpDisplayOpenCV.h>
57#include <visp3/gui/vpDisplayX.h>
58#include <visp3/io/vpImageIo.h>
59#include <visp3/io/vpParseArgv.h>
60#include <visp3/io/vpVideoReader.h>
61#include <visp3/mbt/vpMbGenericTracker.h>
62
63#define GETOPTARGS "x:m:i:n:de:chtfColwvpT:"
64
65#define USE_XML 0
66
67void usage(const char *name, const char *badparam)
68{
69#if VISP_HAVE_DATASET_VERSION >= 0x030600
70 std::string ext("png");
71#else
72 std::string ext("pgm");
73#endif
74 fprintf(stdout, "\n\
75Example of tracking based on the 3D model.\n\
76\n\
77SYNOPSIS\n\
78 %s [-i <test image path>] [-x <config file>]\n\
79 [-m <model name>] [-n <initialisation file base name>] [-e <last frame index>]\n\
80 [-t] [-c] [-d] [-h] [-f] [-C] [-o] [-w] [-l] [-v] [-p]\n\
81 [-T <tracker type>]\n",
82 name);
83
84 fprintf(stdout, "\n\
85OPTIONS: \n\
86 -i <input image path> \n\
87 Set image input path.\n\
88 From this path read images \n\
89 \"mbt/cube/image%%04d.%s\". These \n\
90 images come from visp-images-x.y.z.tar.gz available \n\
91 on the ViSP website.\n\
92 Setting the VISP_INPUT_IMAGE_PATH environment\n\
93 variable produces the same behavior than using\n\
94 this option.\n\
95\n\
96 -x <config file> \n\
97 Set the config file (the xml file) to use.\n\
98 The config file is used to specify the parameters of the tracker.\n\
99\n\
100 -m <model name> \n\
101 Specify the name of the file of the model\n\
102 The model can either be a vrml model (.wrl) or a .cao file.\n\
103\n\
104 -e <last frame index> \n\
105 Specify the index of the last frame. Once reached, the tracking is stopped\n\
106\n\
107 -f \n\
108 Do not use the vrml model, use the .cao one. These two models are \n\
109 equivalent and comes from ViSP-images-x.y.z.tar.gz available on the ViSP\n\
110 website. However, the .cao model allows to use the 3d model based tracker \n\
111 without Coin.\n\
112\n\
113 -C \n\
114 Track only the cube (not the cylinder). In this case the models files are\n\
115 cube.cao or cube.wrl instead of cube_and_cylinder.cao and \n\
116 cube_and_cylinder.wrl.\n\
117\n\
118 -n <initialisation file base name> \n\
119 Base name of the initialisation file. The file will be 'base_name'.init .\n\
120 This base name is also used for the optional picture specifying where to \n\
121 click (a .ppm picture).\n\
122\n\
123 -t \n\
124 Turn off the display of the the moving edges and Klt points. \n\
125\n\
126 -d \n\
127 Turn off the display.\n\
128\n\
129 -c\n\
130 Disable the mouse click. Useful to automate the \n\
131 execution of this program without human intervention.\n\
132\n\
133 -o\n\
134 Use Ogre3D for visibility tests\n\
135\n\
136 -w\n\
137 When Ogre3D is enable [-o] show Ogre3D configuration dialog that allows to set the renderer.\n\
138\n\
139 -l\n\
140 Use the scanline for visibility tests.\n\
141\n\
142 -v\n\
143 Compute covariance matrix.\n\
144\n\
145 -p\n\
146 Compute gradient projection error.\n\
147\n\
148 -T <tracker type>\n\
149 Set tracker type (<1 (Edge)>, <2 (KLT)>, <3 (EdgeKlt)>).\n\
150\n\
151 -h \n\
152 Print the help.\n\n", ext.c_str());
153
154 if (badparam)
155 fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam);
156}
157
158bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile,
159 std::string &initFile, long &lastFrame, bool &displayFeatures, bool &click_allowed, bool &display,
160 bool &cao3DModel, bool &trackCylinder, bool &useOgre, bool &showOgreConfigDialog, bool &useScanline,
161 bool &computeCovariance, bool &projectionError, int &trackerType)
162{
163 const char *optarg_;
164 int c;
165 while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) {
166
167 switch (c) {
168 case 'e':
169 lastFrame = atol(optarg_);
170 break;
171 case 'i':
172 ipath = optarg_;
173 break;
174 case 'x':
175 configFile = optarg_;
176 break;
177 case 'm':
178 modelFile = optarg_;
179 break;
180 case 'n':
181 initFile = optarg_;
182 break;
183 case 't':
184 displayFeatures = false;
185 break;
186 case 'f':
187 cao3DModel = true;
188 break;
189 case 'c':
190 click_allowed = false;
191 break;
192 case 'd':
193 display = false;
194 break;
195 case 'C':
196 trackCylinder = false;
197 break;
198 case 'o':
199 useOgre = true;
200 break;
201 case 'l':
202 useScanline = true;
203 break;
204 case 'w':
205 showOgreConfigDialog = true;
206 break;
207 case 'v':
208 computeCovariance = true;
209 break;
210 case 'p':
211 projectionError = true;
212 break;
213 case 'T':
214 trackerType = atoi(optarg_);
215 break;
216 case 'h':
217 usage(argv[0], NULL);
218 return false;
219 break;
220
221 default:
222 usage(argv[0], optarg_);
223 return false;
224 break;
225 }
226 }
227
228 if ((c == 1) || (c == -1)) {
229 // standalone param or error
230 usage(argv[0], NULL);
231 std::cerr << "ERROR: " << std::endl;
232 std::cerr << " Bad argument " << optarg_ << std::endl << std::endl;
233 return false;
234 }
235
236 return true;
237}
238
239int main(int argc, const char **argv)
240{
241 try {
242 std::string env_ipath;
243 std::string opt_ipath;
244 std::string ipath;
245 std::string opt_configFile;
246 std::string opt_modelFile;
247 std::string modelFile;
248 std::string opt_initFile;
249 std::string initFile;
250 long opt_lastFrame = -1;
251 bool displayFeatures = true;
252 bool opt_click_allowed = true;
253 bool opt_display = true;
254 bool cao3DModel = false;
255 bool trackCylinder = true;
256 bool useOgre = false;
257 bool showOgreConfigDialog = false;
258 bool useScanline = false;
259 bool computeCovariance = false;
260 bool projectionError = false;
261 int trackerType = vpMbGenericTracker::EDGE_TRACKER;
262
263#if VISP_HAVE_DATASET_VERSION >= 0x030600
264 std::string ext("png");
265#else
266 std::string ext("pgm");
267#endif
268
269 // Get the visp-images-data package path or VISP_INPUT_IMAGE_PATH
270 // environment variable value
272
273 // Set the default input path
274 if (!env_ipath.empty())
275 ipath = env_ipath;
276
277 // Read the command line options
278 if (!getOptions(argc, argv, opt_ipath, opt_configFile, opt_modelFile, opt_initFile, opt_lastFrame, displayFeatures,
279 opt_click_allowed, opt_display, cao3DModel, trackCylinder, useOgre, showOgreConfigDialog,
280 useScanline, computeCovariance, projectionError, trackerType)) {
281 return EXIT_FAILURE;
282 }
283
284 // Test if an input path is set
285 if (opt_ipath.empty() && env_ipath.empty()) {
286 usage(argv[0], NULL);
287 std::cerr << std::endl << "ERROR:" << std::endl;
288 std::cerr << " Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
289 << " environment variable to specify the location of the " << std::endl
290 << " image path where test images are located." << std::endl
291 << std::endl;
292
293 return EXIT_FAILURE;
294 }
295
296 // Get the option values
297 if (!opt_ipath.empty())
298 ipath = vpIoTools::createFilePath(opt_ipath, "mbt/cube/image%04d." + ext);
299 else
300 ipath = vpIoTools::createFilePath(env_ipath, "mbt/cube/image%04d." + ext);
301
302#if USE_XML
303 std::string configFile;
304 if (!opt_configFile.empty())
305 configFile = opt_configFile;
306 else if (!opt_ipath.empty())
307 configFile = vpIoTools::createFilePath(opt_ipath, "mbt/cube.xml");
308 else
309 configFile = vpIoTools::createFilePath(env_ipath, "mbt/cube.xml");
310#endif
311
312 if (!opt_modelFile.empty()) {
313 modelFile = opt_modelFile;
314 }
315 else {
316 std::string modelFileCao;
317 std::string modelFileWrl;
318 if (trackCylinder) {
319 modelFileCao = "mbt/cube_and_cylinder.cao";
320 modelFileWrl = "mbt/cube_and_cylinder.wrl";
321 }
322 else {
323 modelFileCao = "mbt/cube.cao";
324 modelFileWrl = "mbt/cube.wrl";
325 }
326
327 if (!opt_ipath.empty()) {
328 if (cao3DModel) {
329 modelFile = vpIoTools::createFilePath(opt_ipath, modelFileCao);
330 }
331 else {
332#ifdef VISP_HAVE_COIN3D
333 modelFile = vpIoTools::createFilePath(opt_ipath, modelFileWrl);
334#else
335 std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl;
336 modelFile = vpIoTools::createFilePath(opt_ipath, modelFileCao);
337#endif
338 }
339 }
340 else {
341 if (cao3DModel) {
342 modelFile = vpIoTools::createFilePath(env_ipath, modelFileCao);
343 }
344 else {
345#ifdef VISP_HAVE_COIN3D
346 modelFile = vpIoTools::createFilePath(env_ipath, modelFileWrl);
347#else
348 std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl;
349 modelFile = vpIoTools::createFilePath(env_ipath, modelFileCao);
350#endif
351 }
352 }
353 }
354
355 if (!opt_initFile.empty())
356 initFile = opt_initFile;
357 else if (!opt_ipath.empty())
358 initFile = vpIoTools::createFilePath(opt_ipath, "mbt/cube");
359 else
360 initFile = vpIoTools::createFilePath(env_ipath, "mbt/cube");
361
363 vpVideoReader reader;
364
365 reader.setFileName(ipath);
366 try {
367 reader.open(I1);
368 I2 = I1;
369 }
370 catch (...) {
371 std::cerr << "Cannot open sequence: " << ipath << std::endl;
372 return EXIT_FAILURE;
373 }
374
375 if (opt_lastFrame > 1 && opt_lastFrame < reader.getLastFrameIndex())
376 reader.setLastFrameIndex(opt_lastFrame);
377
378 reader.acquire(I1);
379 I2 = I1;
380
381 // initialise a display
382#if defined(VISP_HAVE_X11)
383 vpDisplayX display1, display2;
384#elif defined(VISP_HAVE_GDI)
385 vpDisplayGDI display1, display2;
386#elif defined(HAVE_OPENCV_HIGHGUI)
387 vpDisplayOpenCV display1, display2;
388#elif defined(VISP_HAVE_D3D9)
389 vpDisplayD3D display1, display2;
390#elif defined(VISP_HAVE_GTK)
391 vpDisplayGTK display1, display2;
392#else
393 opt_display = false;
394#endif
395 if (opt_display) {
396#if defined(VISP_HAVE_DISPLAY)
399 display1.init(I1, 100, 100, "Test tracking (Left)");
400 display2.init(I2, (int)(I1.getWidth() / vpDisplay::getDownScalingFactor(I1)) + 110, 100, "Test tracking (Right)");
401#endif
406 }
407
408 // Object pointer to check that inheritance is ok
409 vpMbTracker *tracker = new vpMbGenericTracker(2, trackerType);
410 vpHomogeneousMatrix c1Mo, c2Mo;
411 vpCameraParameters cam1, cam2;
412
413 // Initialise the tracker: camera parameters, moving edge and KLT settings
414#if USE_XML
415 // From the xml file
416 dynamic_cast<vpMbGenericTracker *>(tracker)->loadConfigFile(configFile, configFile);
417#else
418 // By setting the parameters:
419 cam1.initPersProjWithoutDistortion(547, 542, 338, 234);
420 cam2.initPersProjWithoutDistortion(547, 542, 338, 234);
421
422 vpMe me;
423 me.setMaskSize(5);
424 me.setMaskNumber(180);
425 me.setRange(7);
427 me.setThreshold(10);
428 me.setMu1(0.5);
429 me.setMu2(0.5);
430 me.setSampleStep(4);
431
432#if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
433 vpKltOpencv klt;
434 klt.setMaxFeatures(10000);
435 klt.setWindowSize(5);
436 klt.setQuality(0.01);
437 klt.setMinDistance(5);
438 klt.setHarrisFreeParameter(0.01);
439 klt.setBlockSize(3);
440 klt.setPyramidLevels(3);
441
442 dynamic_cast<vpMbGenericTracker *>(tracker)->setKltOpencv(klt);
443 dynamic_cast<vpMbGenericTracker *>(tracker)->setKltMaskBorder(5);
444#endif
445
446 dynamic_cast<vpMbGenericTracker *>(tracker)->setCameraParameters(cam1, cam2);
447 dynamic_cast<vpMbGenericTracker *>(tracker)->setMovingEdge(me);
448
449 tracker->setAngleAppear(vpMath::rad(65));
450 tracker->setAngleDisappear(vpMath::rad(75));
451
452 // Specify the clipping to
453 tracker->setNearClippingDistance(0.01);
454 tracker->setFarClippingDistance(0.90);
456 // tracker->setClipping(tracker->getClipping() | vpMbtPolygon::LEFT_CLIPPING
457 // | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING |
458 // vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING
459#endif
460
461 // Display the moving edges, and the Klt points
462 tracker->setDisplayFeatures(displayFeatures);
463
464 // Tells if the tracker has to use Ogre3D for visibility tests
465 tracker->setOgreVisibilityTest(useOgre);
466 if (useOgre)
467 tracker->setOgreShowConfigDialog(showOgreConfigDialog);
468
469 // Tells if the tracker has to use the scanline visibility tests
470 tracker->setScanLineVisibilityTest(useScanline);
471
472 // Tells if the tracker has to compute the covariance matrix
473 tracker->setCovarianceComputation(computeCovariance);
474
475 // Tells if the tracker has to compute the projection error
476 tracker->setProjectionErrorComputation(projectionError);
477
478 // Retrieve the camera parameters from the tracker
479 dynamic_cast<vpMbGenericTracker *>(tracker)->getCameraParameters(cam1, cam2);
480
481 // Loop to position the cube
482 if (opt_display && opt_click_allowed) {
483 while (!vpDisplay::getClick(I1, false)) {
485 vpDisplay::displayText(I1, 15, 10, "click after positioning the object", vpColor::red);
487 }
488 }
489
490 // Load the 3D model (either a vrml file or a .cao file)
491 tracker->loadModel(modelFile);
492
493 // Initialise the tracker by clicking on the image
494 // This function looks for
495 // - a ./cube/cube.init file that defines the 3d coordinates (in meter,
496 // in the object basis) of the points used for the initialisation
497 // - a ./cube/cube.ppm file to display where the user have to click
498 // (Optional, set by the third parameter)
499 if (opt_display && opt_click_allowed) {
500 dynamic_cast<vpMbGenericTracker *>(tracker)->initClick(I1, I2, initFile, initFile, true);
501 dynamic_cast<vpMbGenericTracker *>(tracker)->getPose(c1Mo, c2Mo);
502 // display the 3D model at the given pose
503 dynamic_cast<vpMbGenericTracker *>(tracker)->display(I1, I2, c1Mo, c2Mo, cam1, cam2, vpColor::red);
504 }
505 else {
506 vpHomogeneousMatrix c1Moi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872);
507 vpHomogeneousMatrix c2Moi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872);
508 dynamic_cast<vpMbGenericTracker *>(tracker)->initFromPose(I1, I2, c1Moi, c2Moi);
509 }
510
511 // track the model
512 dynamic_cast<vpMbGenericTracker *>(tracker)->track(I1, I2);
513 dynamic_cast<vpMbGenericTracker *>(tracker)->getPose(c1Mo, c2Mo);
514
515 if (opt_display) {
518 }
519
520 bool quit = false, click = false;
521 while (!reader.end() && !quit) {
522 // acquire a new image
523 reader.acquire(I1);
524 I2 = I1;
525 // display the image
526 if (opt_display) {
529
530 std::stringstream ss;
531 ss << "Num frame: " << reader.getFrameIndex() << "/" << reader.getLastFrameIndex();
532 vpDisplay::displayText(I1, 40, 20, ss.str(), vpColor::red);
533 }
534
535 // Test to reset the tracker
536 if (reader.getFrameIndex() == reader.getFirstFrameIndex() + 10) {
537 std::cout << "----------Test reset tracker----------" << std::endl;
538 if (opt_display) {
541 }
542
543 tracker->resetTracker();
544#if USE_XML
545 dynamic_cast<vpMbGenericTracker *>(tracker)->loadConfigFile(configFile, configFile);
546#else
547 // By setting the parameters:
548 cam1.initPersProjWithoutDistortion(547, 542, 338, 234);
549 cam2.initPersProjWithoutDistortion(547, 542, 338, 234);
550
551 me.setMaskSize(5);
552 me.setMaskNumber(180);
553 me.setRange(7);
555 me.setThreshold(10);
556 me.setMu1(0.5);
557 me.setMu2(0.5);
558 me.setSampleStep(4);
559
560#if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
561 klt.setMaxFeatures(10000);
562 klt.setWindowSize(5);
563 klt.setQuality(0.01);
564 klt.setMinDistance(5);
565 klt.setHarrisFreeParameter(0.01);
566 klt.setBlockSize(3);
567 klt.setPyramidLevels(3);
568
569 dynamic_cast<vpMbGenericTracker *>(tracker)->setKltOpencv(klt);
570 dynamic_cast<vpMbGenericTracker *>(tracker)->setKltMaskBorder(5);
571#endif
572
573 dynamic_cast<vpMbGenericTracker *>(tracker)->setCameraParameters(cam1, cam2);
574 dynamic_cast<vpMbGenericTracker *>(tracker)->setMovingEdge(me);
575 tracker->setAngleAppear(vpMath::rad(65));
576 tracker->setAngleDisappear(vpMath::rad(75));
577
578 // Specify the clipping to
579 tracker->setNearClippingDistance(0.01);
580 tracker->setFarClippingDistance(0.90);
582 // tracker->setClipping(tracker->getClipping() | vpMbtPolygon::LEFT_CLIPPING
583 // | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING |
584 // vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING
585#endif
586 tracker->loadModel(modelFile);
587 dynamic_cast<vpMbGenericTracker *>(tracker)->setCameraParameters(cam1, cam2);
588 tracker->setOgreVisibilityTest(useOgre);
589 tracker->setScanLineVisibilityTest(useScanline);
590 tracker->setCovarianceComputation(computeCovariance);
591 tracker->setProjectionErrorComputation(projectionError);
592 dynamic_cast<vpMbGenericTracker *>(tracker)->initFromPose(I1, I2, c1Mo, c2Mo);
593 }
594
595 // Test to set an initial pose
596 if (reader.getFrameIndex() == reader.getFirstFrameIndex() + 50) {
597 c1Mo.buildFrom(0.0439540832, 0.0845870108, 0.5477322481, 2.179498458, 0.8611798108, -0.3491961946);
598 c2Mo.buildFrom(0.0439540832, 0.0845870108, 0.5477322481, 2.179498458, 0.8611798108, -0.3491961946);
599 std::cout << "Test set pose" << std::endl;
600 dynamic_cast<vpMbGenericTracker *>(tracker)->setPose(I1, I2, c1Mo, c2Mo);
601 }
602
603 // track the object: stop tracking from frame 40 to 50
604 if (reader.getFrameIndex() - reader.getFirstFrameIndex() < 40 ||
605 reader.getFrameIndex() - reader.getFirstFrameIndex() >= 50) {
606 dynamic_cast<vpMbGenericTracker *>(tracker)->track(I1, I2);
607 dynamic_cast<vpMbGenericTracker *>(tracker)->getPose(c1Mo, c2Mo);
608 if (opt_display) {
609 // display the 3D model
610 dynamic_cast<vpMbGenericTracker *>(tracker)->display(I1, I2, c1Mo, c2Mo, cam1, cam2, vpColor::darkRed);
611 // display the frame
612 vpDisplay::displayFrame(I1, c1Mo, cam1, 0.05);
613 vpDisplay::displayFrame(I2, c2Mo, cam2, 0.05);
614 }
615 }
616
617 if (opt_click_allowed && opt_display) {
618 vpDisplay::displayText(I1, 10, 10, "Click to quit", vpColor::red);
620 if (vpDisplay::getClick(I1, button, click)) {
621 switch (button) {
623 quit = !click;
624 break;
625
627 click = !click;
628 break;
629
630 default:
631 break;
632 }
633 }
634 }
635
636 if (computeCovariance) {
637 std::cout << "Covariance matrix: \n" << tracker->getCovarianceMatrix() << std::endl << std::endl;
638 }
639
640 if (projectionError) {
641 std::cout << "Projection error: " << tracker->getProjectionError() << std::endl << std::endl;
642 }
643
644 if (opt_display) {
647 }
648 }
649
650 std::cout << "Reached last frame: " << reader.getFrameIndex() << std::endl;
651 std::cout << "\nFinal poses, c1Mo:\n" << c1Mo << "\nc2Mo:\n" << c2Mo << std::endl;
652
653 if (opt_click_allowed && !quit) {
655 }
656 reader.close();
657
658 delete tracker;
659 tracker = NULL;
660
661 return EXIT_SUCCESS;
662 }
663 catch (const vpException &e) {
664 std::cout << "Catch an exception: " << e << std::endl;
665 return EXIT_FAILURE;
666 }
667}
668
669#elif !(defined(VISP_HAVE_MODULE_MBT) && defined(VISP_HAVE_DISPLAY))
670int main()
671{
672 std::cout << "Cannot run this example: visp_mbt, visp_gui modules are required." << std::endl;
673 return EXIT_SUCCESS;
674}
675#else
676int main()
677{
678 std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
679 return EXIT_SUCCESS;
680}
681#endif
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
static const vpColor red
Definition vpColor.h:211
static const vpColor darkRed
Definition vpColor.h:212
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
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:132
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="")
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
virtual void setDownScalingFactor(unsigned int scale)
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 flush(const vpImage< unsigned char > &I)
unsigned int getDownScalingFactor()
Definition vpDisplay.h:231
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
Implementation of an homogeneous matrix and operations on such kind of matrices.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Definition of the vpImage class member functions.
Definition vpImage.h:135
unsigned int getWidth() const
Definition vpImage.h:242
static std::string getViSPImagesDataPath()
static std::string createFilePath(const std::string &parent, const std::string &child)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition vpKltOpencv.h:73
void setBlockSize(int blockSize)
void setQuality(double qualityLevel)
void setHarrisFreeParameter(double harris_k)
void setMaxFeatures(int maxCount)
void setMinDistance(double minDistance)
void setWindowSize(int winSize)
void setPyramidLevels(int pyrMaxLevel)
static double rad(double deg)
Definition vpMath.h:116
Real-time 6D object pose tracking using its CAD model.
Main methods for a model-based tracker.
virtual void resetTracker()=0
virtual void setOgreShowConfigDialog(bool showConfigDialog)
virtual void setDisplayFeatures(bool displayF)
virtual void setAngleDisappear(const double &a)
virtual void setCovarianceComputation(const bool &flag)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setOgreVisibilityTest(const bool &v)
virtual vpMatrix getCovarianceMatrix() const
virtual void setNearClippingDistance(const double &dist)
virtual void setFarClippingDistance(const double &dist)
virtual double getProjectionError() const
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setClipping(const unsigned int &flags)
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setAngleAppear(const double &a)
virtual unsigned int getClipping() const
Definition vpMe.h:122
void setMu1(const double &mu_1)
Definition vpMe.h:353
void setSampleStep(const double &s)
Definition vpMe.h:390
void setRange(const unsigned int &r)
Definition vpMe.h:383
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
Definition vpMe.h:445
void setMaskSize(const unsigned int &a)
Definition vpMe.cpp:452
void setMu2(const double &mu_2)
Definition vpMe.h:360
@ NORMALIZED_THRESHOLD
Easy-to-use normalized likelihood threshold corresponding to the minimal luminance contrast to consid...
Definition vpMe.h:132
void setMaskNumber(const unsigned int &a)
Definition vpMe.cpp:445
void setThreshold(const double &t)
Definition vpMe.h:435
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void setLastFrameIndex(const long last_frame)
long getLastFrameIndex()
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
long getFirstFrameIndex()
long getFrameIndex() const