Visual Servoing Platform  version 3.2.1 under development (2019-05-26)
vpMbEdgeMultiTracker.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 http://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  * Model-based edge tracker with multiple cameras.
33  *
34  * Authors:
35  * Souriya Trinh
36  *
37  *****************************************************************************/
38 
44 #ifndef _vpMbEdgeMultiTracker_h_
45 #define _vpMbEdgeMultiTracker_h_
46 
47 #include <visp3/core/vpConfig.h>
48 
49 #include <iostream>
50 #include <vector>
51 
52 #include <visp3/mbt/vpMbEdgeTracker.h>
53 
54 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
55 
73 class VISP_EXPORT vp_deprecated vpMbEdgeMultiTracker : public vpMbEdgeTracker
74 {
75 protected:
78  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
79 
81  std::map<std::string, vpMbEdgeTracker *> m_mapOfEdgeTrackers;
82 
84  std::map<std::string, std::vector<const vpImage<unsigned char> *> > m_mapOfPyramidalImages;
85 
87  std::string m_referenceCameraName;
96 
97 public:
98  // Default constructor <==> equivalent to vpMbEdgeTracker
100  // Constructor with a specified number of cameras, camera names are
101  // generated
102  explicit vpMbEdgeMultiTracker(const unsigned int nbCameras);
103  // Constructor with a specified list of camera names
104  explicit vpMbEdgeMultiTracker(const std::vector<std::string> &cameraNames);
105 
106  virtual ~vpMbEdgeMultiTracker();
107 
110  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
111  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
112 
113  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_,
114  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
115 
116  virtual void display(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
117  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1,
118  const vpCameraParameters &cam2, const vpColor &col, const unsigned int thickness = 1,
119  const bool displayFullModel = false);
120 
121  virtual void display(const vpImage<vpRGBa> &I1, const vpImage<vpRGBa> &I2, const vpHomogeneousMatrix &c1Mo,
122  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
123  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
124 
125  virtual void display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
126  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
127  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
128  const unsigned int thickness = 1, const bool displayFullModel = false);
129 
130  virtual void display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
131  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
132  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
133  const unsigned int thickness = 1, const bool displayFullModel = false);
134 
135  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int, unsigned int,
136  const vpHomogeneousMatrix &,
137  const vpCameraParameters &,
138  const bool =false)
139  {
140  std::cerr << "Not implemented. Deprecated class." << std::endl;
141  return std::vector<std::vector<double> >();
142  }
143 
144  virtual std::vector<std::string> getCameraNames() const;
145 
146  virtual void getCameraParameters(vpCameraParameters &camera) const;
147  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
148  virtual void getCameraParameters(const std::string &cameraName, vpCameraParameters &camera) const;
149  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
150 
152  virtual unsigned int getClipping(const std::string &cameraName) const;
153 
155  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
156  virtual std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > getFaces() const;
157 
158  void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, const unsigned int level = 0) const;
159  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
160  const unsigned int level = 0) const;
161 
162  void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList, const unsigned int level = 0) const;
163  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
164  const unsigned int level = 0) const;
165 
166  void getLline(std::list<vpMbtDistanceLine *> &linesList, const unsigned int level = 0) const;
167  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
168  const unsigned int level = 0) const;
169 
170  virtual void getMovingEdge(vpMe &p_me) const;
171  virtual vpMe getMovingEdge() const;
172  virtual void getMovingEdge(const std::string &cameraName, vpMe &p_me) const;
173  virtual vpMe getMovingEdge(const std::string &cameraName) const;
174 
175  virtual unsigned int getNbPoints(const unsigned int level = 0) const;
176  virtual unsigned int getNbPoints(const std::string &cameraName, const unsigned int level = 0) const;
177 
178  virtual unsigned int getNbPolygon() const;
179  virtual unsigned int getNbPolygon(const std::string &cameraName) const;
180  virtual std::map<std::string, unsigned int> getMultiNbPolygon() const;
181 
187  inline unsigned int getNumberOfCameras() const { return (unsigned int)m_mapOfEdgeTrackers.size(); }
188 
189  using vpMbTracker::getPose;
190  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
191  virtual void getPose(const std::string &cameraName, vpHomogeneousMatrix &cMo_) const;
192  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
193 
194  virtual inline vpColVector getError() const { return m_error_edgeMulti; }
195 
196  virtual inline vpColVector getRobustWeights() const { return m_w_edgeMulti; }
197 
198  void init(const vpImage<unsigned char> &I);
199 
200 #ifdef VISP_HAVE_MODULE_GUI
202  virtual void initClick(const vpImage<unsigned char> &I, const std::vector<vpPoint> &points3D_list,
203  const std::string &displayFile = "");
204 
205  virtual void initClick(const vpImage<unsigned char> &I, const std::string &initFile, const bool displayHelp = false,
207 
208  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
209  const std::string &initFile1, const std::string &initFile2, const bool displayHelp = false,
210  const bool firstCameraIsReference = true);
211 
212  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
213  const std::string &initFile, const bool displayHelp = false);
214 
215  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
216  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp = false);
217 #endif
218 
220  virtual void initFromPose(const vpImage<unsigned char> &I, const std::string &initFile);
221  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
222  virtual void initFromPose(const vpImage<unsigned char> &I, const vpPoseVector &cPo);
223 
224  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
225  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
226  const bool firstCameraIsReference = true);
227  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
228  const vpHomogeneousMatrix &cMo_);
229  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
230  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
231 
232  virtual void loadConfigFile(const std::string &configFile);
233 
234  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2,
235  const bool firstCameraIsReference = true);
236 
237  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
238 
239  virtual void loadModel(const std::string &modelFile, const bool verbose = false,
241 
242  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
243  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
245  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
246  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo,
247  const vpHomogeneousMatrix &c2Mo, const bool verbose = false,
248  const bool firstCameraIsReference = true);
249  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
250  const std::string &cad_name,
251  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
252  const bool verbose = false);
253 
254  virtual void resetTracker();
255 
256  virtual void setAngleAppear(const double &a);
257  virtual void setAngleDisappear(const double &a);
258 
259  virtual void setCameraParameters(const vpCameraParameters &camera);
260 
261  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2,
262  const bool firstCameraIsReference = true);
263 
264  virtual void setCameraParameters(const std::string &cameraName, const vpCameraParameters &camera);
265 
266  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
267 
268  virtual void setCameraTransformationMatrix(const std::string &cameraName,
269  const vpHomogeneousMatrix &cameraTransformationMatrix);
270 
271  virtual void
272  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
273 
274  virtual void setClipping(const unsigned int &flags);
275  virtual void setClipping(const std::string &cameraName, const unsigned int &flags);
276 
277  virtual void setCovarianceComputation(const bool &flag);
278 
279  virtual void setDisplayFeatures(const bool displayF);
280 
281  virtual void setFarClippingDistance(const double &dist);
282  virtual void setFarClippingDistance(const std::string &cameraName, const double &dist);
283 
284  virtual void setGoodMovingEdgesRatioThreshold(const double threshold);
285 
286 #ifdef VISP_HAVE_OGRE
287 
296  void setGoodNbRayCastingAttemptsRatio(const double &ratio);
297 
307  void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
308 #endif
309 
310  virtual void setLod(const bool useLod, const std::string &name = "");
311  virtual void setLod(const bool useLod, const std::string &cameraName, const std::string &name);
312 
313  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name = "");
314  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
315  const std::string &name);
316 
317  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name = "");
318  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
319  const std::string &name);
320 
321  virtual void setMovingEdge(const vpMe &me);
322  virtual void setMovingEdge(const std::string &cameraName, const vpMe &me);
323 
324  virtual void setNearClippingDistance(const double &dist);
325  virtual void setNearClippingDistance(const std::string &cameraName, const double &dist);
326 
337  virtual void setOgreShowConfigDialog(const bool showConfigDialog);
338 
339  virtual void setOgreVisibilityTest(const bool &v);
340 
341  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
342 
343  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
344  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cMo);
345 
346  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
347  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
348  const bool firstCameraIsReference = true);
349 
350  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
351  const vpHomogeneousMatrix &cMo_);
352 
353  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
354  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
355 
356  virtual void setProjectionErrorComputation(const bool &flag);
357 
358  virtual void setReferenceCameraName(const std::string &referenceCameraName);
359 
360  virtual void setScales(const std::vector<bool> &scales);
361 
362  virtual void setScanLineVisibilityTest(const bool &v);
363 
364  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
365 
367  virtual void track(const vpImage<unsigned char> &I);
368  virtual void track(const vpImage<vpRGBa> &I_color);
369  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
370  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
372 
373 protected:
374  enum FeatureType { LINE, CYLINDER, CIRCLE };
375 
378  virtual void cleanPyramid(std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
379 
380  virtual void computeProjectionError();
381 
382  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages, const unsigned int lvl);
383  virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_);
384  virtual void computeVVSInit();
387  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
388  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
389  virtual void computeVVSWeights();
391 
392  virtual void initPyramid(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
393  std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
395 };
396 
397 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
398 #endif //_vpMbEdgeMultiTracker_h_
virtual void setDisplayFeatures(const bool displayF)
Definition: vpMbTracker.h:513
std::string m_referenceCameraName
Name of the reference camera.
void getLline(std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0) const
virtual void setCovarianceComputation(const bool &flag)
Definition: vpMbTracker.h:495
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Definition: vpMbTracker.h:639
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
void setMovingEdge(const vpMe &me)
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:252
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:476
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void init(const vpImage< unsigned char > &I)
virtual void track(const vpImage< unsigned char > &I)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Definition: vpMbTracker.h:553
virtual void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, const unsigned int level=0) const
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
vpColVector m_w_edgeMulti
Robust weights.
virtual vpColVector getRobustWeights() const
Definition: vpMe.h:60
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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 unsigned int getNbPoints(const unsigned int level=0) const
virtual void computeVVSWeights()
virtual void setNearClippingDistance(const double &dist)
virtual void setOgreVisibilityTest(const bool &v)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0) const
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:613
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
vpMatrix m_L_edgeMulti
Interaction matrix.
virtual void setScanLineVisibilityTest(const bool &v)
friend class vpMbEdgeMultiTracker
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:419
virtual void getCameraParameters(vpCameraParameters &camera) const
Definition: vpMbTracker.h:244
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 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:465
virtual vpColVector getError() const
std::map< std::string, vpMbEdgeTracker * > m_mapOfEdgeTrackers
Map of Model-based edge trackers.
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:623
virtual vpMe getMovingEdge() const
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)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
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:151
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:364
virtual 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()
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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 std::vector< std::vector< double > > getModelForDisplay(unsigned int, unsigned int, const vpHomogeneousMatrix &, const vpCameraParameters &, const bool=false)
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:328
vpColVector m_weightedError_edgeMulti
Weighted error.
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:580
virtual void setLod(const bool useLod, const std::string &name="")