superquadric-model
superqVisualization.h
1 /*
2  * Copyright (C) 2015 iCub Facility - Istituto Italiano di Tecnologia
3  * Author: Giulia Vezzani
4  * email: giulia.vezzani@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #ifndef __VISUALIZATION_H__
19 #define __VISUALIZATION_H__
20 
21 #include <string>
22 #include <deque>
23 #include <map>
24 
25 #include <yarp/os/all.h>
26 #include <yarp/sig/all.h>
27 #include <yarp/dev/all.h>
28 
29 #include <opencv2/opencv.hpp>
30 
35 /*******************************************************************************/
36 class SuperqVisualization : public yarp::os::RateThread
37 {
38 protected:
40  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > portImgIn;
42  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > portImgOut;
43 
44  // Parameters for visualization
46  int r;
48  int g;
50  int b;
52  double t_vis;
56  int vis_step;
58  std::string what_to_plot;
59 
60  yarp::sig::Vector point,point1;
61  yarp::sig::Vector point2D;
62  std::deque<int> Color;
63 
64  // Variables for gaze
66  std::string eye;
67  yarp::sig::Matrix R,H,K;
69  yarp::dev::IGazeControl *igaze;
70 
71  yarp::os::Mutex mutex;
72 
73 public:
74 
76  yarp::sig::Vector &superq;
78  yarp::sig::Vector &superq_filtered;
80  std::deque<yarp::sig::Vector> &points;
81 
83  yarp::sig::ImageOf<yarp::sig::PixelRgb> *imgIn;
84 
85  /***********************************************************************/
86  SuperqVisualization(int rate, const std::string &_eye, const std::string &_what_to_plot, yarp::sig::Vector &_x, yarp::sig::Vector &_x_filtered,
87  std::deque<int> &_Color, yarp::dev::IGazeControl *_igaze, const yarp::sig::Matrix _K, std::deque<yarp::sig::Vector> &_points,
88  const int &_vis_points, const int &_vis_step);
89 
93  /***********************************************************************/
94  bool showPoints();
95 
100  /***********************************************************************/
101  bool showSuperq(yarp::sig::Vector &x_to_show);
102 
107  /***********************************************************************/
108  yarp::sig::Vector from3Dto2D(const yarp::sig::Vector &point3D);
109 
111  /***********************************************************************/
112  virtual bool threadInit();
113 
115  /***********************************************************************/
116  virtual void run();
117 
119  /***********************************************************************/
120  void interruptPorts();
121 
123  /***********************************************************************/
124  virtual void threadRelease();
125 
130  /***********************************************************************/
131  void setPar(const std::string &par_name, const std::string &value);
132 
137  /***********************************************************************/
138  void setPar(const std::string &par_name, const int &value);
139 
145  /***********************************************************************/
146  void setColor (const int &r, const int &g, const int &b);
147 
152  /***********************************************************************/
153  void setPar(const yarp::os::Property &newOptions, bool first_time);
154 
158  /***********************************************************************/
159  yarp::os::Property getPar();
160 
164  /***********************************************************************/
165  double getTime();
166 };
167 
168 #endif
yarp::dev::IGazeControl * igaze
Gaze Control interface.
yarp::sig::Vector & superq_filtered
Filtered superquadric.
yarp::os::Property getPar()
Get parameters for visualization.
std::string eye
Eye camera selected.
yarp::sig::Vector from3Dto2D(const yarp::sig::Vector &point3D)
Compute 2D pixels from 3D points.
yarp::sig::Vector & superq
Estimated superquadric.
This class shows the point cloud used for modeling or the estimated superquadric overlapped on the ca...
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > > portImgIn
Input image port.
bool showPoints()
Show point cloud on the image.
bool showSuperq(yarp::sig::Vector &x_to_show)
Show reconstructed superquadric on the image.
yarp::sig::ImageOf< yarp::sig::PixelRgb > * imgIn
Input image.
double getTime()
Get time required for visualization.
std::deque< yarp::sig::Vector > & points
Object point cloud.
double t_vis
Time for visualization.
void setColor(const int &r, const int &g, const int &b)
Set color for visualization.
void interruptPorts()
Interrupt ports functionalities.
virtual bool threadInit()
Init function of RateThread.
std::string what_to_plot
String used for deciding what to plot: "points" or "superq".
int vis_step
Number of visualization step.
int r
R value for visualization.
int b
Blue value for visualization.
void setPar(const std::string &par_name, const std::string &value)
Set a given parameter equal to a string.
virtual void run()
Run function of RateThread.
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > > portImgOut
Output image port *.
int g
Green value for visualization.
virtual void threadRelease()
Release function of RateThread.
int vis_points
Number of points used for visualization.