Visual Servoing Platform  version 3.1.0
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 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/download/ 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  * http://www.irisa.fr/lagadic
25  *
26  * If you have questions regarding the use of this file, please contact
27  * INRIA at visp@inria.fr
28  *
29  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31  *
32  *
33  * Description:
34  * Model-based edge tracker with multiple cameras.
35  *
36  * Authors:
37  * Souriya Trinh
38  *
39  *****************************************************************************/
40 
46 #ifndef __vpMbEdgeMultiTracker_h__
47 #define __vpMbEdgeMultiTracker_h__
48 
49 #include <iostream>
50 #include <vector>
51 
52 #include <visp3/mbt/vpMbEdgeTracker.h>
53 
69 class VISP_EXPORT vpMbEdgeMultiTracker : public vpMbEdgeTracker
70 {
71 protected:
74  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
75 
77  std::map<std::string, vpMbEdgeTracker *> m_mapOfEdgeTrackers;
78 
80  std::map<std::string, std::vector<const vpImage<unsigned char> *> > m_mapOfPyramidalImages;
81 
83  std::string m_referenceCameraName;
92 
93 public:
94  // Default constructor <==> equivalent to vpMbEdgeTracker
96  // Constructor with a specified number of cameras, camera names are
97  // generated
98  explicit vpMbEdgeMultiTracker(const unsigned int nbCameras);
99  // Constructor with a specified list of camera names
100  explicit vpMbEdgeMultiTracker(const std::vector<std::string> &cameraNames);
101 
102  virtual ~vpMbEdgeMultiTracker();
103 
106  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
107  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
108 
109  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
110  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
111 
112  virtual void display(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
113  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1,
114  const vpCameraParameters &cam2, const vpColor &col, const unsigned int thickness = 1,
115  const bool displayFullModel = false);
116 
117  virtual void display(const vpImage<vpRGBa> &I1, const vpImage<vpRGBa> &I2, const vpHomogeneousMatrix &c1Mo,
118  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
119  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
120 
121  virtual void display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
122  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
123  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
124  const unsigned int thickness = 1, const bool displayFullModel = false);
125 
126  virtual void display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
127  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
128  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
129  const unsigned int thickness = 1, const bool displayFullModel = false);
130 
131  virtual std::vector<std::string> getCameraNames() const;
132 
133  virtual void getCameraParameters(vpCameraParameters &camera) const;
134  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
135  virtual void getCameraParameters(const std::string &cameraName, vpCameraParameters &camera) const;
136  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
137 
139  virtual unsigned int getClipping(const std::string &cameraName) const;
140 
142  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
143  virtual std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > getFaces() const;
144 
145  void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, const unsigned int level = 0) const;
146  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
147  const unsigned int level = 0) const;
148 
149  void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList, const unsigned int level = 0) const;
150  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
151  const unsigned int level = 0) const;
152 
153  void getLline(std::list<vpMbtDistanceLine *> &linesList, const unsigned int level = 0) const;
154  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
155  const unsigned int level = 0) const;
156 
157  virtual void getMovingEdge(vpMe &p_me) const;
158  virtual vpMe getMovingEdge() const;
159  virtual void getMovingEdge(const std::string &cameraName, vpMe &p_me) const;
160  virtual vpMe getMovingEdge(const std::string &cameraName) const;
161 
162  virtual unsigned int getNbPoints(const unsigned int level = 0) const;
163  virtual unsigned int getNbPoints(const std::string &cameraName, const unsigned int level = 0) const;
164 
165  virtual unsigned int getNbPolygon() const;
166  virtual unsigned int getNbPolygon(const std::string &cameraName) const;
167  virtual std::map<std::string, unsigned int> getMultiNbPolygon() const;
168 
174  inline unsigned int getNumberOfCameras() const { return (unsigned int)m_mapOfEdgeTrackers.size(); }
175 
176  using vpMbTracker::getPose;
177  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
178  virtual void getPose(const std::string &cameraName, vpHomogeneousMatrix &cMo_) const;
179  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
180 
181  virtual inline vpColVector getError() const { return m_error_edgeMulti; }
182 
183  virtual inline vpColVector getRobustWeights() const { return m_w_edgeMulti; }
184 
185  void init(const vpImage<unsigned char> &I);
186 
187 #ifdef VISP_HAVE_MODULE_GUI
188  virtual void initClick(const vpImage<unsigned char> &I, const std::vector<vpPoint> &points3D_list,
189  const std::string &displayFile = "");
190 
191  virtual void initClick(const vpImage<unsigned char> &I, const std::string &initFile, const bool displayHelp = false);
192 
193  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
194  const std::string &initFile1, const std::string &initFile2, const bool displayHelp = false,
195  const bool firstCameraIsReference = true);
196 
197  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
198  const std::string &initFile, const bool displayHelp = false);
199 
200  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
201  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp = false);
202 #endif
203 
204  virtual void initFromPose(const vpImage<unsigned char> &I, const std::string &initFile);
205  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
206  virtual void initFromPose(const vpImage<unsigned char> &I, const vpPoseVector &cPo);
207 
208  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
209  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
210  const bool firstCameraIsReference = true);
211  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
212  const vpHomogeneousMatrix &cMo_);
213  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
214  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
215 
216  virtual void loadConfigFile(const std::string &configFile);
217 
218  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2,
219  const bool firstCameraIsReference = true);
220 
221  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
222 
223  virtual void loadModel(const std::string &modelFile, const bool verbose = false);
224 
225  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
226  const vpHomogeneousMatrix &cMo_, const bool verbose = false);
227  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
228  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo,
229  const vpHomogeneousMatrix &c2Mo, const bool verbose = false,
230  const bool firstCameraIsReference = true);
231  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
232  const std::string &cad_name,
233  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
234  const bool verbose = false);
235 
236  virtual void resetTracker();
237 
238  virtual void setAngleAppear(const double &a);
239  virtual void setAngleDisappear(const double &a);
240 
241  virtual void setCameraParameters(const vpCameraParameters &camera);
242 
243  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2,
244  const bool firstCameraIsReference = true);
245 
246  virtual void setCameraParameters(const std::string &cameraName, const vpCameraParameters &camera);
247 
248  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
249 
250  virtual void setCameraTransformationMatrix(const std::string &cameraName,
251  const vpHomogeneousMatrix &cameraTransformationMatrix);
252 
253  virtual void
254  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
255 
256  virtual void setClipping(const unsigned int &flags);
257  virtual void setClipping(const std::string &cameraName, const unsigned int &flags);
258 
259  virtual void setCovarianceComputation(const bool &flag);
260 
261  virtual void setDisplayFeatures(const bool displayF);
262 
263  virtual void setFarClippingDistance(const double &dist);
264  virtual void setFarClippingDistance(const std::string &cameraName, const double &dist);
265 
266  virtual void setGoodMovingEdgesRatioThreshold(const double threshold);
267 
268 #ifdef VISP_HAVE_OGRE
269 
278  void setGoodNbRayCastingAttemptsRatio(const double &ratio);
279 
289  void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
290 #endif
291 
292  virtual void setLod(const bool useLod, const std::string &name = "");
293  virtual void setLod(const bool useLod, const std::string &cameraName, const std::string &name);
294 
295  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name = "");
296  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
297  const std::string &name);
298 
299  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name = "");
300  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
301  const std::string &name);
302 
303  virtual void setMovingEdge(const vpMe &me);
304  virtual void setMovingEdge(const std::string &cameraName, const vpMe &me);
305 
306  virtual void setNearClippingDistance(const double &dist);
307  virtual void setNearClippingDistance(const std::string &cameraName, const double &dist);
308 
319  virtual void setOgreShowConfigDialog(const bool showConfigDialog);
320 
321  virtual void setOgreVisibilityTest(const bool &v);
322 
323  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
324 
325  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
326 
327  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
328  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
329  const bool firstCameraIsReference = true);
330 
331  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
332  const vpHomogeneousMatrix &cMo_);
333 
334  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
335  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
336 
337  virtual void setProjectionErrorComputation(const bool &flag);
338 
339  virtual void setReferenceCameraName(const std::string &referenceCameraName);
340 
341  virtual void setScales(const std::vector<bool> &scales);
342 
343  virtual void setScanLineVisibilityTest(const bool &v);
344 
345  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
346 
347  virtual void track(const vpImage<unsigned char> &I);
348  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
349  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
351 
352 protected:
353  enum FeatureType { LINE, CYLINDER, CIRCLE };
354 
357  virtual void cleanPyramid(std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
358 
359  virtual void computeProjectionError();
360 
361  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages, const unsigned int lvl);
362  virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_);
363  virtual void computeVVSInit();
366  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
367  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
368  virtual void computeVVSWeights();
370 
371  virtual void initPyramid(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
372  std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
374 };
375 
376 #endif
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:223
virtual void setDisplayFeatures(const bool displayF)
Definition: vpMbTracker.h:470
std::string m_referenceCameraName
Name of the reference camera.
virtual void setCovarianceComputation(const bool &flag)
Definition: vpMbTracker.h:452
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Definition: vpMbTracker.h:575
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void setMovingEdge(const vpMe &me)
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:433
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:510
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
vpColVector m_w_edgeMulti
Robust weights.
virtual unsigned int getNbPoints(const unsigned int level=0) const
Definition: vpMe.h:60
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 computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
vpColVector m_error_edgeMulti
(s - s*)
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 void computeVVSWeights()
virtual void setNearClippingDistance(const double &dist)
unsigned int getNumberOfCameras() const
virtual void setOgreVisibilityTest(const bool &v)
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:390
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="")
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:549
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
vpMatrix m_L_edgeMulti
Interaction matrix.
virtual void setScanLineVisibilityTest(const bool &v)
friend class vpMbEdgeMultiTracker
virtual vpColVector getError() const
Generic class defining intrinsic camera parameters.
void cleanPyramid(std::vector< const vpImage< unsigned char > *> &_pyramid)
virtual void computeVVSInteractionMatrixAndResidu()
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setFarClippingDistance(const double &dist)
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:422
std::map< std::string, vpMbEdgeTracker * > m_mapOfEdgeTrackers
Map of Model-based edge trackers.
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
virtual vpColVector getRobustWeights() const
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:559
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
void getLline(std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
void computeProjectionError(const vpImage< unsigned char > &_I)
void getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
void setScales(const std::vector< bool > &_scales)
virtual void loadModel(const char *modelFile, const bool verbose=false)
virtual void getCameraParameters(vpCameraParameters &camera) const
Definition: vpMbTracker.h:215
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:335
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
std::map< std::string, std::vector< const vpImage< unsigned char > * > > m_mapOfPyramidalImages
Map of pyramidal images for each camera.
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
virtual vpMe getMovingEdge() const
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 computeVVSInit()
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
virtual void setClipping(const unsigned int &flags)
void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
Make the complete stereo (or more) tracking of an object by using its CAD model.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:299
vpColVector m_weightedError_edgeMulti
Weighted error.
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, const unsigned int level=0) const
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:531
virtual void setLod(const bool useLod, const std::string &name="")