Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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::string> getCameraNames() const;
136 
137  virtual void getCameraParameters(vpCameraParameters &camera) const;
138  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
139  virtual void getCameraParameters(const std::string &cameraName, vpCameraParameters &camera) const;
140  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
141 
143  virtual unsigned int getClipping(const std::string &cameraName) const;
144 
146  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
147  virtual std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > getFaces() const;
148 
149  void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, const unsigned int level = 0) const;
150  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
151  const unsigned int level = 0) const;
152 
153  void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList, const unsigned int level = 0) const;
154  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
155  const unsigned int level = 0) const;
156 
157  void getLline(std::list<vpMbtDistanceLine *> &linesList, const unsigned int level = 0) const;
158  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
159  const unsigned int level = 0) const;
160 
161  virtual void getMovingEdge(vpMe &p_me) const;
162  virtual vpMe getMovingEdge() const;
163  virtual void getMovingEdge(const std::string &cameraName, vpMe &p_me) const;
164  virtual vpMe getMovingEdge(const std::string &cameraName) const;
165 
166  virtual unsigned int getNbPoints(const unsigned int level = 0) const;
167  virtual unsigned int getNbPoints(const std::string &cameraName, const unsigned int level = 0) const;
168 
169  virtual unsigned int getNbPolygon() const;
170  virtual unsigned int getNbPolygon(const std::string &cameraName) const;
171  virtual std::map<std::string, unsigned int> getMultiNbPolygon() const;
172 
178  inline unsigned int getNumberOfCameras() const { return (unsigned int)m_mapOfEdgeTrackers.size(); }
179 
180  using vpMbTracker::getPose;
181  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
182  virtual void getPose(const std::string &cameraName, vpHomogeneousMatrix &cMo_) const;
183  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
184 
185  virtual inline vpColVector getError() const { return m_error_edgeMulti; }
186 
187  virtual inline vpColVector getRobustWeights() const { return m_w_edgeMulti; }
188 
189  void init(const vpImage<unsigned char> &I);
190 
191 #ifdef VISP_HAVE_MODULE_GUI
192  virtual void initClick(const vpImage<unsigned char> &I, const std::vector<vpPoint> &points3D_list,
193  const std::string &displayFile = "");
194 
195  virtual void initClick(const vpImage<unsigned char> &I, const std::string &initFile, const bool displayHelp = false,
197 
198  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
199  const std::string &initFile1, const std::string &initFile2, const bool displayHelp = false,
200  const bool firstCameraIsReference = true);
201 
202  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
203  const std::string &initFile, const bool displayHelp = false);
204 
205  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
206  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp = false);
207 #endif
208 
209  virtual void initFromPose(const vpImage<unsigned char> &I, const std::string &initFile);
210  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
211  virtual void initFromPose(const vpImage<unsigned char> &I, const vpPoseVector &cPo);
212 
213  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
214  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
215  const bool firstCameraIsReference = true);
216  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
217  const vpHomogeneousMatrix &cMo_);
218  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
219  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
220 
221  virtual void loadConfigFile(const std::string &configFile);
222 
223  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2,
224  const bool firstCameraIsReference = true);
225 
226  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
227 
228  virtual void loadModel(const std::string &modelFile, const bool verbose = false,
230 
231  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
232  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
234  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
235  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo,
236  const vpHomogeneousMatrix &c2Mo, const bool verbose = false,
237  const bool firstCameraIsReference = true);
238  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
239  const std::string &cad_name,
240  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
241  const bool verbose = false);
242 
243  virtual void resetTracker();
244 
245  virtual void setAngleAppear(const double &a);
246  virtual void setAngleDisappear(const double &a);
247 
248  virtual void setCameraParameters(const vpCameraParameters &camera);
249 
250  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2,
251  const bool firstCameraIsReference = true);
252 
253  virtual void setCameraParameters(const std::string &cameraName, const vpCameraParameters &camera);
254 
255  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
256 
257  virtual void setCameraTransformationMatrix(const std::string &cameraName,
258  const vpHomogeneousMatrix &cameraTransformationMatrix);
259 
260  virtual void
261  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
262 
263  virtual void setClipping(const unsigned int &flags);
264  virtual void setClipping(const std::string &cameraName, const unsigned int &flags);
265 
266  virtual void setCovarianceComputation(const bool &flag);
267 
268  virtual void setDisplayFeatures(const bool displayF);
269 
270  virtual void setFarClippingDistance(const double &dist);
271  virtual void setFarClippingDistance(const std::string &cameraName, const double &dist);
272 
273  virtual void setGoodMovingEdgesRatioThreshold(const double threshold);
274 
275 #ifdef VISP_HAVE_OGRE
276 
285  void setGoodNbRayCastingAttemptsRatio(const double &ratio);
286 
296  void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
297 #endif
298 
299  virtual void setLod(const bool useLod, const std::string &name = "");
300  virtual void setLod(const bool useLod, const std::string &cameraName, const std::string &name);
301 
302  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name = "");
303  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
304  const std::string &name);
305 
306  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name = "");
307  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
308  const std::string &name);
309 
310  virtual void setMovingEdge(const vpMe &me);
311  virtual void setMovingEdge(const std::string &cameraName, const vpMe &me);
312 
313  virtual void setNearClippingDistance(const double &dist);
314  virtual void setNearClippingDistance(const std::string &cameraName, const double &dist);
315 
326  virtual void setOgreShowConfigDialog(const bool showConfigDialog);
327 
328  virtual void setOgreVisibilityTest(const bool &v);
329 
330  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
331 
332  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
333 
334  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
335  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
336  const bool firstCameraIsReference = true);
337 
338  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
339  const vpHomogeneousMatrix &cMo_);
340 
341  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
342  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
343 
344  virtual void setProjectionErrorComputation(const bool &flag);
345 
346  virtual void setReferenceCameraName(const std::string &referenceCameraName);
347 
348  virtual void setScales(const std::vector<bool> &scales);
349 
350  virtual void setScanLineVisibilityTest(const bool &v);
351 
352  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
353 
354  virtual void track(const vpImage<unsigned char> &I);
355  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
356  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
358 
359 protected:
360  enum FeatureType { LINE, CYLINDER, CIRCLE };
361 
364  virtual void cleanPyramid(std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
365 
366  virtual void computeProjectionError();
367 
368  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages, const unsigned int lvl);
369  virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_);
370  virtual void computeVVSInit();
373  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
374  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
375  virtual void computeVVSWeights();
377 
378  virtual void initPyramid(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
379  std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid);
381 };
382 
383 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
384 #endif //_vpMbEdgeMultiTracker_h_
virtual void setDisplayFeatures(const bool displayF)
Definition: vpMbTracker.h:503
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:485
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Definition: vpMbTracker.h:629
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void setMovingEdge(const vpMe &me)
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:256
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:466
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:543
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:603
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:423
virtual void getCameraParameters(vpCameraParameters &camera) const
Definition: vpMbTracker.h:248
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:455
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:613
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: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 unsigned int getNbPolygon() const
Definition: vpMbTracker.h:368
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 vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:332
vpColVector m_weightedError_edgeMulti
Weighted error.
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:570
virtual void setLod(const bool useLod, const std::string &name="")