Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMbEdgeMultiTracker.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2016 by INRIA. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact INRIA about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
17  *
18  * This software was developed at:
19  * INRIA Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  * http://www.irisa.fr/lagadic
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  *
32  * Description:
33  * Model-based edge tracker with multiple cameras.
34  *
35  * Authors:
36  * Souriya Trinh
37  *
38  *****************************************************************************/
39 
45 #ifndef __vpMbEdgeMultiTracker_h__
46 #define __vpMbEdgeMultiTracker_h__
47 
48 #include <iostream>
49 #include <vector>
50 
51 #include <visp3/mbt/vpMbEdgeTracker.h>
52 #include <visp3/core/vpRobust.h>
53 
67 class VISP_EXPORT vpMbEdgeMultiTracker: public vpMbEdgeTracker
68 {
69 protected:
71  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
72 
74  std::map<std::string, vpMbEdgeTracker*> m_mapOfEdgeTrackers;
75 
77  std::map<std::string, std::vector<const vpImage<unsigned char>* > > m_mapOfPyramidalImages;
78 
80  std::string m_referenceCameraName;
81 
82 
83 public:
84  // Default constructor <==> equivalent to vpMbEdgeTracker
86  // Constructor with a specified number of cameras, camera names are generated
87  vpMbEdgeMultiTracker(const unsigned int nbCameras);
88  // Constructor with a specified list of camera names
89  vpMbEdgeMultiTracker(const std::vector<std::string> &cameraNames);
90 
91  virtual ~vpMbEdgeMultiTracker();
92 
95  virtual void display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
96  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
97 
98  virtual void display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
99  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
100 
101  virtual void display(const vpImage<unsigned char>& I1, const vpImage<unsigned char>& I2, const vpHomogeneousMatrix &c1Mo,
102  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
103  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
104 
105  virtual void display(const vpImage<vpRGBa>& I1, const vpImage<vpRGBa>& I2, const vpHomogeneousMatrix &c1Mo,
106  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
107  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
108 
109  virtual void display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
110  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
111  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
112  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
113 
114  virtual void display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
115  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
116  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
117  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel=false);
118 
119  virtual std::vector<std::string> getCameraNames() const;
120 
121  virtual void getCameraParameters(vpCameraParameters &camera) const;
122  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
123  virtual void getCameraParameters(const std::string &cameraName, vpCameraParameters &camera) const;
124  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
125 
127  virtual unsigned int getClipping(const std::string &cameraName) const;
128 
130  virtual vpMbHiddenFaces<vpMbtPolygon>& getFaces(const std::string &cameraName);
131  virtual std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > getFaces() const;
132 
133  void getLcircle(std::list<vpMbtDistanceCircle *>& circlesList, const unsigned int level=0) const;
134  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *>& circlesList,
135  const unsigned int level=0) const;
136 
137  void getLcylinder(std::list<vpMbtDistanceCylinder *>& cylindersList, const unsigned int level=0) const;
138  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *>& cylindersList,
139  const unsigned int level=0) const;
140 
141  void getLline(std::list<vpMbtDistanceLine *>& linesList, const unsigned int level=0) const;
142  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *>& linesList,
143  const unsigned int level=0) const;
144 
145  virtual void getMovingEdge(vpMe &p_me) const;
146  virtual vpMe getMovingEdge() const;
147  virtual void getMovingEdge(const std::string &cameraName, vpMe &p_me) const;
148  virtual vpMe getMovingEdge(const std::string &cameraName) const;
149 
150  virtual unsigned int getNbPoints(const unsigned int level=0) const;
151  virtual unsigned int getNbPoints(const std::string &cameraName, const unsigned int level=0) const;
152 
153 
154  virtual unsigned int getNbPolygon() const;
155  virtual unsigned int getNbPolygon(const std::string &cameraName) const;
156  virtual std::map<std::string, unsigned int> getMultiNbPolygon() const;
157 
163  inline unsigned int getNumberOfCameras() const {
164  return (unsigned int) m_mapOfEdgeTrackers.size();
165  }
166 
167  using vpMbTracker::getPose;
168  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
169  virtual void getPose(const std::string &cameraName, vpHomogeneousMatrix &cMo_) const;
170  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
171 
172  void init(const vpImage<unsigned char>& I);
173 
174 #ifdef VISP_HAVE_MODULE_GUI
175  virtual void initClick(const vpImage<unsigned char>& I, const std::vector<vpPoint> &points3D_list,
176  const std::string &displayFile="");
177 
178  virtual void initClick(const vpImage<unsigned char>& I, const std::string& initFile, const bool displayHelp=false);
179 
180  virtual void initClick(const vpImage<unsigned char>& I1, const vpImage<unsigned char> &I2,
181  const std::string& initFile1, const std::string& initFile2, const bool displayHelp=false,
182  const bool firstCameraIsReference=true);
183 
184  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
185  const std::string &initFile, const bool displayHelp=false);
186 
187  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
188  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp=false);
189 #endif
190 
191  virtual void initFromPose(const vpImage<unsigned char>& I, const std::string &initFile);
192  virtual void initFromPose(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo);
193  virtual void initFromPose(const vpImage<unsigned char>& I, const vpPoseVector &cPo);
194 
195  virtual void initFromPose(const vpImage<unsigned char>& I1, const vpImage<unsigned char>& I2,
196  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo, const bool firstCameraIsReference=true);
197  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
198  const vpHomogeneousMatrix &cMo_);
199  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
200  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
201 
202  virtual void loadConfigFile(const std::string &configFile);
203 
204  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2,
205  const bool firstCameraIsReference=true);
206 
207  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
208 
209  virtual void loadModel(const std::string &modelFile, const bool verbose=false);
210 
211  virtual void reInitModel(const vpImage<unsigned char>& I, const std::string &cad_name, const vpHomogeneousMatrix& cMo_,
212  const bool verbose=false);
213  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
214  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
215  const bool verbose=false, const bool firstCameraIsReference=true);
216  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
217  const std::string &cad_name, const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
218  const bool verbose=false);
219 
220  virtual void resetTracker();
221 
222  virtual void setAngleAppear(const double &a);
223  virtual void setAngleDisappear(const double &a);
224 
225  virtual void setCameraParameters(const vpCameraParameters& camera);
226 
227  virtual void setCameraParameters(const vpCameraParameters& camera1, const vpCameraParameters& camera2,
228  const bool firstCameraIsReference=true);
229 
230  virtual void setCameraParameters(const std::string &cameraName, const vpCameraParameters& camera);
231 
232  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
233 
234  virtual void setCameraTransformationMatrix(const std::string &cameraName,
235  const vpHomogeneousMatrix &cameraTransformationMatrix);
236 
237  virtual void setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
238 
239  virtual void setClipping(const unsigned int &flags);
240  virtual void setClipping(const std::string &cameraName, const unsigned int &flags);
241 
242  virtual void setCovarianceComputation(const bool& flag);
243 
244  virtual void setDisplayFeatures(const bool displayF);
245 
246  virtual void setFarClippingDistance(const double &dist);
247  virtual void setFarClippingDistance(const std::string &cameraName, const double &dist);
248 
249  virtual void setGoodMovingEdgesRatioThreshold(const double threshold);
250 
251 #ifdef VISP_HAVE_OGRE
252 
259  void setGoodNbRayCastingAttemptsRatio(const double &ratio);
260 
269  void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
270 #endif
271 
272  virtual void setLod(const bool useLod, const std::string &name="");
273  virtual void setLod(const bool useLod, const std::string &cameraName, const std::string &name);
274 
275  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="");
276  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
277  const std::string &name);
278 
279  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="");
280  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
281  const std::string &name);
282 
283  virtual void setMovingEdge(const vpMe &me);
284  virtual void setMovingEdge(const std::string &cameraName, const vpMe &me);
285 
286  virtual void setNearClippingDistance(const double &dist);
287  virtual void setNearClippingDistance(const std::string &cameraName, const double &dist);
288 
299  virtual void setOgreShowConfigDialog(const bool showConfigDialog);
300 
301  virtual void setOgreVisibilityTest(const bool &v);
302 
303  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
304 
305  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
306 
307  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2, const vpHomogeneousMatrix &c1Mo,
308  const vpHomogeneousMatrix c2Mo, const bool firstCameraIsReference=true);
309 
310  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
311  const vpHomogeneousMatrix &cMo_);
312 
313  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
314  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
315 
316  virtual void setProjectionErrorComputation(const bool &flag);
317 
318  virtual void setReferenceCameraName(const std::string &referenceCameraName);
319 
320  virtual void setScales(const std::vector<bool>& scales);
321 
322  virtual void setScanLineVisibilityTest(const bool &v);
323 
324  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
325 
326  virtual void track(const vpImage<unsigned char> &I);
327  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
328  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
330 
331 protected:
332  typedef enum FeatureType {
333  LINE, CYLINDER, CIRCLE
334  } FeatureType;
335 
338  virtual void cleanPyramid(std::map<std::string, std::vector<const vpImage<unsigned char>* > >& pyramid);
339 
340  virtual void computeProjectionError();
341 
342  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
343  const unsigned int lvl);
344 
345  virtual void computeVVSSecondPhaseWeights(const unsigned int iter, const unsigned int nerror,
346  vpColVector &weighted_error, vpColVector &w_lines, vpColVector &w_cylinders, vpColVector &w_circles,
347  std::map<std::string, unsigned int> &mapOfNumberOfLines,
348  std::map<std::string, unsigned int> &mapOfNumberOfCylinders, std::map<std::string, unsigned int> &mapOfNumberOfCircles,
349  std::map<std::string, vpColVector> &mapOfWeightLines, std::map<std::string, vpColVector> &mapOfWeightCylinders,
350  std::map<std::string, vpColVector> &mapOfWeightCircles, std::map<std::string, vpColVector> &mapOfErrorLines,
351  std::map<std::string, vpColVector> &mapOfErrorCylinders, std::map<std::string, vpColVector> &mapOfErrorCircles,
352  std::map<std::string, vpRobust> &mapOfRobustLines, std::map<std::string, vpRobust> &mapOfRobustCylinders,
353  std::map<std::string, vpRobust> &mapOfRobustCircles, double threshold);
354 
355  virtual void initPyramid(const std::map<std::string, const vpImage<unsigned char> * >& mapOfImages,
356  std::map<std::string, std::vector<const vpImage<unsigned char>* > >& pyramid);
358 };
359 
360 #endif
361 
virtual void setDisplayFeatures(const bool displayF)
Definition: vpMbTracker.h:411
std::string m_referenceCameraName
Name of the reference camera.
void getLline(std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0) const
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:453
virtual void setCovarianceComputation(const bool &flag)
Definition: vpMbTracker.h:398
void setMovingEdge(const vpMe &me)
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:208
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:382
Implementation of an homogeneous matrix and operations on such kind of matrices.
void init(const vpImage< unsigned char > &I)
void track(const vpImage< unsigned char > &I)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Definition: vpMbTracker.h:430
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, const unsigned int level=0) const
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
Definition: vpMe.h:59
void computeVVSSecondPhaseWeights(const unsigned int iter, const unsigned int nerror, const unsigned int nbrow, vpColVector &weighted_error, vpRobust &robust_lines, vpRobust &robust_cylinders, vpRobust &robust_circles, vpColVector &w_lines, vpColVector &w_cylinders, vpColVector &w_circles, vpColVector &error_lines, vpColVector &error_cylinders, vpColVector &error_circles, const unsigned int nberrors_lines, const unsigned int nberrors_cylinders, const unsigned int nberrors_circles)
Make the complete tracking of an object by using its CAD model.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void setCameraParameters(const vpCameraParameters &camera)
void computeVVS(const vpImage< unsigned char > &_I, const unsigned int lvl)
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
void loadConfigFile(const std::string &configFile)
void setGoodMovingEdgesRatioThreshold(const double threshold)
virtual unsigned int getNbPoints(const unsigned int level=0) const
virtual void setNearClippingDistance(const double &dist)
virtual void setOgreVisibilityTest(const bool &v)
void setOgreShowConfigDialog(const bool showConfigDialog)
Definition: vpMbTracker.h:479
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0) const
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
Map of camera transformation matrix between the current camera frame to the reference camera frame (c...
virtual void setScanLineVisibilityTest(const bool &v)
friend class vpMbEdgeMultiTracker
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:342
virtual void getCameraParameters(vpCameraParameters &camera) const
Definition: vpMbTracker.h:201
Generic class defining intrinsic camera parameters.
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
void cleanPyramid(std::vector< const vpImage< unsigned char > * > &_pyramid)
virtual void setFarClippingDistance(const double &dist)
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:371
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
virtual vpMe getMovingEdge() const
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:464
unsigned int getNumberOfCameras() const
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
void computeProjectionError(const vpImage< unsigned char > &_I)
void setScales(const std::vector< bool > &_scales)
std::map< std::string, std::vector< const vpImage< unsigned char > * > > m_mapOfPyramidalImages
Map of pyramidal images for each camera.
virtual void loadModel(const char *modelFile, const bool verbose=false)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:93
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:286
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual void setClipping(const unsigned int &flags)
void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
std::map< std::string, vpMbEdgeTracker * > m_mapOfEdgeTrackers
Map of Model-based edge trackers.
Make the complete stereo (or more) tracking of an object by using its CAD model.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:248
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:437
virtual void setLod(const bool useLod, const std::string &name="")