1 #ifndef WORLD_SCOPED_MAPS_H 2 #define WORLD_SCOPED_MAPS_H 4 #include <opencv2/core/core.hpp> 5 #include <opencv2/core/core_c.h> 6 #include <opencv2/imgproc/imgproc.hpp> 10 class WorldScopedMaps;
48 void init (
int width_pixel,
int height_pixel,
double min_y,
double max_y,
double min_x,
double max_x,
double rotation = 0 );
54 template <
typename T>
void init(
const T &metadata){
55 width_pixel_ = metadata.width, height_pixel_ = metadata.height;
56 dx_ = metadata.resolution * (double) metadata.width;
57 dy_ = metadata.resolution * (
double) metadata.height;
58 sx_ = 1.0/metadata.resolution;
59 sy_ = 1.0/metadata.resolution;
62 double roll = 0, pitch = 0, yaw = 0;
66 double ca = cos ( rotation_ ), sa = sin ( rotation_ );
67 mx_ = metadata.origin.position.x;
68 my_ = metadata.origin.position.y;
69 cv::Matx<double, 3, 3 > Tw ( 1, 0, -mx_, 0, 1, -my_, 0, 0, 1 );
70 cv::Matx<double, 3, 3 > Sc ( sx_, 0, 0, 0, sy_, 0, 0, 0, 1 );
71 cv::Matx<double, 3, 3 > R ( ca, -sa, 0, sa, ca, 0, 0, 0, 1 );
95 void line ( T &map,
const Point2D &p0,
const Point2D &p1,
const cv::Scalar &color,
int thickness=1,
int lineType = CV_AA )
const {
96 cv::line ( map,
w2m ( p0 ).
cv(),
w2m ( p1 ).
cv(), color, thickness, lineType );
107 template <
typename T>
108 void circle ( T &map,
const Point2D &
p,
int radius,
const cv::Scalar &color,
int thickness=1,
int lineType = CV_AA )
const{
109 cv::circle ( map,
w2m ( p ).
cv(), radius, color, thickness, lineType );
117 template <
typename T>
118 cv::Scalar_<T>
get ( cv::Mat_<T> &map,
const Point2D &
p)
const{
119 return map.at(
w2m (
p ).
cv() );
125 const cv::Matx33d &
Mw2m ()
const;
129 const cv::Matx33d &
Mm2w ()
const;
191 double min_x ()
const ;
195 double max_x ()
const ;
199 double min_y ()
const ;
203 double max_y ()
const ;
219 #endif // WORLD_SCOPED_MAPS_H
void circle(T &map, const Point2D &p, int radius, const cv::Scalar &color, int thickness=1, int lineType=CV_AA) const
void init(const T &metadata)
std::string infoHeader() const
virtual ~WorldScopedMaps()=default
cv::Matx33d Mm2w_
transformation map to world
int height_pixel_
dimensions of the canvas in pixel
double dy_
dimension of the visualized space
void init()
initializes the transformation matrices
void line(T &map, const Point2D &p0, const Point2D &p1, const cv::Scalar &color, int thickness=1, int lineType=CV_AA) const
Point2D w2m(const Point2D &src) const
double scale_w2m(double v) const
WorldScopedMaps & operator=(const WorldScopedMaps &)=default
cv::Matx33d Mw2m_
transformation world to map
const cv::Matx33d & Mw2m() const
const cv::Matx33d & Mm2w() const
void QuaternionToEuler(const Quaternion &q, double &roll, double &pitch, double &yaw)
std::shared_ptr< WorldScopedMaps > WorldScopedMapsPtr
Prototype.
double my_
offset of the visualized space
std::shared_ptr< WorldScopedMaps const > WorldScopedMapsConstPtr
Point2D m2w(const Point2D &src) const
double rotation_
area and rotation of the visualized space