temp_viz removed
This commit is contained in:
parent
3e41f0647e
commit
83cb28f169
@ -53,12 +53,15 @@
|
|||||||
#include <opencv2/viz/viz3d.hpp>
|
#include <opencv2/viz/viz3d.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
//! takes coordiante frame data and builds transfrom to global coordinate frame
|
namespace viz
|
||||||
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
|
{
|
||||||
|
//! takes coordiante frame data and builds transfrom to global coordinate frame
|
||||||
|
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
|
||||||
|
|
||||||
CV_EXPORTS Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& up_vector);
|
CV_EXPORTS Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& up_vector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,79 +3,82 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <opencv2/viz/types.hpp>
|
#include <opencv2/viz/types.hpp>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
class KeyboardEvent
|
namespace viz
|
||||||
{
|
{
|
||||||
public:
|
class KeyboardEvent
|
||||||
static const unsigned int Alt = 1;
|
|
||||||
static const unsigned int Ctrl = 2;
|
|
||||||
static const unsigned int Shift = 4;
|
|
||||||
|
|
||||||
/** \brief Constructor
|
|
||||||
* \param[in] action true for key was pressed, false for released
|
|
||||||
* \param[in] key_sym the key-name that caused the action
|
|
||||||
* \param[in] key the key code that caused the action
|
|
||||||
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
|
|
||||||
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
|
|
||||||
* \param[in] shift whether the shift was pressed at the time where this event was triggered
|
|
||||||
*/
|
|
||||||
KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift);
|
|
||||||
|
|
||||||
bool isAltPressed () const;
|
|
||||||
bool isCtrlPressed () const;
|
|
||||||
bool isShiftPressed () const;
|
|
||||||
|
|
||||||
unsigned char getKeyCode () const;
|
|
||||||
|
|
||||||
const String& getKeySym () const;
|
|
||||||
bool keyDown () const;
|
|
||||||
bool keyUp () const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
bool action_;
|
|
||||||
unsigned int modifiers_;
|
|
||||||
unsigned char key_code_;
|
|
||||||
String key_sym_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MouseEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Type
|
|
||||||
{
|
{
|
||||||
MouseMove = 1,
|
public:
|
||||||
MouseButtonPress,
|
static const unsigned int Alt = 1;
|
||||||
MouseButtonRelease,
|
static const unsigned int Ctrl = 2;
|
||||||
MouseScrollDown,
|
static const unsigned int Shift = 4;
|
||||||
MouseScrollUp,
|
|
||||||
MouseDblClick
|
|
||||||
} ;
|
|
||||||
|
|
||||||
enum MouseButton
|
/** \brief Constructor
|
||||||
|
* \param[in] action true for key was pressed, false for released
|
||||||
|
* \param[in] key_sym the key-name that caused the action
|
||||||
|
* \param[in] key the key code that caused the action
|
||||||
|
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
|
||||||
|
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
|
||||||
|
* \param[in] shift whether the shift was pressed at the time where this event was triggered
|
||||||
|
*/
|
||||||
|
KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift);
|
||||||
|
|
||||||
|
bool isAltPressed () const;
|
||||||
|
bool isCtrlPressed () const;
|
||||||
|
bool isShiftPressed () const;
|
||||||
|
|
||||||
|
unsigned char getKeyCode () const;
|
||||||
|
|
||||||
|
const String& getKeySym () const;
|
||||||
|
bool keyDown () const;
|
||||||
|
bool keyUp () const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool action_;
|
||||||
|
unsigned int modifiers_;
|
||||||
|
unsigned char key_code_;
|
||||||
|
String key_sym_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MouseEvent
|
||||||
{
|
{
|
||||||
NoButton = 0,
|
public:
|
||||||
LeftButton,
|
enum Type
|
||||||
MiddleButton,
|
{
|
||||||
RightButton,
|
MouseMove = 1,
|
||||||
VScroll /*other buttons, scroll wheels etc. may follow*/
|
MouseButtonPress,
|
||||||
} ;
|
MouseButtonRelease,
|
||||||
|
MouseScrollDown,
|
||||||
|
MouseScrollUp,
|
||||||
|
MouseDblClick
|
||||||
|
} ;
|
||||||
|
|
||||||
MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift);
|
enum MouseButton
|
||||||
|
{
|
||||||
|
NoButton = 0,
|
||||||
|
LeftButton,
|
||||||
|
MiddleButton,
|
||||||
|
RightButton,
|
||||||
|
VScroll /*other buttons, scroll wheels etc. may follow*/
|
||||||
|
} ;
|
||||||
|
|
||||||
|
MouseEvent (const Type& type, const MouseButton& button, const Point& p, bool alt, bool ctrl, bool shift);
|
||||||
|
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
MouseButton button;
|
MouseButton button;
|
||||||
Point pointer;
|
Point pointer;
|
||||||
unsigned int key_state;
|
unsigned int key_state;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
/// Implementation
|
/// Implementation
|
||||||
|
|
||||||
inline temp_viz::KeyboardEvent::KeyboardEvent (bool _action, const std::string& _key_sym, unsigned char key, bool alt, bool ctrl, bool shift)
|
inline cv::viz::KeyboardEvent::KeyboardEvent (bool _action, const std::string& _key_sym, unsigned char key, bool alt, bool ctrl, bool shift)
|
||||||
: action_ (_action), modifiers_ (0), key_code_(key), key_sym_ (_key_sym)
|
: action_ (_action), modifiers_ (0), key_code_(key), key_sym_ (_key_sym)
|
||||||
{
|
{
|
||||||
if (alt)
|
if (alt)
|
||||||
@ -88,15 +91,15 @@ inline temp_viz::KeyboardEvent::KeyboardEvent (bool _action, const std::string&
|
|||||||
modifiers_ |= Shift;
|
modifiers_ |= Shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool temp_viz::KeyboardEvent::isAltPressed () const { return (modifiers_ & Alt) != 0; }
|
inline bool cv::viz::KeyboardEvent::isAltPressed () const { return (modifiers_ & Alt) != 0; }
|
||||||
inline bool temp_viz::KeyboardEvent::isCtrlPressed () const { return (modifiers_ & Ctrl) != 0; }
|
inline bool cv::viz::KeyboardEvent::isCtrlPressed () const { return (modifiers_ & Ctrl) != 0; }
|
||||||
inline bool temp_viz::KeyboardEvent::isShiftPressed () const { return (modifiers_ & Shift) != 0; }
|
inline bool cv::viz::KeyboardEvent::isShiftPressed () const { return (modifiers_ & Shift) != 0; }
|
||||||
inline unsigned char temp_viz::KeyboardEvent::getKeyCode () const { return key_code_; }
|
inline unsigned char cv::viz::KeyboardEvent::getKeyCode () const { return key_code_; }
|
||||||
inline const temp_viz::String& temp_viz::KeyboardEvent::getKeySym () const { return key_sym_; }
|
inline const cv::String& cv::viz::KeyboardEvent::getKeySym () const { return key_sym_; }
|
||||||
inline bool temp_viz::KeyboardEvent::keyDown () const { return action_; }
|
inline bool cv::viz::KeyboardEvent::keyDown () const { return action_; }
|
||||||
inline bool temp_viz::KeyboardEvent::keyUp () const { return !action_; }
|
inline bool cv::viz::KeyboardEvent::keyUp () const { return !action_; }
|
||||||
|
|
||||||
inline temp_viz::MouseEvent::MouseEvent (const Type& _type, const MouseButton& _button, const Point& _p, bool alt, bool ctrl, bool shift)
|
inline cv::viz::MouseEvent::MouseEvent (const Type& _type, const MouseButton& _button, const Point& _p, bool alt, bool ctrl, bool shift)
|
||||||
: type(_type), button(_button), pointer(_p), key_state(0)
|
: type(_type), button(_button), pointer(_p), key_state(0)
|
||||||
{
|
{
|
||||||
if (alt)
|
if (alt)
|
||||||
|
@ -5,105 +5,109 @@
|
|||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
#include <opencv2/core/affine.hpp>
|
#include <opencv2/core/affine.hpp>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
//qt creator hack
|
|
||||||
typedef cv::Scalar Scalar;
|
|
||||||
typedef cv::Mat Mat;
|
|
||||||
typedef std::string String;
|
typedef std::string String;
|
||||||
|
// //qt creator hack
|
||||||
|
// typedef cv::Scalar Scalar;
|
||||||
|
// typedef cv::Mat Mat;
|
||||||
|
// typedef std::string String;
|
||||||
|
|
||||||
typedef cv::Vec3d Vec3d;
|
// typedef cv::Vec3d Vec3d;
|
||||||
typedef cv::Vec3f Vec3f;
|
// typedef cv::Vec3f Vec3f;
|
||||||
typedef cv::Vec4d Vec4d;
|
// typedef cv::Vec4d Vec4d;
|
||||||
typedef cv::Vec4f Vec4f;
|
// typedef cv::Vec4f Vec4f;
|
||||||
typedef cv::Vec2d Vec2d;
|
// typedef cv::Vec2d Vec2d;
|
||||||
typedef cv::Vec2i Vec2i;
|
// typedef cv::Vec2i Vec2i;
|
||||||
typedef cv::Vec3b Vec3b;
|
// typedef cv::Vec3b Vec3b;
|
||||||
typedef cv::Matx33d Matx33d;
|
// typedef cv::Matx33d Matx33d;
|
||||||
typedef cv::Affine3f Affine3f;
|
// typedef cv::Affine3f Affine3f;
|
||||||
typedef cv::Affine3d Affine3d;
|
// typedef cv::Affine3d Affine3d;
|
||||||
typedef cv::Point2i Point2i;
|
// typedef cv::Point2i Point2i;
|
||||||
typedef cv::Point3f Point3f;
|
// typedef cv::Point3f Point3f;
|
||||||
typedef cv::Point3d Point3d;
|
// typedef cv::Point3d Point3d;
|
||||||
typedef cv::Matx44d Matx44d;
|
// typedef cv::Matx44d Matx44d;
|
||||||
typedef cv::Matx44f Matx44f;
|
// typedef cv::Matx44f Matx44f;
|
||||||
typedef cv::Size Size;
|
// typedef cv::Size Size;
|
||||||
typedef cv::Point Point;
|
// typedef cv::Point Point;
|
||||||
typedef cv::InputArray InputArray;
|
// typedef cv::InputArray InputArray;
|
||||||
using cv::Point3_;
|
// using cv::Point3_;
|
||||||
using cv::Vec;
|
// using cv::Vec;
|
||||||
using cv::Mat_;
|
// using cv::Mat_;
|
||||||
using cv::DataDepth;
|
// using cv::DataDepth;
|
||||||
using cv::DataType;
|
// using cv::DataType;
|
||||||
|
// using cv::Ptr;
|
||||||
class CV_EXPORTS Color : public Scalar
|
namespace viz
|
||||||
{
|
{
|
||||||
public:
|
class CV_EXPORTS Color : public Scalar
|
||||||
Color();
|
{
|
||||||
Color(double gray);
|
public:
|
||||||
Color(double blue, double green, double red);
|
Color();
|
||||||
|
Color(double gray);
|
||||||
|
Color(double blue, double green, double red);
|
||||||
|
|
||||||
Color(const Scalar& color);
|
Color(const Scalar& color);
|
||||||
|
|
||||||
static Color black();
|
static Color black();
|
||||||
static Color blue();
|
static Color blue();
|
||||||
static Color green();
|
static Color green();
|
||||||
static Color cyan();
|
static Color cyan();
|
||||||
|
|
||||||
static Color red();
|
static Color red();
|
||||||
static Color magenta();
|
static Color magenta();
|
||||||
static Color yellow();
|
static Color yellow();
|
||||||
static Color white();
|
static Color white();
|
||||||
|
|
||||||
static Color gray();
|
static Color gray();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct CV_EXPORTS Vertices
|
struct CV_EXPORTS Vertices
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> vertices;
|
std::vector<unsigned int> vertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS Mesh3d
|
class CV_EXPORTS Mesh3d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Ptr<Mesh3d> Ptr;
|
typedef Ptr<Mesh3d> Ptr;
|
||||||
|
|
||||||
Mat cloud, colors;
|
Mat cloud, colors;
|
||||||
std::vector<Vertices> polygons;
|
std::vector<Vertices> polygons;
|
||||||
|
|
||||||
static Mesh3d::Ptr mesh_load(const String& file);
|
static Mesh3d::Ptr mesh_load(const String& file);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/// Utility functions
|
/// Utility functions
|
||||||
|
|
||||||
inline Color vtkcolor(const Color& color)
|
inline Color vtkcolor(const Color& color)
|
||||||
{
|
{
|
||||||
Color scaled_color = color * (1.0/255.0);
|
Color scaled_color = color * (1.0/255.0);
|
||||||
std::swap(scaled_color[0], scaled_color[2]);
|
std::swap(scaled_color[0], scaled_color[2]);
|
||||||
return scaled_color;
|
return scaled_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vec3d vtkpoint(const Point3f& point) { return Vec3d(point.x, point.y, point.z); }
|
||||||
|
template<typename _Tp> inline _Tp normalized(const _Tp& v) { return v * 1/cv::norm(v); }
|
||||||
|
|
||||||
|
inline bool isNan(float x)
|
||||||
|
{
|
||||||
|
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
|
||||||
|
return ((u[0] & 0x7f800000) == 0x7f800000) && (u[0] & 0x007fffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isNan(double x)
|
||||||
|
{
|
||||||
|
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
|
||||||
|
return (u[1] & 0x7ff00000) == 0x7ff00000 && (u[0] != 0 || (u[1] & 0x000fffff) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _Tp, int cn> inline bool isNan(const Vec<_Tp, cn>& v)
|
||||||
|
{ return isNan(v.val[0]) || isNan(v.val[1]) || isNan(v.val[2]); }
|
||||||
|
|
||||||
|
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
|
||||||
|
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vec3d vtkpoint(const Point3f& point) { return Vec3d(point.x, point.y, point.z); }
|
|
||||||
template<typename _Tp> inline _Tp normalized(const _Tp& v) { return v * 1/cv::norm(v); }
|
|
||||||
|
|
||||||
inline bool isNan(float x)
|
|
||||||
{
|
|
||||||
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
|
|
||||||
return ((u[0] & 0x7f800000) == 0x7f800000) && (u[0] & 0x007fffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool isNan(double x)
|
|
||||||
{
|
|
||||||
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
|
|
||||||
return (u[1] & 0x7ff00000) == 0x7ff00000 && (u[0] != 0 || (u[1] & 0x000fffff) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp, int cn> inline bool isNan(const Vec<_Tp, cn>& v)
|
|
||||||
{ return isNan(v.val[0]) || isNan(v.val[1]) || isNan(v.val[2]); }
|
|
||||||
|
|
||||||
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
|
|
||||||
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
|
|
||||||
}
|
}
|
||||||
|
@ -13,48 +13,51 @@
|
|||||||
#include <opencv2/viz/widgets.hpp>
|
#include <opencv2/viz/widgets.hpp>
|
||||||
#include <opencv2/viz/events.hpp>
|
#include <opencv2/viz/events.hpp>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
class CV_EXPORTS Viz3d
|
namespace viz
|
||||||
{
|
{
|
||||||
public:
|
class CV_EXPORTS Viz3d
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
typedef cv::Ptr<Viz3d> Ptr;
|
typedef cv::Ptr<Viz3d> Ptr;
|
||||||
|
|
||||||
Viz3d(const String& window_name = String());
|
Viz3d(const String& window_name = String());
|
||||||
~Viz3d();
|
~Viz3d();
|
||||||
|
|
||||||
void setBackgroundColor(const Color& color = Color::black());
|
void setBackgroundColor(const Color& color = Color::black());
|
||||||
|
|
||||||
bool addPolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
|
bool addPolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
|
||||||
bool updatePolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
|
bool updatePolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
|
||||||
|
|
||||||
bool addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id = "polyline");
|
bool addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id = "polyline");
|
||||||
|
|
||||||
bool addPolygon(const Mat& cloud, const Color& color, const String& id = "polygon");
|
bool addPolygon(const Mat& cloud, const Color& color, const String& id = "polygon");
|
||||||
|
|
||||||
void spin ();
|
void spin ();
|
||||||
void spinOnce (int time = 1, bool force_redraw = false);
|
void spinOnce (int time = 1, bool force_redraw = false);
|
||||||
|
|
||||||
void registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie = 0);
|
void registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie = 0);
|
||||||
void registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie = 0);
|
void registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie = 0);
|
||||||
|
|
||||||
bool wasStopped() const;
|
bool wasStopped() const;
|
||||||
|
|
||||||
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
|
||||||
void removeWidget(const String &id);
|
|
||||||
Widget getWidget(const String &id) const;
|
|
||||||
|
|
||||||
void setWidgetPose(const String &id, const Affine3f &pose);
|
|
||||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
|
||||||
private:
|
|
||||||
Viz3d(const Viz3d&);
|
|
||||||
Viz3d& operator=(const Viz3d&);
|
|
||||||
|
|
||||||
struct VizImpl;
|
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
||||||
VizImpl* impl_;
|
void removeWidget(const String &id);
|
||||||
};
|
Widget getWidget(const String &id) const;
|
||||||
|
|
||||||
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
private:
|
||||||
|
Viz3d(const Viz3d&);
|
||||||
|
Viz3d& operator=(const Viz3d&);
|
||||||
|
|
||||||
|
struct VizImpl;
|
||||||
|
VizImpl* impl_;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,15 +4,18 @@
|
|||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
#include <vtkProp.h>
|
#include <vtkProp.h>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
class Widget;
|
namespace viz
|
||||||
|
|
||||||
//The class is only that depends on VTK in its interface.
|
|
||||||
//It is indended for those users who want to develop own widgets system using VTK library API.
|
|
||||||
struct CV_EXPORTS WidgetAccessor
|
|
||||||
{
|
{
|
||||||
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
|
class Widget;
|
||||||
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
|
|
||||||
};
|
//The class is only that depends on VTK in its interface.
|
||||||
|
//It is indended for those users who want to develop own widgets system using VTK library API.
|
||||||
|
struct CV_EXPORTS WidgetAccessor
|
||||||
|
{
|
||||||
|
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
|
||||||
|
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> prop);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,178 +3,182 @@
|
|||||||
#include <opencv2/viz/types.hpp>
|
#include <opencv2/viz/types.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
namespace viz
|
||||||
/// The base class for all widgets
|
|
||||||
class CV_EXPORTS Widget
|
|
||||||
{
|
{
|
||||||
public:
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
Widget();
|
/// The base class for all widgets
|
||||||
Widget(const Widget &other);
|
class CV_EXPORTS Widget
|
||||||
Widget& operator =(const Widget &other);
|
{
|
||||||
|
public:
|
||||||
~Widget();
|
Widget();
|
||||||
|
Widget(const Widget &other);
|
||||||
|
Widget& operator =(const Widget &other);
|
||||||
|
|
||||||
template<typename _W> _W cast();
|
~Widget();
|
||||||
private:
|
|
||||||
class Impl;
|
|
||||||
Impl *impl_;
|
|
||||||
friend struct WidgetAccessor;
|
|
||||||
|
|
||||||
void create();
|
|
||||||
void release();
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// The base class for all 3D widgets
|
|
||||||
class CV_EXPORTS Widget3D : public Widget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Widget3D() {}
|
|
||||||
|
|
||||||
void setPose(const Affine3f &pose);
|
|
||||||
void updatePose(const Affine3f &pose);
|
|
||||||
Affine3f getPose() const;
|
|
||||||
|
|
||||||
void setColor(const Color &color);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct MatrixConverter;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// The base class for all 2D widgets
|
|
||||||
class CV_EXPORTS Widget2D : public Widget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Widget2D() {}
|
|
||||||
|
|
||||||
void setColor(const Color &color);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS LineWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
|
|
||||||
|
|
||||||
void setLineWidth(float line_width);
|
|
||||||
float getLineWidth();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS PlaneWidget : public Widget3D
|
template<typename _W> _W cast();
|
||||||
{
|
private:
|
||||||
public:
|
class Impl;
|
||||||
PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white());
|
Impl *impl_;
|
||||||
PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
|
friend struct WidgetAccessor;
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS SphereWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS ArrowWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CircleWidget : public Widget3D
|
void create();
|
||||||
{
|
void release();
|
||||||
public:
|
};
|
||||||
CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CylinderWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CubeWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CoordinateSystemWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CoordinateSystemWidget(double scale = 1.0);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS PolyLineWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PolyLineWidget(InputArray points, const Color &color = Color::white());
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct CopyImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS GridWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GridWidget(Vec2i dimensions, Vec2d spacing, const Color &color = Color::white());
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS Text3DWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, const Color &color = Color::white());
|
|
||||||
|
|
||||||
void setText(const String &text);
|
|
||||||
String getText() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS TextWidget : public Widget2D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white());
|
|
||||||
|
|
||||||
void setText(const String &text);
|
|
||||||
String getText() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CloudWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CloudWidget(InputArray cloud, InputArray colors);
|
|
||||||
CloudWidget(InputArray cloud, const Color &color = Color::white());
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct CreateCloudWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS CloudNormalsWidget : public Widget3D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white());
|
|
||||||
|
|
||||||
private:
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
struct ApplyCloudNormals;
|
/// The base class for all 3D widgets
|
||||||
};
|
class CV_EXPORTS Widget3D : public Widget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Widget3D() {}
|
||||||
|
|
||||||
template<> CV_EXPORTS Widget2D Widget::cast<Widget2D>();
|
void setPose(const Affine3f &pose);
|
||||||
template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>();
|
void updatePose(const Affine3f &pose);
|
||||||
template<> CV_EXPORTS LineWidget Widget::cast<LineWidget>();
|
Affine3f getPose() const;
|
||||||
template<> CV_EXPORTS PlaneWidget Widget::cast<PlaneWidget>();
|
|
||||||
template<> CV_EXPORTS SphereWidget Widget::cast<SphereWidget>();
|
void setColor(const Color &color);
|
||||||
template<> CV_EXPORTS CylinderWidget Widget::cast<CylinderWidget>();
|
|
||||||
template<> CV_EXPORTS ArrowWidget Widget::cast<ArrowWidget>();
|
private:
|
||||||
template<> CV_EXPORTS CircleWidget Widget::cast<CircleWidget>();
|
struct MatrixConverter;
|
||||||
template<> CV_EXPORTS CubeWidget Widget::cast<CubeWidget>();
|
|
||||||
template<> CV_EXPORTS CoordinateSystemWidget Widget::cast<CoordinateSystemWidget>();
|
};
|
||||||
template<> CV_EXPORTS PolyLineWidget Widget::cast<PolyLineWidget>();
|
|
||||||
template<> CV_EXPORTS GridWidget Widget::cast<GridWidget>();
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
template<> CV_EXPORTS Text3DWidget Widget::cast<Text3DWidget>();
|
/// The base class for all 2D widgets
|
||||||
template<> CV_EXPORTS TextWidget Widget::cast<TextWidget>();
|
class CV_EXPORTS Widget2D : public Widget
|
||||||
template<> CV_EXPORTS CloudWidget Widget::cast<CloudWidget>();
|
{
|
||||||
template<> CV_EXPORTS CloudNormalsWidget Widget::cast<CloudNormalsWidget>();
|
public:
|
||||||
}
|
Widget2D() {}
|
||||||
|
|
||||||
|
void setColor(const Color &color);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS LineWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
|
||||||
|
|
||||||
|
void setLineWidth(float line_width);
|
||||||
|
float getLineWidth();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS PlaneWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white());
|
||||||
|
PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS SphereWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS ArrowWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CircleWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CylinderWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CubeWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CoordinateSystemWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CoordinateSystemWidget(double scale = 1.0);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS PolyLineWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PolyLineWidget(InputArray points, const Color &color = Color::white());
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct CopyImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS GridWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GridWidget(Vec2i dimensions, Vec2d spacing, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS Text3DWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, const Color &color = Color::white());
|
||||||
|
|
||||||
|
void setText(const String &text);
|
||||||
|
String getText() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS TextWidget : public Widget2D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white());
|
||||||
|
|
||||||
|
void setText(const String &text);
|
||||||
|
String getText() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CloudWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CloudWidget(InputArray cloud, InputArray colors);
|
||||||
|
CloudWidget(InputArray cloud, const Color &color = Color::white());
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct CreateCloudWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS CloudNormalsWidget : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CloudNormalsWidget(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white());
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct ApplyCloudNormals;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> CV_EXPORTS Widget2D Widget::cast<Widget2D>();
|
||||||
|
template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>();
|
||||||
|
template<> CV_EXPORTS LineWidget Widget::cast<LineWidget>();
|
||||||
|
template<> CV_EXPORTS PlaneWidget Widget::cast<PlaneWidget>();
|
||||||
|
template<> CV_EXPORTS SphereWidget Widget::cast<SphereWidget>();
|
||||||
|
template<> CV_EXPORTS CylinderWidget Widget::cast<CylinderWidget>();
|
||||||
|
template<> CV_EXPORTS ArrowWidget Widget::cast<ArrowWidget>();
|
||||||
|
template<> CV_EXPORTS CircleWidget Widget::cast<CircleWidget>();
|
||||||
|
template<> CV_EXPORTS CubeWidget Widget::cast<CubeWidget>();
|
||||||
|
template<> CV_EXPORTS CoordinateSystemWidget Widget::cast<CoordinateSystemWidget>();
|
||||||
|
template<> CV_EXPORTS PolyLineWidget Widget::cast<PolyLineWidget>();
|
||||||
|
template<> CV_EXPORTS GridWidget Widget::cast<GridWidget>();
|
||||||
|
template<> CV_EXPORTS Text3DWidget Widget::cast<Text3DWidget>();
|
||||||
|
template<> CV_EXPORTS TextWidget Widget::cast<TextWidget>();
|
||||||
|
template<> CV_EXPORTS CloudWidget Widget::cast<CloudWidget>();
|
||||||
|
template<> CV_EXPORTS CloudNormalsWidget Widget::cast<CloudNormalsWidget>();
|
||||||
|
|
||||||
|
} /* namespace viz */
|
||||||
|
} /* namespace cv */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Eigen::Matrix4d temp_viz::vtkToEigen (vtkMatrix4x4* vtk_matrix)
|
//Eigen::Matrix4d cv::viz::vtkToEigen (vtkMatrix4x4* vtk_matrix)
|
||||||
//{
|
//{
|
||||||
// Eigen::Matrix4d eigen_matrix = Eigen::Matrix4d::Identity ();
|
// Eigen::Matrix4d eigen_matrix = Eigen::Matrix4d::Identity ();
|
||||||
// for (int i=0; i < 4; i++)
|
// for (int i=0; i < 4; i++)
|
||||||
@ -16,7 +16,7 @@
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Eigen::Vector2i temp_viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
//Eigen::Vector2i cv::viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
||||||
//{
|
//{
|
||||||
// // Transform world to clipping coordinates
|
// // Transform world to clipping coordinates
|
||||||
// Eigen::Vector4d world (view_projection_matrix * world_pt);
|
// Eigen::Vector4d world (view_projection_matrix * world_pt);
|
||||||
@ -34,7 +34,7 @@
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//void temp_viz::getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24])
|
//void cv::viz::getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24])
|
||||||
//{
|
//{
|
||||||
// // Set up the normals
|
// // Set up the normals
|
||||||
// Eigen::Vector4d normals[6];
|
// Eigen::Vector4d normals[6];
|
||||||
@ -65,7 +65,7 @@
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//int temp_viz::cullFrustum (double frustum[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
|
//int cv::viz::cullFrustum (double frustum[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
|
||||||
//{
|
//{
|
||||||
// int result = PCL_INSIDE_FRUSTUM;
|
// int result = PCL_INSIDE_FRUSTUM;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//void
|
//void
|
||||||
//temp_viz::getModelViewPosition (Eigen::Matrix4d model_view_matrix, Eigen::Vector3d &position)
|
//cv::viz::getModelViewPosition (Eigen::Matrix4d model_view_matrix, Eigen::Vector3d &position)
|
||||||
//{
|
//{
|
||||||
// //Compute eye or position from model view matrix
|
// //Compute eye or position from model view matrix
|
||||||
// Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix.inverse();
|
// Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix.inverse();
|
||||||
@ -174,7 +174,7 @@ int hull_vertex_table[43][7] = {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//float
|
//float
|
||||||
//temp_viz::viewScreenArea (
|
//cv::viz::viewScreenArea (
|
||||||
// const Eigen::Vector3d &eye,
|
// const Eigen::Vector3d &eye,
|
||||||
// const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb,
|
// const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb,
|
||||||
// const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
// const Eigen::Matrix4d &view_projection_matrix, int width, int height)
|
||||||
@ -261,7 +261,7 @@ int hull_vertex_table[43][7] = {
|
|||||||
// for (int i = 0; i < num; i++)
|
// for (int i = 0; i < num; i++)
|
||||||
// {
|
// {
|
||||||
// Eigen::Vector4d world_pt = bounding_box[hull_vertex_table[pos][i]];
|
// Eigen::Vector4d world_pt = bounding_box[hull_vertex_table[pos][i]];
|
||||||
// Eigen::Vector2i screen_pt = temp_viz::worldToView(world_pt, view_projection_matrix, width, height);
|
// Eigen::Vector2i screen_pt = cv::viz::worldToView(world_pt, view_projection_matrix, width, height);
|
||||||
// // cout << "point[" << i << "]: " << screen_pt.x() << " " << screen_pt.y() << endl;
|
// // cout << "point[" << i << "]: " << screen_pt.x() << " " << screen_pt.y() << endl;
|
||||||
// dst[i] = Eigen::Vector2d(screen_pt.x (), screen_pt.y ());
|
// dst[i] = Eigen::Vector2d(screen_pt.x (), screen_pt.y ());
|
||||||
// }
|
// }
|
||||||
@ -276,7 +276,7 @@ int hull_vertex_table[43][7] = {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Camera::computeViewMatrix (Affine3d& view_mat) const
|
void cv::viz::Camera::computeViewMatrix (Affine3d& view_mat) const
|
||||||
{
|
{
|
||||||
//constructs view matrix from camera pos, view up, and the point it is looking at
|
//constructs view matrix from camera pos, view up, and the point it is looking at
|
||||||
//this code is based off of gluLookAt http://www.opengl.org/wiki/GluLookAt_code
|
//this code is based off of gluLookAt http://www.opengl.org/wiki/GluLookAt_code
|
||||||
@ -297,7 +297,7 @@ void temp_viz::Camera::computeViewMatrix (Affine3d& view_mat) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Camera::computeProjectionMatrix (Matx44d& proj) const
|
void cv::viz::Camera::computeProjectionMatrix (Matx44d& proj) const
|
||||||
{
|
{
|
||||||
double top = clip[0] * tan (0.5 * fovy);
|
double top = clip[0] * tan (0.5 * fovy);
|
||||||
double left = -(top * window_size[0]) / window_size[1];
|
double left = -(top * window_size[0]) / window_size[1];
|
||||||
|
@ -3,121 +3,124 @@
|
|||||||
#include <opencv2/core/cvdef.h>
|
#include <opencv2/core/cvdef.h>
|
||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
#include <opencv2/viz/types.hpp>
|
#include <opencv2/viz/types.hpp>
|
||||||
//#include <vtkMatrix4x4.h>
|
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
//CV_EXPORTS Eigen::Matrix4d vtkToEigen (vtkMatrix4x4* vtk_matrix);
|
namespace viz
|
||||||
//CV_EXPORTS Eigen::Vector2i worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
|
|
||||||
//CV_EXPORTS void getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24]);
|
|
||||||
|
|
||||||
// enum FrustumCull
|
|
||||||
// {
|
|
||||||
// PCL_INSIDE_FRUSTUM,
|
|
||||||
// PCL_INTERSECT_FRUSTUM,
|
|
||||||
// PCL_OUTSIDE_FRUSTUM
|
|
||||||
// };
|
|
||||||
|
|
||||||
//CV_EXPORTS int cullFrustum (double planes[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb);
|
|
||||||
//CV_EXPORTS float viewScreenArea (const Eigen::Vector3d &eye, const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
|
|
||||||
|
|
||||||
enum RenderingProperties
|
|
||||||
{
|
{
|
||||||
VIZ_POINT_SIZE,
|
//CV_EXPORTS Eigen::Matrix4d vtkToEigen (vtkMatrix4x4* vtk_matrix);
|
||||||
VIZ_OPACITY,
|
//CV_EXPORTS Eigen::Vector2i worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
|
||||||
VIZ_LINE_WIDTH,
|
//CV_EXPORTS void getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24]);
|
||||||
VIZ_FONT_SIZE,
|
|
||||||
VIZ_COLOR,
|
|
||||||
VIZ_REPRESENTATION,
|
|
||||||
VIZ_IMMEDIATE_RENDERING,
|
|
||||||
VIZ_SHADING
|
|
||||||
};
|
|
||||||
|
|
||||||
enum RenderingRepresentationProperties
|
// enum FrustumCull
|
||||||
{
|
// {
|
||||||
REPRESENTATION_POINTS,
|
// PCL_INSIDE_FRUSTUM,
|
||||||
REPRESENTATION_WIREFRAME,
|
// PCL_INTERSECT_FRUSTUM,
|
||||||
REPRESENTATION_SURFACE
|
// PCL_OUTSIDE_FRUSTUM
|
||||||
};
|
// };
|
||||||
|
|
||||||
enum ShadingRepresentationProperties
|
//CV_EXPORTS int cullFrustum (double planes[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb);
|
||||||
{
|
//CV_EXPORTS float viewScreenArea (const Eigen::Vector3d &eye, const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
|
||||||
SHADING_FLAT,
|
|
||||||
SHADING_GOURAUD,
|
|
||||||
SHADING_PHONG
|
|
||||||
};
|
|
||||||
|
|
||||||
class CV_EXPORTS Camera
|
enum RenderingProperties
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Focal point or lookAt. The view direction can be obtained by (focal-pos).normalized () */
|
|
||||||
Vec3d focal;
|
|
||||||
|
|
||||||
/** \brief Position of the camera. */
|
|
||||||
Vec3d pos;
|
|
||||||
|
|
||||||
/** \brief Up vector of the camera. */
|
|
||||||
Vec3d view_up;
|
|
||||||
|
|
||||||
/** \brief Near/far clipping planes depths */
|
|
||||||
Vec2d clip;
|
|
||||||
|
|
||||||
/** \brief Field of view angle in y direction (radians). */
|
|
||||||
double fovy;
|
|
||||||
|
|
||||||
// the following variables are the actual position and size of the window on the screen and NOT the viewport!
|
|
||||||
// except for the size, which is the same the viewport is assumed to be centered and same size as the window.
|
|
||||||
Vec2i window_size;
|
|
||||||
Vec2i window_pos;
|
|
||||||
|
|
||||||
/** \brief Computes View matrix for Camera (Based on gluLookAt)
|
|
||||||
* \param[out] view_mat the resultant matrix
|
|
||||||
*/
|
|
||||||
void computeViewMatrix(Affine3d& view_mat) const;
|
|
||||||
|
|
||||||
/** \brief Computes Projection Matrix for Camera
|
|
||||||
* \param[out] proj the resultant matrix
|
|
||||||
*/
|
|
||||||
void computeProjectionMatrix(Matx44d& proj) const;
|
|
||||||
|
|
||||||
/** \brief converts point to window coordiantes
|
|
||||||
* \param[in] pt xyz point to be converted
|
|
||||||
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
|
|
||||||
*
|
|
||||||
* This function computes the projection and view matrix every time.
|
|
||||||
* It is very inefficient to use this for every point in the point cloud!
|
|
||||||
*/
|
|
||||||
void cvtWindowCoordinates (const cv::Point3f& pt, Vec4d& window_cord) const
|
|
||||||
{
|
{
|
||||||
Affine3d view;
|
VIZ_POINT_SIZE,
|
||||||
computeViewMatrix (view);
|
VIZ_OPACITY,
|
||||||
|
VIZ_LINE_WIDTH,
|
||||||
|
VIZ_FONT_SIZE,
|
||||||
|
VIZ_COLOR,
|
||||||
|
VIZ_REPRESENTATION,
|
||||||
|
VIZ_IMMEDIATE_RENDERING,
|
||||||
|
VIZ_SHADING
|
||||||
|
};
|
||||||
|
|
||||||
Matx44d proj;
|
enum RenderingRepresentationProperties
|
||||||
computeProjectionMatrix (proj);
|
|
||||||
cvtWindowCoordinates (pt, proj * view.matrix, window_cord);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief converts point to window coordiantes
|
|
||||||
* \param[in] pt xyz point to be converted
|
|
||||||
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
|
|
||||||
* \param[in] composite_mat composite transformation matrix (proj*view)
|
|
||||||
*
|
|
||||||
* Use this function to compute window coordinates with a precomputed
|
|
||||||
* transformation function. The typical composite matrix will be
|
|
||||||
* the projection matrix * the view matrix. However, additional
|
|
||||||
* matrices like a camera disortion matrix can also be added.
|
|
||||||
*/
|
|
||||||
void cvtWindowCoordinates (const Point3f& pt, const Matx44d& composite_mat, Vec4d& window_cord) const
|
|
||||||
{
|
{
|
||||||
Vec4d pte (pt.x, pt.y, pt.z, 1);
|
REPRESENTATION_POINTS,
|
||||||
window_cord = composite_mat * pte;
|
REPRESENTATION_WIREFRAME,
|
||||||
window_cord = window_cord/window_cord[3];
|
REPRESENTATION_SURFACE
|
||||||
|
};
|
||||||
|
|
||||||
window_cord[0] = (window_cord[0]+1.0) / 2.0*window_size[0];
|
enum ShadingRepresentationProperties
|
||||||
window_cord[1] = (window_cord[1]+1.0) / 2.0*window_size[1];
|
{
|
||||||
window_cord[2] = (window_cord[2]+1.0) / 2.0;
|
SHADING_FLAT,
|
||||||
}
|
SHADING_GOURAUD,
|
||||||
};
|
SHADING_PHONG
|
||||||
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS Camera
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** Focal point or lookAt. The view direction can be obtained by (focal-pos).normalized () */
|
||||||
|
Vec3d focal;
|
||||||
|
|
||||||
|
/** \brief Position of the camera. */
|
||||||
|
Vec3d pos;
|
||||||
|
|
||||||
|
/** \brief Up vector of the camera. */
|
||||||
|
Vec3d view_up;
|
||||||
|
|
||||||
|
/** \brief Near/far clipping planes depths */
|
||||||
|
Vec2d clip;
|
||||||
|
|
||||||
|
/** \brief Field of view angle in y direction (radians). */
|
||||||
|
double fovy;
|
||||||
|
|
||||||
|
// the following variables are the actual position and size of the window on the screen and NOT the viewport!
|
||||||
|
// except for the size, which is the same the viewport is assumed to be centered and same size as the window.
|
||||||
|
Vec2i window_size;
|
||||||
|
Vec2i window_pos;
|
||||||
|
|
||||||
|
/** \brief Computes View matrix for Camera (Based on gluLookAt)
|
||||||
|
* \param[out] view_mat the resultant matrix
|
||||||
|
*/
|
||||||
|
void computeViewMatrix(Affine3d& view_mat) const;
|
||||||
|
|
||||||
|
/** \brief Computes Projection Matrix for Camera
|
||||||
|
* \param[out] proj the resultant matrix
|
||||||
|
*/
|
||||||
|
void computeProjectionMatrix(Matx44d& proj) const;
|
||||||
|
|
||||||
|
/** \brief converts point to window coordiantes
|
||||||
|
* \param[in] pt xyz point to be converted
|
||||||
|
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
|
||||||
|
*
|
||||||
|
* This function computes the projection and view matrix every time.
|
||||||
|
* It is very inefficient to use this for every point in the point cloud!
|
||||||
|
*/
|
||||||
|
void cvtWindowCoordinates (const cv::Point3f& pt, Vec4d& window_cord) const
|
||||||
|
{
|
||||||
|
Affine3d view;
|
||||||
|
computeViewMatrix (view);
|
||||||
|
|
||||||
|
Matx44d proj;
|
||||||
|
computeProjectionMatrix (proj);
|
||||||
|
cvtWindowCoordinates (pt, proj * view.matrix, window_cord);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief converts point to window coordiantes
|
||||||
|
* \param[in] pt xyz point to be converted
|
||||||
|
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
|
||||||
|
* \param[in] composite_mat composite transformation matrix (proj*view)
|
||||||
|
*
|
||||||
|
* Use this function to compute window coordinates with a precomputed
|
||||||
|
* transformation function. The typical composite matrix will be
|
||||||
|
* the projection matrix * the view matrix. However, additional
|
||||||
|
* matrices like a camera disortion matrix can also be added.
|
||||||
|
*/
|
||||||
|
void cvtWindowCoordinates (const Point3f& pt, const Matx44d& composite_mat, Vec4d& window_cord) const
|
||||||
|
{
|
||||||
|
Vec4d pte (pt.x, pt.y, pt.z, 1);
|
||||||
|
window_cord = composite_mat * pte;
|
||||||
|
window_cord = window_cord/window_cord[3];
|
||||||
|
|
||||||
|
window_cord[0] = (window_cord[0]+1.0) / 2.0*window_size[0];
|
||||||
|
window_cord[1] = (window_cord[1]+1.0) / 2.0*window_size[1];
|
||||||
|
window_cord[2] = (window_cord[2]+1.0) / 2.0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::Initialize ()
|
void cv::viz::InteractorStyle::Initialize ()
|
||||||
{
|
{
|
||||||
modifier_ = temp_viz::InteractorStyle::KB_MOD_ALT;
|
modifier_ = cv::viz::InteractorStyle::KB_MOD_ALT;
|
||||||
// Set windows size (width, height) to unknown (-1)
|
// Set windows size (width, height) to unknown (-1)
|
||||||
win_size_ = Vec2i(-1, -1);
|
win_size_ = Vec2i(-1, -1);
|
||||||
win_pos_ = Vec2i(0, 0);
|
win_pos_ = Vec2i(0, 0);
|
||||||
@ -33,7 +33,7 @@ void temp_viz::InteractorStyle::Initialize ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::saveScreenshot (const std::string &file)
|
void cv::viz::InteractorStyle::saveScreenshot (const std::string &file)
|
||||||
{
|
{
|
||||||
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
||||||
wif_->SetInput (Interactor->GetRenderWindow ());
|
wif_->SetInput (Interactor->GetRenderWindow ());
|
||||||
@ -44,29 +44,29 @@ void temp_viz::InteractorStyle::saveScreenshot (const std::string &file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::zoomIn ()
|
void cv::viz::InteractorStyle::zoomIn ()
|
||||||
{
|
{
|
||||||
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
||||||
// Zoom in
|
// Zoom in
|
||||||
StartDolly ();
|
StartDolly ();
|
||||||
double factor = 10.0 * 0.2 * .5;
|
double factor = 10.0 * 0.2 * .5;
|
||||||
Dolly (pow (1.1, factor));
|
Dolly (std::pow (1.1, factor));
|
||||||
EndDolly ();
|
EndDolly ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::zoomOut ()
|
void cv::viz::InteractorStyle::zoomOut ()
|
||||||
{
|
{
|
||||||
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
||||||
// Zoom out
|
// Zoom out
|
||||||
StartDolly ();
|
StartDolly ();
|
||||||
double factor = 10.0 * -0.2 * .5;
|
double factor = 10.0 * -0.2 * .5;
|
||||||
Dolly (pow (1.1, factor));
|
Dolly (std::pow (1.1, factor));
|
||||||
EndDolly ();
|
EndDolly ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnChar ()
|
void cv::viz::InteractorStyle::OnChar ()
|
||||||
{
|
{
|
||||||
// Make sure we ignore the same events we handle in OnKeyDown to avoid calling things twice
|
// Make sure we ignore the same events we handle in OnKeyDown to avoid calling things twice
|
||||||
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
|
||||||
@ -133,7 +133,7 @@ void temp_viz::InteractorStyle::OnChar ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
void cv::viz::InteractorStyle::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
||||||
{
|
{
|
||||||
// Register the callback function and store the user data
|
// Register the callback function and store the user data
|
||||||
mouseCallback_ = callback;
|
mouseCallback_ = callback;
|
||||||
@ -141,7 +141,7 @@ void temp_viz::InteractorStyle::registerMouseCallback(void (*callback)(const Mou
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void *cookie)
|
void cv::viz::InteractorStyle::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void *cookie)
|
||||||
{
|
{
|
||||||
// Register the callback function and store the user data
|
// Register the callback function and store the user data
|
||||||
keyboardCallback_ = callback;
|
keyboardCallback_ = callback;
|
||||||
@ -150,7 +150,7 @@ void temp_viz::InteractorStyle::registerKeyboardCallback(void (*callback)(const
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void
|
void
|
||||||
temp_viz::InteractorStyle::OnKeyDown ()
|
cv::viz::InteractorStyle::OnKeyDown ()
|
||||||
{
|
{
|
||||||
if (!init_)
|
if (!init_)
|
||||||
{
|
{
|
||||||
@ -507,7 +507,7 @@ temp_viz::InteractorStyle::OnKeyDown ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnKeyUp ()
|
void cv::viz::InteractorStyle::OnKeyUp ()
|
||||||
{
|
{
|
||||||
KeyboardEvent event (false, Interactor->GetKeySym (), Interactor->GetKeyCode (), Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
KeyboardEvent event (false, Interactor->GetKeySym (), Interactor->GetKeyCode (), Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
// Check if there is a keyboard callback registered
|
// Check if there is a keyboard callback registered
|
||||||
@ -518,7 +518,7 @@ void temp_viz::InteractorStyle::OnKeyUp ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnMouseMove ()
|
void cv::viz::InteractorStyle::OnMouseMove ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseMove, MouseEvent::NoButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseMove, MouseEvent::NoButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -528,7 +528,7 @@ void temp_viz::InteractorStyle::OnMouseMove ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnLeftButtonDown ()
|
void cv::viz::InteractorStyle::OnLeftButtonDown ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent::Type type = (Interactor->GetRepeatCount() == 0) ? MouseEvent::MouseButtonPress : MouseEvent::MouseDblClick;
|
MouseEvent::Type type = (Interactor->GetRepeatCount() == 0) ? MouseEvent::MouseButtonPress : MouseEvent::MouseDblClick;
|
||||||
@ -539,7 +539,7 @@ void temp_viz::InteractorStyle::OnLeftButtonDown ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnLeftButtonUp ()
|
void cv::viz::InteractorStyle::OnLeftButtonUp ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::LeftButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::LeftButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -549,7 +549,7 @@ void temp_viz::InteractorStyle::OnLeftButtonUp ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnMiddleButtonDown ()
|
void cv::viz::InteractorStyle::OnMiddleButtonDown ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ void temp_viz::InteractorStyle::OnMiddleButtonDown ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnMiddleButtonUp ()
|
void cv::viz::InteractorStyle::OnMiddleButtonUp ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::MiddleButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::MiddleButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -571,7 +571,7 @@ void temp_viz::InteractorStyle::OnMiddleButtonUp ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnRightButtonDown ()
|
void cv::viz::InteractorStyle::OnRightButtonDown ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
|
|
||||||
@ -583,7 +583,7 @@ void temp_viz::InteractorStyle::OnRightButtonDown ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnRightButtonUp ()
|
void cv::viz::InteractorStyle::OnRightButtonUp ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::RightButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseButtonRelease, MouseEvent::RightButton, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -593,7 +593,7 @@ void temp_viz::InteractorStyle::OnRightButtonUp ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnMouseWheelForward ()
|
void cv::viz::InteractorStyle::OnMouseWheelForward ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseScrollUp, MouseEvent::VScroll, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseScrollUp, MouseEvent::VScroll, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -625,7 +625,7 @@ void temp_viz::InteractorStyle::OnMouseWheelForward ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnMouseWheelBackward ()
|
void cv::viz::InteractorStyle::OnMouseWheelBackward ()
|
||||||
{
|
{
|
||||||
Vec2i p(Interactor->GetEventPosition());
|
Vec2i p(Interactor->GetEventPosition());
|
||||||
MouseEvent event (MouseEvent::MouseScrollDown, MouseEvent::VScroll, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
MouseEvent event (MouseEvent::MouseScrollDown, MouseEvent::VScroll, p, Interactor->GetAltKey (), Interactor->GetControlKey (), Interactor->GetShiftKey ());
|
||||||
@ -658,7 +658,7 @@ void temp_viz::InteractorStyle::OnMouseWheelBackward ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::InteractorStyle::OnTimer ()
|
void cv::viz::InteractorStyle::OnTimer ()
|
||||||
{
|
{
|
||||||
if (!init_)
|
if (!init_)
|
||||||
{
|
{
|
||||||
@ -676,10 +676,15 @@ void temp_viz::InteractorStyle::OnTimer ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace temp_viz
|
|
||||||
{
|
|
||||||
// Standard VTK macro for *New ()
|
|
||||||
vtkStandardNewMacro (InteractorStyle);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace cv
|
||||||
|
{
|
||||||
|
namespace viz
|
||||||
|
{
|
||||||
|
//Standard VTK macro for *New()
|
||||||
|
vtkStandardNewMacro(InteractorStyle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
#include "viz_types.h"
|
#include "viz_types.h"
|
||||||
#include <opencv2/viz/events.hpp>
|
#include <opencv2/viz/events.hpp>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
|
namespace viz
|
||||||
|
{
|
||||||
/** \brief PCLVisualizerInteractorStyle defines an unique, custom VTK
|
/** \brief PCLVisualizerInteractorStyle defines an unique, custom VTK
|
||||||
* based interactory style for PCL Visualizer applications. Besides
|
* based interactory style for PCL Visualizer applications. Besides
|
||||||
* defining the rendering style, we also create a list of custom actions
|
* defining the rendering style, we also create a list of custom actions
|
||||||
@ -54,7 +56,7 @@ namespace temp_viz
|
|||||||
/** \brief Pass a pointer to the actor map
|
/** \brief Pass a pointer to the actor map
|
||||||
* \param[in] actors the actor map that will be used with this style
|
* \param[in] actors the actor map that will be used with this style
|
||||||
*/
|
*/
|
||||||
inline void setCloudActorMap (const cv::Ptr<CloudActorMap>& actors) { actors_ = actors; }
|
inline void setCloudActorMap (const Ptr<CloudActorMap>& actors) { actors_ = actors; }
|
||||||
|
|
||||||
/** \brief Pass a set of renderers to the interactor style.
|
/** \brief Pass a set of renderers to the interactor style.
|
||||||
* \param[in] rens the vtkRendererCollection to use
|
* \param[in] rens the vtkRendererCollection to use
|
||||||
@ -152,4 +154,5 @@ namespace temp_viz
|
|||||||
/** \brief MouseEvent callback user data */
|
/** \brief MouseEvent callback user data */
|
||||||
void *mouse_callback_cookie_;
|
void *mouse_callback_cookie_;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <vtkPointData.h>
|
#include <vtkPointData.h>
|
||||||
#include <vtkCellArray.h>
|
#include <vtkCellArray.h>
|
||||||
|
|
||||||
temp_viz::Mesh3d::Ptr temp_viz::Mesh3d::mesh_load(const String& file)
|
cv::viz::Mesh3d::Ptr cv::viz::Mesh3d::mesh_load(const String& file)
|
||||||
{
|
{
|
||||||
Mesh3d::Ptr mesh = new Mesh3d();
|
Mesh3d::Ptr mesh = new Mesh3d();
|
||||||
|
|
||||||
|
@ -158,23 +158,26 @@
|
|||||||
#include "opencv2/viz/widget_accessor.hpp"
|
#include "opencv2/viz/widget_accessor.hpp"
|
||||||
#include <opencv2/calib3d.hpp>
|
#include <opencv2/calib3d.hpp>
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
template<typename _Tp> Vec<_Tp, 3>* vtkpoints_data(vtkSmartPointer<vtkPoints>& points);
|
namespace viz
|
||||||
|
|
||||||
template<> static inline Vec3f* vtkpoints_data<float>(vtkSmartPointer<vtkPoints>& points)
|
|
||||||
{
|
{
|
||||||
CV_Assert(points->GetDataType() == VTK_FLOAT);
|
template<typename _Tp> Vec<_Tp, 3>* vtkpoints_data(vtkSmartPointer<vtkPoints>& points);
|
||||||
vtkDataArray *data = points->GetData();
|
|
||||||
float *pointer = static_cast<vtkFloatArray*>(data)->GetPointer(0);
|
|
||||||
return reinterpret_cast<Vec3f*>(pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> static inline Vec3d* vtkpoints_data<double>(vtkSmartPointer<vtkPoints>& points)
|
template<> static inline Vec3f* vtkpoints_data<float>(vtkSmartPointer<vtkPoints>& points)
|
||||||
{
|
{
|
||||||
CV_Assert(points->GetDataType() == VTK_DOUBLE);
|
CV_Assert(points->GetDataType() == VTK_FLOAT);
|
||||||
vtkDataArray *data = points->GetData();
|
vtkDataArray *data = points->GetData();
|
||||||
double *pointer = static_cast<vtkDoubleArray*>(data)->GetPointer(0);
|
float *pointer = static_cast<vtkFloatArray*>(data)->GetPointer(0);
|
||||||
return reinterpret_cast<Vec3d*>(pointer);
|
return reinterpret_cast<Vec3f*>(pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> static inline Vec3d* vtkpoints_data<double>(vtkSmartPointer<vtkPoints>& points)
|
||||||
|
{
|
||||||
|
CV_Assert(points->GetDataType() == VTK_DOUBLE);
|
||||||
|
vtkDataArray *data = points->GetData();
|
||||||
|
double *pointer = static_cast<vtkDoubleArray*>(data)->GetPointer(0);
|
||||||
|
return reinterpret_cast<Vec3d*>(pointer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// line widget implementation
|
/// line widget implementation
|
||||||
temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color)
|
cv::viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
|
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
|
||||||
line->SetPoint1 (pt1.x, pt1.y, pt1.z);
|
line->SetPoint1 (pt1.x, pt1.y, pt1.z);
|
||||||
@ -19,21 +19,21 @@ temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const C
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::LineWidget::setLineWidth(float line_width)
|
void cv::viz::LineWidget::setLineWidth(float line_width)
|
||||||
{
|
{
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
actor->GetProperty()->SetLineWidth(line_width);
|
actor->GetProperty()->SetLineWidth(line_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
float temp_viz::LineWidget::getLineWidth()
|
float cv::viz::LineWidget::getLineWidth()
|
||||||
{
|
{
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
return actor->GetProperty()->GetLineWidth();
|
return actor->GetProperty()->GetLineWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::LineWidget temp_viz::Widget::cast<temp_viz::LineWidget>()
|
template<> cv::viz::LineWidget cv::viz::Widget::cast<cv::viz::LineWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<LineWidget&>(widget);
|
return static_cast<LineWidget&>(widget);
|
||||||
@ -42,11 +42,11 @@ template<> temp_viz::LineWidget temp_viz::Widget::cast<temp_viz::LineWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// plane widget implementation
|
/// plane widget implementation
|
||||||
|
|
||||||
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color)
|
cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
||||||
plane->SetNormal (coefs[0], coefs[1], coefs[2]);
|
plane->SetNormal (coefs[0], coefs[1], coefs[2]);
|
||||||
double norm = cv::norm(cv::Vec3f(coefs.val));
|
double norm = cv::norm(Vec3f(coefs.val));
|
||||||
plane->Push (-coefs[3] / norm);
|
plane->Push (-coefs[3] / norm);
|
||||||
|
|
||||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||||
@ -60,15 +60,15 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color)
|
cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
||||||
cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]);
|
Point3f coefs3(coefs[0], coefs[1], coefs[2]);
|
||||||
double norm_sqr = 1.0 / coefs3.dot (coefs3);
|
double norm_sqr = 1.0 / coefs3.dot (coefs3);
|
||||||
plane->SetNormal(coefs[0], coefs[1], coefs[2]);
|
plane->SetNormal(coefs[0], coefs[1], coefs[2]);
|
||||||
|
|
||||||
double t = coefs3.dot(pt) + coefs[3];
|
double t = coefs3.dot(pt) + coefs[3];
|
||||||
cv::Vec3f p_center = pt - coefs3 * t * norm_sqr;
|
Vec3f p_center = pt - coefs3 * t * norm_sqr;
|
||||||
plane->SetCenter (p_center[0], p_center[1], p_center[2]);
|
plane->SetCenter (p_center[0], p_center[1], p_center[2]);
|
||||||
|
|
||||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||||
@ -82,7 +82,7 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::PlaneWidget temp_viz::Widget::cast<temp_viz::PlaneWidget>()
|
template<> cv::viz::PlaneWidget cv::viz::Widget::cast<cv::viz::PlaneWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<PlaneWidget&>(widget);
|
return static_cast<PlaneWidget&>(widget);
|
||||||
@ -91,7 +91,7 @@ template<> temp_viz::PlaneWidget temp_viz::Widget::cast<temp_viz::PlaneWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// sphere widget implementation
|
/// sphere widget implementation
|
||||||
|
|
||||||
temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution, const Color &color)
|
cv::viz::SphereWidget::SphereWidget(const Point3f ¢er, float radius, int sphere_resolution, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New ();
|
vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New ();
|
||||||
sphere->SetRadius (radius);
|
sphere->SetRadius (radius);
|
||||||
@ -111,7 +111,7 @@ temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, in
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::SphereWidget temp_viz::Widget::cast<temp_viz::SphereWidget>()
|
template<> cv::viz::SphereWidget cv::viz::Widget::cast<cv::viz::SphereWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<SphereWidget&>(widget);
|
return static_cast<SphereWidget&>(widget);
|
||||||
@ -120,7 +120,7 @@ template<> temp_viz::SphereWidget temp_viz::Widget::cast<temp_viz::SphereWidget>
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// arrow widget implementation
|
/// arrow widget implementation
|
||||||
|
|
||||||
temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color)
|
cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New ();
|
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New ();
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::ArrowWidget temp_viz::Widget::cast<temp_viz::ArrowWidget>()
|
template<> cv::viz::ArrowWidget cv::viz::Widget::cast<cv::viz::ArrowWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<ArrowWidget&>(widget);
|
return static_cast<ArrowWidget&>(widget);
|
||||||
@ -189,7 +189,7 @@ template<> temp_viz::ArrowWidget temp_viz::Widget::cast<temp_viz::ArrowWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// circle widget implementation
|
/// circle widget implementation
|
||||||
|
|
||||||
temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius, double thickness, const temp_viz::Color& color)
|
cv::viz::CircleWidget::CircleWidget(const Point3f& pt, double radius, double thickness, const Color& color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkDiskSource> disk = vtkSmartPointer<vtkDiskSource>::New ();
|
vtkSmartPointer<vtkDiskSource> disk = vtkSmartPointer<vtkDiskSource>::New ();
|
||||||
// Maybe the resolution should be lower e.g. 50 or 25
|
// Maybe the resolution should be lower e.g. 50 or 25
|
||||||
@ -216,7 +216,7 @@ temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius,
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CircleWidget temp_viz::Widget::cast<temp_viz::CircleWidget>()
|
template<> cv::viz::CircleWidget cv::viz::Widget::cast<cv::viz::CircleWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CircleWidget&>(widget);
|
return static_cast<CircleWidget&>(widget);
|
||||||
@ -225,9 +225,9 @@ template<> temp_viz::CircleWidget temp_viz::Widget::cast<temp_viz::CircleWidget>
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cylinder widget implementation
|
/// cylinder widget implementation
|
||||||
|
|
||||||
temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color)
|
cv::viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color)
|
||||||
{
|
{
|
||||||
const cv::Point3f pt2 = pt_on_axis + axis_direction;
|
const Point3f pt2 = pt_on_axis + axis_direction;
|
||||||
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
|
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
|
||||||
line->SetPoint1 (pt_on_axis.x, pt_on_axis.y, pt_on_axis.z);
|
line->SetPoint1 (pt_on_axis.x, pt_on_axis.y, pt_on_axis.z);
|
||||||
line->SetPoint2 (pt2.x, pt2.y, pt2.z);
|
line->SetPoint2 (pt2.x, pt2.y, pt2.z);
|
||||||
@ -247,7 +247,7 @@ temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CylinderWidget temp_viz::Widget::cast<temp_viz::CylinderWidget>()
|
template<> cv::viz::CylinderWidget cv::viz::Widget::cast<cv::viz::CylinderWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CylinderWidget&>(widget);
|
return static_cast<CylinderWidget&>(widget);
|
||||||
@ -256,7 +256,7 @@ template<> temp_viz::CylinderWidget temp_viz::Widget::cast<temp_viz::CylinderWid
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cylinder widget implementation
|
/// cylinder widget implementation
|
||||||
|
|
||||||
temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color)
|
cv::viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New ();
|
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New ();
|
||||||
cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
|
cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
|
||||||
@ -274,7 +274,7 @@ temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, b
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CubeWidget temp_viz::Widget::cast<temp_viz::CubeWidget>()
|
template<> cv::viz::CubeWidget cv::viz::Widget::cast<cv::viz::CubeWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CubeWidget&>(widget);
|
return static_cast<CubeWidget&>(widget);
|
||||||
@ -283,7 +283,7 @@ template<> temp_viz::CubeWidget temp_viz::Widget::cast<temp_viz::CubeWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// coordinate system widget implementation
|
/// coordinate system widget implementation
|
||||||
|
|
||||||
temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale)
|
cv::viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New ();
|
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New ();
|
||||||
axes->SetOrigin (0, 0, 0);
|
axes->SetOrigin (0, 0, 0);
|
||||||
@ -317,7 +317,7 @@ temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale)
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CoordinateSystemWidget temp_viz::Widget::cast<temp_viz::CoordinateSystemWidget>()
|
template<> cv::viz::CoordinateSystemWidget cv::viz::Widget::cast<cv::viz::CoordinateSystemWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CoordinateSystemWidget&>(widget);
|
return static_cast<CoordinateSystemWidget&>(widget);
|
||||||
@ -326,7 +326,7 @@ template<> temp_viz::CoordinateSystemWidget temp_viz::Widget::cast<temp_viz::Coo
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// polyline widget implementation
|
/// polyline widget implementation
|
||||||
|
|
||||||
struct temp_viz::PolyLineWidget::CopyImpl
|
struct cv::viz::PolyLineWidget::CopyImpl
|
||||||
{
|
{
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static void copy(const Mat& source, Vec<_Tp, 3> *output, vtkSmartPointer<vtkPolyLine> polyLine)
|
static void copy(const Mat& source, Vec<_Tp, 3> *output, vtkSmartPointer<vtkPolyLine> polyLine)
|
||||||
@ -346,7 +346,7 @@ struct temp_viz::PolyLineWidget::CopyImpl
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
temp_viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &color)
|
cv::viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &color)
|
||||||
{
|
{
|
||||||
Mat pointData = _pointData.getMat();
|
Mat pointData = _pointData.getMat();
|
||||||
CV_Assert(pointData.type() == CV_32FC3 || pointData.type() == CV_32FC4 || pointData.type() == CV_64FC3 || pointData.type() == CV_64FC4);
|
CV_Assert(pointData.type() == CV_32FC3 || pointData.type() == CV_32FC4 || pointData.type() == CV_64FC3 || pointData.type() == CV_64FC4);
|
||||||
@ -393,7 +393,7 @@ temp_viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &col
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::PolyLineWidget temp_viz::Widget::cast<temp_viz::PolyLineWidget>()
|
template<> cv::viz::PolyLineWidget cv::viz::Widget::cast<cv::viz::PolyLineWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<PolyLineWidget&>(widget);
|
return static_cast<PolyLineWidget&>(widget);
|
||||||
@ -402,7 +402,7 @@ template<> temp_viz::PolyLineWidget temp_viz::Widget::cast<temp_viz::PolyLineWid
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// grid widget implementation
|
/// grid widget implementation
|
||||||
|
|
||||||
temp_viz::GridWidget::GridWidget(Vec2i dimensions, Vec2d spacing, const Color &color)
|
cv::viz::GridWidget::GridWidget(Vec2i dimensions, Vec2d spacing, const Color &color)
|
||||||
{
|
{
|
||||||
// Create the grid using image data
|
// Create the grid using image data
|
||||||
vtkSmartPointer<vtkImageData> grid = vtkSmartPointer<vtkImageData>::New();
|
vtkSmartPointer<vtkImageData> grid = vtkSmartPointer<vtkImageData>::New();
|
||||||
@ -425,7 +425,7 @@ temp_viz::GridWidget::GridWidget(Vec2i dimensions, Vec2d spacing, const Color &c
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::GridWidget temp_viz::Widget::cast<temp_viz::GridWidget>()
|
template<> cv::viz::GridWidget cv::viz::Widget::cast<cv::viz::GridWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<GridWidget&>(widget);
|
return static_cast<GridWidget&>(widget);
|
||||||
@ -434,7 +434,7 @@ template<> temp_viz::GridWidget temp_viz::Widget::cast<temp_viz::GridWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// text3D widget implementation
|
/// text3D widget implementation
|
||||||
|
|
||||||
temp_viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, double text_scale, const Color &color)
|
cv::viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, double text_scale, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkVectorText> textSource = vtkSmartPointer<vtkVectorText>::New ();
|
vtkSmartPointer<vtkVectorText> textSource = vtkSmartPointer<vtkVectorText>::New ();
|
||||||
textSource->SetText (text.c_str());
|
textSource->SetText (text.c_str());
|
||||||
@ -452,7 +452,7 @@ temp_viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Text3DWidget::setText(const String &text)
|
void cv::viz::Text3DWidget::setText(const String &text)
|
||||||
{
|
{
|
||||||
vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -466,7 +466,7 @@ void temp_viz::Text3DWidget::setText(const String &text)
|
|||||||
textSource->Update();
|
textSource->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::String temp_viz::Text3DWidget::getText() const
|
cv::String cv::viz::Text3DWidget::getText() const
|
||||||
{
|
{
|
||||||
vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkFollower *actor = vtkFollower::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -478,7 +478,7 @@ temp_viz::String temp_viz::Text3DWidget::getText() const
|
|||||||
return textSource->GetText();
|
return textSource->GetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::Text3DWidget temp_viz::Widget::cast<temp_viz::Text3DWidget>()
|
template<> cv::viz::Text3DWidget cv::viz::Widget::cast<cv::viz::Text3DWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<Text3DWidget&>(widget);
|
return static_cast<Text3DWidget&>(widget);
|
||||||
@ -487,7 +487,7 @@ template<> temp_viz::Text3DWidget temp_viz::Widget::cast<temp_viz::Text3DWidget>
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// text widget implementation
|
/// text widget implementation
|
||||||
|
|
||||||
temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font_size, const Color &color)
|
cv::viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font_size, const Color &color)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
||||||
actor->SetPosition (pos.x, pos.y);
|
actor->SetPosition (pos.x, pos.y);
|
||||||
@ -505,20 +505,20 @@ temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int fon
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::TextWidget temp_viz::Widget::cast<temp_viz::TextWidget>()
|
template<> cv::viz::TextWidget cv::viz::Widget::cast<cv::viz::TextWidget>()
|
||||||
{
|
{
|
||||||
Widget2D widget = this->cast<Widget2D>();
|
Widget2D widget = this->cast<Widget2D>();
|
||||||
return static_cast<TextWidget&>(widget);
|
return static_cast<TextWidget&>(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::TextWidget::setText(const String &text)
|
void cv::viz::TextWidget::setText(const String &text)
|
||||||
{
|
{
|
||||||
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
actor->SetInput(text.c_str());
|
actor->SetInput(text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::String temp_viz::TextWidget::getText() const
|
cv::String cv::viz::TextWidget::getText() const
|
||||||
{
|
{
|
||||||
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -528,7 +528,7 @@ temp_viz::String temp_viz::TextWidget::getText() const
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// point cloud widget implementation
|
/// point cloud widget implementation
|
||||||
|
|
||||||
struct temp_viz::CloudWidget::CreateCloudWidget
|
struct cv::viz::CloudWidget::CreateCloudWidget
|
||||||
{
|
{
|
||||||
static inline vtkSmartPointer<vtkPolyData> create(const Mat &cloud, vtkIdType &nr_points)
|
static inline vtkSmartPointer<vtkPolyData> create(const Mat &cloud, vtkIdType &nr_points)
|
||||||
{
|
{
|
||||||
@ -615,7 +615,7 @@ struct temp_viz::CloudWidget::CreateCloudWidget
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
temp_viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
||||||
{
|
{
|
||||||
Mat cloud = _cloud.getMat();
|
Mat cloud = _cloud.getMat();
|
||||||
Mat colors = _colors.getMat();
|
Mat colors = _colors.getMat();
|
||||||
@ -646,7 +646,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
|||||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||||
mapper->SetInput (polydata);
|
mapper->SetInput (polydata);
|
||||||
|
|
||||||
cv::Vec3d minmax(scalars->GetRange());
|
Vec3d minmax(scalars->GetRange());
|
||||||
mapper->SetScalarRange(minmax.val);
|
mapper->SetScalarRange(minmax.val);
|
||||||
mapper->SetScalarModeToUsePointData ();
|
mapper->SetScalarModeToUsePointData ();
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
||||||
{
|
{
|
||||||
Mat cloud = _cloud.getMat();
|
Mat cloud = _cloud.getMat();
|
||||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||||
@ -695,7 +695,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CloudWidget temp_viz::Widget::cast<temp_viz::CloudWidget>()
|
template<> cv::viz::CloudWidget cv::viz::Widget::cast<cv::viz::CloudWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CloudWidget&>(widget);
|
return static_cast<CloudWidget&>(widget);
|
||||||
@ -704,17 +704,16 @@ template<> temp_viz::CloudWidget temp_viz::Widget::cast<temp_viz::CloudWidget>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cloud normals widget implementation
|
/// cloud normals widget implementation
|
||||||
|
|
||||||
struct temp_viz::CloudNormalsWidget::ApplyCloudNormals
|
struct cv::viz::CloudNormalsWidget::ApplyCloudNormals
|
||||||
{
|
{
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
struct Impl
|
struct Impl
|
||||||
{
|
{
|
||||||
static vtkSmartPointer<vtkCellArray> applyOrganized(const cv::Mat &cloud, const cv::Mat& normals,
|
static vtkSmartPointer<vtkCellArray> applyOrganized(const Mat &cloud, const Mat& normals, double level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
||||||
int level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
|
||||||
{
|
{
|
||||||
vtkIdType point_step = static_cast<vtkIdType> (sqrt (double (level)));
|
vtkIdType point_step = static_cast<vtkIdType>(std::sqrt(level));
|
||||||
nr_normals = (static_cast<vtkIdType> ((cloud.cols - 1)/ point_step) + 1) *
|
nr_normals = (static_cast<vtkIdType> ((cloud.cols - 1) / point_step) + 1) *
|
||||||
(static_cast<vtkIdType> ((cloud.rows - 1) / point_step) + 1);
|
(static_cast<vtkIdType> ((cloud.rows - 1) / point_step) + 1);
|
||||||
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
|
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
|
||||||
|
|
||||||
pts = new _Tp[2 * nr_normals * 3];
|
pts = new _Tp[2 * nr_normals * 3];
|
||||||
@ -743,8 +742,7 @@ struct temp_viz::CloudNormalsWidget::ApplyCloudNormals
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vtkSmartPointer<vtkCellArray> applyUnorganized(const cv::Mat &cloud, const cv::Mat& normals,
|
static vtkSmartPointer<vtkCellArray> applyUnorganized(const Mat &cloud, const Mat& normals, int level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
||||||
int level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
|
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
|
||||||
nr_normals = (cloud.size().area() - 1) / level + 1 ;
|
nr_normals = (cloud.size().area() - 1) / level + 1 ;
|
||||||
@ -772,8 +770,7 @@ struct temp_viz::CloudNormalsWidget::ApplyCloudNormals
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static inline vtkSmartPointer<vtkCellArray> apply(const cv::Mat &cloud, const cv::Mat& normals,
|
static inline vtkSmartPointer<vtkCellArray> apply(const Mat &cloud, const Mat& normals, int level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
||||||
int level, float scale, _Tp *&pts, vtkIdType &nr_normals)
|
|
||||||
{
|
{
|
||||||
if (cloud.cols > 1 && cloud.rows > 1)
|
if (cloud.cols > 1 && cloud.rows > 1)
|
||||||
return ApplyCloudNormals::Impl<_Tp>::applyOrganized(cloud, normals, level, scale, pts, nr_normals);
|
return ApplyCloudNormals::Impl<_Tp>::applyOrganized(cloud, normals, level, scale, pts, nr_normals);
|
||||||
@ -782,7 +779,7 @@ struct temp_viz::CloudNormalsWidget::ApplyCloudNormals
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _normals, int level, float scale, const Color &color)
|
cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _normals, int level, float scale, const Color &color)
|
||||||
{
|
{
|
||||||
Mat cloud = _cloud.getMat();
|
Mat cloud = _cloud.getMat();
|
||||||
Mat normals = _normals.getMat();
|
Mat normals = _normals.getMat();
|
||||||
@ -833,7 +830,7 @@ temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::CloudNormalsWidget temp_viz::Widget::cast<temp_viz::CloudNormalsWidget>()
|
template<> cv::viz::CloudNormalsWidget cv::viz::Widget::cast<cv::viz::CloudNormalsWidget>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
return static_cast<CloudNormalsWidget&>(widget);
|
return static_cast<CloudNormalsWidget&>(widget);
|
||||||
|
@ -3,20 +3,20 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cv::viz::Color
|
/// cv::viz::Color
|
||||||
|
|
||||||
temp_viz::Color::Color() : Scalar(0, 0, 0) {}
|
cv::viz::Color::Color() : Scalar(0, 0, 0) {}
|
||||||
temp_viz::Color::Color(double gray) : Scalar(gray, gray, gray) {}
|
cv::viz::Color::Color(double gray) : Scalar(gray, gray, gray) {}
|
||||||
temp_viz::Color::Color(double blue, double green, double red) : Scalar(blue, green, red) {}
|
cv::viz::Color::Color(double blue, double green, double red) : Scalar(blue, green, red) {}
|
||||||
temp_viz::Color::Color(const Scalar& color) : Scalar(color) {}
|
cv::viz::Color::Color(const Scalar& color) : Scalar(color) {}
|
||||||
|
|
||||||
temp_viz::Color temp_viz::Color::black() { return Color( 0, 0, 0); }
|
cv::viz::Color cv::viz::Color::black() { return Color( 0, 0, 0); }
|
||||||
temp_viz::Color temp_viz::Color::green() { return Color( 0, 255, 0); }
|
cv::viz::Color cv::viz::Color::green() { return Color( 0, 255, 0); }
|
||||||
temp_viz::Color temp_viz::Color::blue() { return Color(255, 0, 0); }
|
cv::viz::Color cv::viz::Color::blue() { return Color(255, 0, 0); }
|
||||||
temp_viz::Color temp_viz::Color::cyan() { return Color(255, 255, 0); }
|
cv::viz::Color cv::viz::Color::cyan() { return Color(255, 255, 0); }
|
||||||
|
|
||||||
temp_viz::Color temp_viz::Color::red() { return Color( 0, 0, 255); }
|
cv::viz::Color cv::viz::Color::red() { return Color( 0, 0, 255); }
|
||||||
temp_viz::Color temp_viz::Color::magenta() { return Color( 0, 255, 255); }
|
cv::viz::Color cv::viz::Color::magenta() { return Color( 0, 255, 255); }
|
||||||
temp_viz::Color temp_viz::Color::yellow() { return Color(255, 0, 255); }
|
cv::viz::Color cv::viz::Color::yellow() { return Color(255, 0, 255); }
|
||||||
temp_viz::Color temp_viz::Color::white() { return Color(255, 255, 255); }
|
cv::viz::Color cv::viz::Color::white() { return Color(255, 255, 255); }
|
||||||
|
|
||||||
temp_viz::Color temp_viz::Color::gray() { return Color(128, 128, 128); }
|
cv::viz::Color cv::viz::Color::gray() { return Color(128, 128, 128); }
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
|
|
||||||
cv::Affine3f temp_viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin)
|
cv::Affine3f cv::viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin)
|
||||||
{
|
{
|
||||||
Affine3f::Mat3 R;
|
Affine3f::Mat3 R;
|
||||||
R.val[0] = axis_x.val[0];
|
R.val[0] = axis_x.val[0];
|
||||||
|
@ -2,89 +2,89 @@
|
|||||||
#include "viz3d_impl.hpp"
|
#include "viz3d_impl.hpp"
|
||||||
|
|
||||||
|
|
||||||
temp_viz::Viz3d::Viz3d(const String& window_name) : impl_(new VizImpl(window_name))
|
cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(new VizImpl(window_name))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Viz3d::~Viz3d()
|
cv::viz::Viz3d::~Viz3d()
|
||||||
{
|
{
|
||||||
delete impl_;
|
delete impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::setBackgroundColor(const Color& color)
|
void cv::viz::Viz3d::setBackgroundColor(const Color& color)
|
||||||
{
|
{
|
||||||
impl_->setBackgroundColor(color);
|
impl_->setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::addPolygonMesh (const Mesh3d& mesh, const String& id)
|
bool cv::viz::Viz3d::addPolygonMesh (const Mesh3d& mesh, const String& id)
|
||||||
{
|
{
|
||||||
return impl_->addPolygonMesh(mesh, Mat(), id);
|
return impl_->addPolygonMesh(mesh, Mat(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::updatePolygonMesh (const Mesh3d& mesh, const String& id)
|
bool cv::viz::Viz3d::updatePolygonMesh (const Mesh3d& mesh, const String& id)
|
||||||
{
|
{
|
||||||
return impl_->updatePolygonMesh(mesh, Mat(), id);
|
return impl_->updatePolygonMesh(mesh, Mat(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id)
|
bool cv::viz::Viz3d::addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id)
|
||||||
{
|
{
|
||||||
return impl_->addPolylineFromPolygonMesh(mesh, id);
|
return impl_->addPolylineFromPolygonMesh(mesh, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::addPolygon(const Mat& cloud, const Color& color, const String& id)
|
bool cv::viz::Viz3d::addPolygon(const Mat& cloud, const Color& color, const String& id)
|
||||||
{
|
{
|
||||||
return impl_->addPolygon(cloud, color, id);
|
return impl_->addPolygon(cloud, color, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::spin()
|
void cv::viz::Viz3d::spin()
|
||||||
{
|
{
|
||||||
impl_->spin();
|
impl_->spin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::spinOnce (int time, bool force_redraw)
|
void cv::viz::Viz3d::spinOnce (int time, bool force_redraw)
|
||||||
{
|
{
|
||||||
impl_->spinOnce(time, force_redraw);
|
impl_->spinOnce(time, force_redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie)
|
void cv::viz::Viz3d::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie)
|
||||||
{
|
{
|
||||||
impl_->registerKeyboardCallback(callback, cookie);
|
impl_->registerKeyboardCallback(callback, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
void cv::viz::Viz3d::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
||||||
{
|
{
|
||||||
impl_->registerMouseCallback(callback, cookie);
|
impl_->registerMouseCallback(callback, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::wasStopped() const { return impl_->wasStopped(); }
|
bool cv::viz::Viz3d::wasStopped() const { return impl_->wasStopped(); }
|
||||||
|
|
||||||
void temp_viz::Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose)
|
void cv::viz::Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
impl_->showWidget(id, widget, pose);
|
impl_->showWidget(id, widget, pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::removeWidget(const String &id)
|
void cv::viz::Viz3d::removeWidget(const String &id)
|
||||||
{
|
{
|
||||||
impl_->removeWidget(id);
|
impl_->removeWidget(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Widget temp_viz::Viz3d::getWidget(const String &id) const
|
cv::viz::Widget cv::viz::Viz3d::getWidget(const String &id) const
|
||||||
{
|
{
|
||||||
return impl_->getWidget(id);
|
return impl_->getWidget(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose)
|
void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
impl_->setWidgetPose(id, pose);
|
impl_->setWidgetPose(id, pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose)
|
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
impl_->updateWidgetPose(id, pose);
|
impl_->updateWidgetPose(id, pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Affine3f temp_viz::Viz3d::getWidgetPose(const String &id) const
|
cv::Affine3f cv::viz::Viz3d::getWidgetPose(const String &id) const
|
||||||
{
|
{
|
||||||
return impl_->getWidgetPose(id);
|
return impl_->getWidgetPose(id);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <opencv2/viz/viz3d.hpp>
|
#include <opencv2/viz/viz3d.hpp>
|
||||||
|
|
||||||
|
|
||||||
struct temp_viz::Viz3d::VizImpl
|
struct cv::viz::Viz3d::VizImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef cv::Ptr<VizImpl> Ptr;
|
typedef cv::Ptr<VizImpl> Ptr;
|
||||||
@ -280,91 +280,93 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
|
namespace viz
|
||||||
//void getTransformationMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternionf& orientation, Eigen::Matrix4f &transformation);
|
|
||||||
|
|
||||||
//void convertToVtkMatrix (const Eigen::Matrix4f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
|
||||||
|
|
||||||
void convertToVtkMatrix (const cv::Matx44f& m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
|
||||||
void convertToCvMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, cv::Matx44f &m);
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f &m);
|
|
||||||
cv::Matx44f convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix);
|
|
||||||
|
|
||||||
/** \brief Convert origin and orientation to vtkMatrix4x4
|
|
||||||
* \param[in] origin the point cloud origin
|
|
||||||
* \param[in] orientation the point cloud orientation
|
|
||||||
* \param[out] vtk_matrix the resultant VTK 4x4 matrix
|
|
||||||
*/
|
|
||||||
void convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
|
||||||
void convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, Eigen::Matrix4f &m);
|
|
||||||
|
|
||||||
|
|
||||||
struct NanFilter
|
|
||||||
{
|
|
||||||
template<typename _Tp, typename _Msk>
|
|
||||||
struct Impl
|
|
||||||
{
|
{
|
||||||
typedef Vec<_Tp, 3> _Out;
|
//void getTransformationMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternionf& orientation, Eigen::Matrix4f &transformation);
|
||||||
|
|
||||||
static _Out* copy(const Mat& source, _Out* output, const Mat& nan_mask)
|
//void convertToVtkMatrix (const Eigen::Matrix4f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
||||||
|
|
||||||
|
void convertToVtkMatrix (const cv::Matx44f& m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
||||||
|
void convertToCvMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, cv::Matx44f &m);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f &m);
|
||||||
|
cv::Matx44f convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix);
|
||||||
|
|
||||||
|
/** \brief Convert origin and orientation to vtkMatrix4x4
|
||||||
|
* \param[in] origin the point cloud origin
|
||||||
|
* \param[in] orientation the point cloud orientation
|
||||||
|
* \param[out] vtk_matrix the resultant VTK 4x4 matrix
|
||||||
|
*/
|
||||||
|
void convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
|
||||||
|
void convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, Eigen::Matrix4f &m);
|
||||||
|
|
||||||
|
|
||||||
|
struct NanFilter
|
||||||
{
|
{
|
||||||
CV_Assert(DataDepth<_Tp>::value == source.depth() && source.size() == nan_mask.size());
|
template<typename _Tp, typename _Msk>
|
||||||
CV_Assert(nan_mask.channels() == 3 || nan_mask.channels() == 4);
|
struct Impl
|
||||||
CV_DbgAssert(DataDepth<_Msk>::value == nan_mask.depth());
|
|
||||||
|
|
||||||
int s_chs = source.channels();
|
|
||||||
int m_chs = nan_mask.channels();
|
|
||||||
|
|
||||||
for(int y = 0; y < source.rows; ++y)
|
|
||||||
{
|
{
|
||||||
const _Tp* srow = source.ptr<_Tp>(y);
|
typedef Vec<_Tp, 3> _Out;
|
||||||
const _Msk* mrow = nan_mask.ptr<_Msk>(y);
|
|
||||||
|
|
||||||
for(int x = 0; x < source.cols; ++x, srow += s_chs, mrow += m_chs)
|
static _Out* copy(const Mat& source, _Out* output, const Mat& nan_mask)
|
||||||
if (!isNan(mrow[0]) && !isNan(mrow[1]) && !isNan(mrow[2]))
|
{
|
||||||
*output++ = _Out(srow);
|
CV_Assert(DataDepth<_Tp>::value == source.depth() && source.size() == nan_mask.size());
|
||||||
|
CV_Assert(nan_mask.channels() == 3 || nan_mask.channels() == 4);
|
||||||
|
CV_DbgAssert(DataDepth<_Msk>::value == nan_mask.depth());
|
||||||
|
|
||||||
|
int s_chs = source.channels();
|
||||||
|
int m_chs = nan_mask.channels();
|
||||||
|
|
||||||
|
for(int y = 0; y < source.rows; ++y)
|
||||||
|
{
|
||||||
|
const _Tp* srow = source.ptr<_Tp>(y);
|
||||||
|
const _Msk* mrow = nan_mask.ptr<_Msk>(y);
|
||||||
|
|
||||||
|
for(int x = 0; x < source.cols; ++x, srow += s_chs, mrow += m_chs)
|
||||||
|
if (!isNan(mrow[0]) && !isNan(mrow[1]) && !isNan(mrow[2]))
|
||||||
|
*output++ = _Out(srow);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
static inline Vec<_Tp, 3>* copy(const Mat& source, Vec<_Tp, 3>* output, const Mat& nan_mask)
|
||||||
|
{
|
||||||
|
CV_Assert(nan_mask.depth() == CV_32F || nan_mask.depth() == CV_64F);
|
||||||
|
|
||||||
|
typedef Vec<_Tp, 3>* (*copy_func)(const Mat&, Vec<_Tp, 3>*, const Mat&);
|
||||||
|
const static copy_func table[2] = { &NanFilter::Impl<_Tp, float>::copy, &NanFilter::Impl<_Tp, double>::copy };
|
||||||
|
|
||||||
|
return table[nan_mask.depth() - 5](source, output, nan_mask);
|
||||||
}
|
}
|
||||||
return output;
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
struct ApplyAffine
|
||||||
static inline Vec<_Tp, 3>* copy(const Mat& source, Vec<_Tp, 3>* output, const Mat& nan_mask)
|
{
|
||||||
{
|
const Affine3f& affine_;
|
||||||
CV_Assert(nan_mask.depth() == CV_32F || nan_mask.depth() == CV_64F);
|
ApplyAffine(const Affine3f& affine) : affine_(affine) {}
|
||||||
|
|
||||||
typedef Vec<_Tp, 3>* (*copy_func)(const Mat&, Vec<_Tp, 3>*, const Mat&);
|
template<typename _Tp> Point3_<_Tp> operator()(const Point3_<_Tp>& p) const { return affine_ * p; }
|
||||||
const static copy_func table[2] = { &NanFilter::Impl<_Tp, float>::copy, &NanFilter::Impl<_Tp, double>::copy };
|
|
||||||
|
|
||||||
return table[nan_mask.depth() - 5](source, output, nan_mask);
|
template<typename _Tp> Vec<_Tp, 3> operator()(const Vec<_Tp, 3>& v) const
|
||||||
|
{
|
||||||
|
const float* m = affine_.matrix.val;
|
||||||
|
|
||||||
|
Vec<_Tp, 3> result;
|
||||||
|
result[0] = (_Tp)(m[0] * v[0] + m[1] * v[1] + m[ 2] * v[2] + m[ 3]);
|
||||||
|
result[1] = (_Tp)(m[4] * v[0] + m[5] * v[1] + m[ 6] * v[2] + m[ 7]);
|
||||||
|
result[2] = (_Tp)(m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ApplyAffine(const ApplyAffine&);
|
||||||
|
ApplyAffine& operator=(const ApplyAffine&);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct ApplyAffine
|
|
||||||
{
|
|
||||||
const Affine3f& affine_;
|
|
||||||
ApplyAffine(const Affine3f& affine) : affine_(affine) {}
|
|
||||||
|
|
||||||
template<typename _Tp> Point3_<_Tp> operator()(const Point3_<_Tp>& p) const { return affine_ * p; }
|
|
||||||
|
|
||||||
template<typename _Tp> Vec<_Tp, 3> operator()(const Vec<_Tp, 3>& v) const
|
|
||||||
{
|
|
||||||
const float* m = affine_.matrix.val;
|
|
||||||
|
|
||||||
Vec<_Tp, 3> result;
|
|
||||||
result[0] = (_Tp)(m[0] * v[0] + m[1] * v[1] + m[ 2] * v[2] + m[ 3]);
|
|
||||||
result[1] = (_Tp)(m[4] * v[0] + m[5] * v[1] + m[ 6] * v[2] + m[ 7]);
|
|
||||||
result[2] = (_Tp)(m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11]);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ApplyAffine(const ApplyAffine&);
|
|
||||||
ApplyAffine& operator=(const ApplyAffine&);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ vtkRenderWindowInteractor* vtkRenderWindowInteractorFixNew ()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
temp_viz::Viz3d::VizImpl::VizImpl (const std::string &name)
|
cv::viz::Viz3d::VizImpl::VizImpl (const std::string &name)
|
||||||
: style_ (vtkSmartPointer<temp_viz::InteractorStyle>::New ())
|
: style_ (vtkSmartPointer<cv::viz::InteractorStyle>::New ())
|
||||||
, cloud_actor_map_ (new CloudActorMap)
|
, cloud_actor_map_ (new CloudActorMap)
|
||||||
, shape_actor_map_ (new ShapeActorMap)
|
, shape_actor_map_ (new ShapeActorMap)
|
||||||
, widget_actor_map_ (new WidgetActorMap)
|
, widget_actor_map_ (new WidgetActorMap)
|
||||||
@ -83,7 +83,7 @@ temp_viz::Viz3d::VizImpl::VizImpl (const std::string &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
temp_viz::Viz3d::VizImpl::~VizImpl ()
|
cv::viz::Viz3d::VizImpl::~VizImpl ()
|
||||||
{
|
{
|
||||||
if (interactor_ != NULL)
|
if (interactor_ != NULL)
|
||||||
interactor_->DestroyTimer (timer_id_);
|
interactor_->DestroyTimer (timer_id_);
|
||||||
@ -92,22 +92,22 @@ temp_viz::Viz3d::VizImpl::~VizImpl ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::saveScreenshot (const std::string &file) { style_->saveScreenshot (file); }
|
void cv::viz::Viz3d::VizImpl::saveScreenshot (const std::string &file) { style_->saveScreenshot (file); }
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
void cv::viz::Viz3d::VizImpl::registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie)
|
||||||
{
|
{
|
||||||
style_->registerMouseCallback(callback, cookie);
|
style_->registerMouseCallback(callback, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie)
|
void cv::viz::Viz3d::VizImpl::registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie)
|
||||||
{
|
{
|
||||||
style_->registerKeyboardCallback(callback, cookie);
|
style_->registerKeyboardCallback(callback, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::spin ()
|
void cv::viz::Viz3d::VizImpl::spin ()
|
||||||
{
|
{
|
||||||
resetStoppedFlag ();
|
resetStoppedFlag ();
|
||||||
window_->Render ();
|
window_->Render ();
|
||||||
@ -115,7 +115,7 @@ void temp_viz::Viz3d::VizImpl::spin ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::spinOnce (int time, bool force_redraw)
|
void cv::viz::Viz3d::VizImpl::spinOnce (int time, bool force_redraw)
|
||||||
{
|
{
|
||||||
resetStoppedFlag ();
|
resetStoppedFlag ();
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ void temp_viz::Viz3d::VizImpl::spinOnce (int time, bool force_redraw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removePointCloud (const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::removePointCloud (const std::string &id)
|
||||||
{
|
{
|
||||||
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
||||||
if (am_it == cloud_actor_map_->end ())
|
if (am_it == cloud_actor_map_->end ())
|
||||||
@ -152,7 +152,7 @@ bool temp_viz::Viz3d::VizImpl::removePointCloud (const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeShape (const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::removeShape (const std::string &id)
|
||||||
{
|
{
|
||||||
// Check to see if the given ID entry exists
|
// Check to see if the given ID entry exists
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
@ -191,7 +191,7 @@ bool temp_viz::Viz3d::VizImpl::removeShape (const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeText3D (const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::removeText3D (const std::string &id)
|
||||||
{
|
{
|
||||||
// Check to see if the given ID entry exists
|
// Check to see if the given ID entry exists
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
@ -206,7 +206,7 @@ bool temp_viz::Viz3d::VizImpl::removeText3D (const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeAllPointClouds ()
|
bool cv::viz::Viz3d::VizImpl::removeAllPointClouds ()
|
||||||
{
|
{
|
||||||
// Check to see if the given ID entry exists
|
// Check to see if the given ID entry exists
|
||||||
CloudActorMap::iterator am_it = cloud_actor_map_->begin ();
|
CloudActorMap::iterator am_it = cloud_actor_map_->begin ();
|
||||||
@ -221,7 +221,7 @@ bool temp_viz::Viz3d::VizImpl::removeAllPointClouds ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeAllShapes ()
|
bool cv::viz::Viz3d::VizImpl::removeAllShapes ()
|
||||||
{
|
{
|
||||||
// Check to see if the given ID entry exists
|
// Check to see if the given ID entry exists
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->begin ();
|
ShapeActorMap::iterator am_it = shape_actor_map_->begin ();
|
||||||
@ -237,7 +237,7 @@ bool temp_viz::Viz3d::VizImpl::removeAllShapes ()
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkLODActor> &actor)
|
bool cv::viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkLODActor> &actor)
|
||||||
{
|
{
|
||||||
vtkLODActor* actor_to_remove = vtkLODActor::SafeDownCast (actor);
|
vtkLODActor* actor_to_remove = vtkLODActor::SafeDownCast (actor);
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vt
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkActor> &actor)
|
bool cv::viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkActor> &actor)
|
||||||
{
|
{
|
||||||
vtkActor* actor_to_remove = vtkActor::SafeDownCast (actor);
|
vtkActor* actor_to_remove = vtkActor::SafeDownCast (actor);
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkProp> &actor)
|
bool cv::viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkProp> &actor)
|
||||||
{
|
{
|
||||||
vtkProp* actor_to_remove = vtkProp::SafeDownCast(actor);
|
vtkProp* actor_to_remove = vtkProp::SafeDownCast(actor);
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ bool temp_viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data, vtkSmartPointer<vtkLODActor> &actor, bool use_scalars)
|
void cv::viz::Viz3d::VizImpl::createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data, vtkSmartPointer<vtkLODActor> &actor, bool use_scalars)
|
||||||
{
|
{
|
||||||
if (!actor)
|
if (!actor)
|
||||||
actor = vtkSmartPointer<vtkLODActor>::New ();
|
actor = vtkSmartPointer<vtkLODActor>::New ();
|
||||||
@ -344,14 +344,14 @@ void temp_viz::Viz3d::VizImpl::createActorFromVTKDataSet (const vtkSmartPointer<
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setBackgroundColor (const Color& color)
|
void cv::viz::Viz3d::VizImpl::setBackgroundColor (const Color& color)
|
||||||
{
|
{
|
||||||
Color c = vtkcolor(color);
|
Color c = vtkcolor(color);
|
||||||
renderer_->SetBackground (c.val);
|
renderer_->SetBackground (c.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::getPointCloudRenderingProperties (int property, double &value, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::getPointCloudRenderingProperties (int property, double &value, const std::string &id)
|
||||||
{
|
{
|
||||||
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
||||||
if (am_it == cloud_actor_map_->end ())
|
if (am_it == cloud_actor_map_->end ())
|
||||||
@ -387,7 +387,7 @@ bool temp_viz::Viz3d::VizImpl::getPointCloudRenderingProperties (int property, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::setPointCloudRenderingProperties (int property, double value, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::setPointCloudRenderingProperties (int property, double value, const std::string &id)
|
||||||
{
|
{
|
||||||
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
||||||
if (am_it == cloud_actor_map_->end ())
|
if (am_it == cloud_actor_map_->end ())
|
||||||
@ -433,7 +433,7 @@ bool temp_viz::Viz3d::VizImpl::setPointCloudRenderingProperties (int property, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::setPointCloudSelected (const bool selected, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::setPointCloudSelected (const bool selected, const std::string &id)
|
||||||
{
|
{
|
||||||
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
||||||
if (am_it == cloud_actor_map_->end ())
|
if (am_it == cloud_actor_map_->end ())
|
||||||
@ -456,7 +456,7 @@ bool temp_viz::Viz3d::VizImpl::setPointCloudSelected (const bool selected, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double value, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double value, const std::string &id)
|
||||||
{
|
{
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
if (am_it == shape_actor_map_->end ())
|
if (am_it == shape_actor_map_->end ())
|
||||||
@ -512,7 +512,7 @@ bool temp_viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double
|
|||||||
{
|
{
|
||||||
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetNormals ())
|
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetNormals ())
|
||||||
{
|
{
|
||||||
std::cout << "[temp_viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Gouraud shading was requested. Estimating normals...\n" << std::endl;
|
std::cout << "[cv::viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Gouraud shading was requested. Estimating normals...\n" << std::endl;
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New ();
|
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New ();
|
||||||
normals->SetInput (actor->GetMapper ()->GetInput ());
|
normals->SetInput (actor->GetMapper ()->GetInput ());
|
||||||
@ -526,7 +526,7 @@ bool temp_viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double
|
|||||||
{
|
{
|
||||||
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetNormals ())
|
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetNormals ())
|
||||||
{
|
{
|
||||||
std::cout << "[temp_viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Phong shading was requested. Estimating normals...\n" << std::endl;
|
std::cout << "[cv::viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Phong shading was requested. Estimating normals...\n" << std::endl;
|
||||||
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New ();
|
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New ();
|
||||||
normals->SetInput (actor->GetMapper ()->GetInput ());
|
normals->SetInput (actor->GetMapper ()->GetInput ());
|
||||||
normals->Update ();
|
normals->Update ();
|
||||||
@ -547,7 +547,7 @@ bool temp_viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::initCameraParameters ()
|
void cv::viz::Viz3d::VizImpl::initCameraParameters ()
|
||||||
{
|
{
|
||||||
Camera camera_temp;
|
Camera camera_temp;
|
||||||
// Set default camera parameters to something meaningful
|
// Set default camera parameters to something meaningful
|
||||||
@ -571,12 +571,12 @@ void temp_viz::Viz3d::VizImpl::initCameraParameters ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::cameraParamsSet () const { return (camera_set_); }
|
bool cv::viz::Viz3d::VizImpl::cameraParamsSet () const { return (camera_set_); }
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::updateCamera ()
|
void cv::viz::Viz3d::VizImpl::updateCamera ()
|
||||||
{
|
{
|
||||||
std::cout << "[temp_viz::PCLVisualizer::updateCamera()] This method was deprecated, just re-rendering all scenes now." << std::endl;
|
std::cout << "[cv::viz::PCLVisualizer::updateCamera()] This method was deprecated, just re-rendering all scenes now." << std::endl;
|
||||||
//rens_->InitTraversal ();
|
//rens_->InitTraversal ();
|
||||||
// Update the camera parameters
|
// Update the camera parameters
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ void temp_viz::Viz3d::VizImpl::updateCamera ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::getCameras (temp_viz::Camera& camera)
|
void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
|
||||||
{
|
{
|
||||||
vtkCamera* active_camera = renderer_->GetActiveCamera ();
|
vtkCamera* active_camera = renderer_->GetActiveCamera ();
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ void temp_viz::Viz3d::VizImpl::getCameras (temp_viz::Camera& camera)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
cv::Affine3f temp_viz::Viz3d::VizImpl::getViewerPose ()
|
cv::Affine3f cv::viz::Viz3d::VizImpl::getViewerPose ()
|
||||||
{
|
{
|
||||||
vtkCamera& camera = *renderer_->GetActiveCamera ();
|
vtkCamera& camera = *renderer_->GetActiveCamera ();
|
||||||
|
|
||||||
@ -628,14 +628,14 @@ cv::Affine3f temp_viz::Viz3d::VizImpl::getViewerPose ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::resetCamera ()
|
void cv::viz::Viz3d::VizImpl::resetCamera ()
|
||||||
{
|
{
|
||||||
renderer_->ResetCamera ();
|
renderer_->ResetCamera ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up)
|
void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up)
|
||||||
{
|
{
|
||||||
|
|
||||||
vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
|
vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
|
||||||
@ -646,7 +646,7 @@ void temp_viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z)
|
void cv::viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z)
|
||||||
{
|
{
|
||||||
//rens_->InitTraversal ();
|
//rens_->InitTraversal ();
|
||||||
|
|
||||||
@ -659,7 +659,7 @@ void temp_viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, do
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraParameters (const cv::Matx33f& intrinsics, const cv::Affine3f& extrinsics)
|
void cv::viz::Viz3d::VizImpl::setCameraParameters (const cv::Matx33f& intrinsics, const cv::Affine3f& extrinsics)
|
||||||
{
|
{
|
||||||
// Position = extrinsic translation
|
// Position = extrinsic translation
|
||||||
cv::Vec3f pos_vec = extrinsics.translation();
|
cv::Vec3f pos_vec = extrinsics.translation();
|
||||||
@ -698,7 +698,7 @@ void temp_viz::Viz3d::VizImpl::setCameraParameters (const cv::Matx33f& intrinsic
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraParameters (const temp_viz::Camera &camera)
|
void cv::viz::Viz3d::VizImpl::setCameraParameters (const cv::viz::Camera &camera)
|
||||||
{
|
{
|
||||||
//rens_->InitTraversal ();
|
//rens_->InitTraversal ();
|
||||||
|
|
||||||
@ -715,7 +715,7 @@ void temp_viz::Viz3d::VizImpl::setCameraParameters (const temp_viz::Camera &came
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraClipDistances (double near, double far)
|
void cv::viz::Viz3d::VizImpl::setCameraClipDistances (double near, double far)
|
||||||
{
|
{
|
||||||
//rens_->InitTraversal ();
|
//rens_->InitTraversal ();
|
||||||
|
|
||||||
@ -724,7 +724,7 @@ void temp_viz::Viz3d::VizImpl::setCameraClipDistances (double near, double far)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setCameraFieldOfView (double fovy)
|
void cv::viz::Viz3d::VizImpl::setCameraFieldOfView (double fovy)
|
||||||
{
|
{
|
||||||
//rens_->InitTraversal ();
|
//rens_->InitTraversal ();
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ void temp_viz::Viz3d::VizImpl::setCameraFieldOfView (double fovy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
|
void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkMatrix4x4> camera_pose;
|
vtkSmartPointer<vtkMatrix4x4> camera_pose;
|
||||||
static CloudActorMap::iterator it = cloud_actor_map_->find (id);
|
static CloudActorMap::iterator it = cloud_actor_map_->find (id);
|
||||||
@ -771,7 +771,7 @@ void temp_viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata, const std::string & id)
|
bool cv::viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata, const std::string & id)
|
||||||
{
|
{
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
if (am_it != shape_actor_map_->end ())
|
if (am_it != shape_actor_map_->end ())
|
||||||
@ -791,7 +791,7 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata, vtkSmartPointer<vtkTransform> transform, const std::string & id)
|
bool cv::viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata, vtkSmartPointer<vtkTransform> transform, const std::string & id)
|
||||||
{
|
{
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
if (am_it != shape_actor_map_->end ())
|
if (am_it != shape_actor_map_->end ())
|
||||||
@ -818,7 +818,7 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer<vtkPolyData
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename, const std::string &id)
|
||||||
{
|
{
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
if (am_it != shape_actor_map_->end ())
|
if (am_it != shape_actor_map_->end ())
|
||||||
@ -837,7 +837,7 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename, vtkSmartPointer<vtkTransform> transform, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename, vtkSmartPointer<vtkTransform> transform, const std::string &id)
|
||||||
{
|
{
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
if (am_it != shape_actor_map_->end ())
|
if (am_it != shape_actor_map_->end ())
|
||||||
@ -859,7 +859,7 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename,
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& mesh, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& mesh, const std::string &id)
|
||||||
{
|
{
|
||||||
CV_Assert(mesh.cloud.rows == 1 && mesh.cloud.type() == CV_32FC3);
|
CV_Assert(mesh.cloud.rows == 1 && mesh.cloud.type() == CV_32FC3);
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ bool temp_viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& mesh, c
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setRepresentationToSurfaceForAllActors ()
|
void cv::viz::Viz3d::VizImpl::setRepresentationToSurfaceForAllActors ()
|
||||||
{
|
{
|
||||||
vtkActorCollection * actors = renderer_->GetActors ();
|
vtkActorCollection * actors = renderer_->GetActors ();
|
||||||
actors->InitTraversal ();
|
actors->InitTraversal ();
|
||||||
@ -923,7 +923,7 @@ void temp_viz::Viz3d::VizImpl::setRepresentationToSurfaceForAllActors ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setRepresentationToPointsForAllActors ()
|
void cv::viz::Viz3d::VizImpl::setRepresentationToPointsForAllActors ()
|
||||||
{
|
{
|
||||||
vtkActorCollection * actors = renderer_->GetActors ();
|
vtkActorCollection * actors = renderer_->GetActors ();
|
||||||
actors->InitTraversal ();
|
actors->InitTraversal ();
|
||||||
@ -933,7 +933,7 @@ void temp_viz::Viz3d::VizImpl::setRepresentationToPointsForAllActors ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::setRepresentationToWireframeForAllActors ()
|
void cv::viz::Viz3d::VizImpl::setRepresentationToWireframeForAllActors ()
|
||||||
{
|
{
|
||||||
vtkActorCollection * actors = renderer_->GetActors ();
|
vtkActorCollection * actors = renderer_->GetActors ();
|
||||||
actors->InitTraversal ();
|
actors->InitTraversal ();
|
||||||
@ -943,7 +943,7 @@ void temp_viz::Viz3d::VizImpl::setRepresentationToWireframeForAllActors ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::updateCells (vtkSmartPointer<vtkIdTypeArray> &cells, vtkSmartPointer<vtkIdTypeArray> &initcells, vtkIdType nr_points)
|
void cv::viz::Viz3d::VizImpl::updateCells (vtkSmartPointer<vtkIdTypeArray> &cells, vtkSmartPointer<vtkIdTypeArray> &initcells, vtkIdType nr_points)
|
||||||
{
|
{
|
||||||
// If no init cells and cells has not been initialized...
|
// If no init cells and cells has not been initialized...
|
||||||
if (!cells)
|
if (!cells)
|
||||||
@ -986,24 +986,24 @@ void temp_viz::Viz3d::VizImpl::updateCells (vtkSmartPointer<vtkIdTypeArray> &cel
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata)
|
void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata)
|
||||||
{
|
{
|
||||||
polydata = vtkSmartPointer<vtkAppendPolyData>::New ();
|
polydata = vtkSmartPointer<vtkAppendPolyData>::New ();
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata)
|
void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata)
|
||||||
{
|
{
|
||||||
polydata = vtkSmartPointer<vtkPolyData>::New ();
|
polydata = vtkSmartPointer<vtkPolyData>::New ();
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::Viz3d::VizImpl::allocVtkUnstructuredGrid (vtkSmartPointer<vtkUnstructuredGrid> &polydata)
|
void cv::viz::Viz3d::VizImpl::allocVtkUnstructuredGrid (vtkSmartPointer<vtkUnstructuredGrid> &polydata)
|
||||||
{
|
{
|
||||||
polydata = vtkSmartPointer<vtkUnstructuredGrid>::New ();
|
polydata = vtkSmartPointer<vtkUnstructuredGrid>::New ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix)
|
void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix)
|
||||||
{
|
{
|
||||||
// set rotation
|
// set rotation
|
||||||
Eigen::Matrix3f rot = orientation.toRotationMatrix ();
|
Eigen::Matrix3f rot = orientation.toRotationMatrix ();
|
||||||
@ -1018,14 +1018,14 @@ void temp_viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Q
|
|||||||
vtk_matrix->SetElement (3, 3, 1.0f);
|
vtk_matrix->SetElement (3, 3, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::convertToVtkMatrix (const cv::Matx44f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix)
|
void cv::viz::convertToVtkMatrix (const Matx44f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
for (int k = 0; k < 4; k++)
|
for (int k = 0; k < 4; k++)
|
||||||
vtk_matrix->SetElement (i, k, m (i, k));
|
vtk_matrix->SetElement (i, k, m (i, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> temp_viz::convertToVtkMatrix (const cv::Matx44f &m)
|
vtkSmartPointer<vtkMatrix4x4> cv::viz::convertToVtkMatrix (const cv::Matx44f &m)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
@ -1034,7 +1034,7 @@ vtkSmartPointer<vtkMatrix4x4> temp_viz::convertToVtkMatrix (const cv::Matx44f &m
|
|||||||
return vtk_matrix;
|
return vtk_matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::convertToCvMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, cv::Matx44f &m)
|
void cv::viz::convertToCvMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, cv::Matx44f &m)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
for (int k = 0; k < 4; k++)
|
for (int k = 0; k < 4; k++)
|
||||||
@ -1042,7 +1042,7 @@ void temp_viz::convertToCvMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cv::Matx44f temp_viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
|
cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
|
||||||
{
|
{
|
||||||
cv::Matx44f m;
|
cv::Matx44f m;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
@ -1052,7 +1052,7 @@ cv::Matx44f temp_viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void temp_viz::convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, Eigen::Matrix4f &m)
|
void cv::viz::convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix, Eigen::Matrix4f &m)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
for (int k = 0; k < 4; k++)
|
for (int k = 0; k < 4; k++)
|
||||||
@ -1060,22 +1060,22 @@ void temp_viz::convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::setFullScreen (bool mode)
|
void cv::viz::Viz3d::VizImpl::setFullScreen (bool mode)
|
||||||
{
|
{
|
||||||
if (window_)
|
if (window_)
|
||||||
window_->SetFullScreen (mode);
|
window_->SetFullScreen (mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::setWindowName (const std::string &name)
|
void cv::viz::Viz3d::VizImpl::setWindowName (const std::string &name)
|
||||||
{
|
{
|
||||||
if (window_)
|
if (window_)
|
||||||
window_->SetWindowName (name.c_str ());
|
window_->SetWindowName (name.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::setPosition (int x, int y) { window_->SetPosition (x, y); }
|
void cv::viz::Viz3d::VizImpl::setPosition (int x, int y) { window_->SetPosition (x, y); }
|
||||||
void temp_viz::Viz3d::VizImpl::setSize (int xw, int yw) { window_->SetSize (xw, yw); }
|
void cv::viz::Viz3d::VizImpl::setSize (int xw, int yw) { window_->SetSize (xw, yw); }
|
||||||
|
|
||||||
bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id)
|
||||||
{
|
{
|
||||||
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
|
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
|
||||||
CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
|
CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
|
||||||
@ -1088,9 +1088,9 @@ bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& ma
|
|||||||
// std::vector<sensor_msgs::PointField> fields;
|
// std::vector<sensor_msgs::PointField> fields;
|
||||||
|
|
||||||
|
|
||||||
// rgb_idx = temp_viz::getFieldIndex (*cloud, "rgb", fields);
|
// rgb_idx = cv::viz::getFieldIndex (*cloud, "rgb", fields);
|
||||||
// if (rgb_idx == -1)
|
// if (rgb_idx == -1)
|
||||||
// rgb_idx = temp_viz::getFieldIndex (*cloud, "rgba", fields);
|
// rgb_idx = cv::viz::getFieldIndex (*cloud, "rgba", fields);
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnsignedCharArray> colors_array;
|
vtkSmartPointer<vtkUnsignedCharArray> colors_array;
|
||||||
#if 1
|
#if 1
|
||||||
@ -1108,12 +1108,12 @@ bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& ma
|
|||||||
for(int i = 0; i < mesh.colors.cols; ++i)
|
for(int i = 0; i < mesh.colors.cols; ++i)
|
||||||
colors_array->InsertNextTupleValue(&data[i*3]);
|
colors_array->InsertNextTupleValue(&data[i*3]);
|
||||||
|
|
||||||
// temp_viz::RGB rgb_data;
|
// cv::viz::RGB rgb_data;
|
||||||
// for (size_t i = 0; i < cloud->size (); ++i)
|
// for (size_t i = 0; i < cloud->size (); ++i)
|
||||||
// {
|
// {
|
||||||
// if (!isFinite (cloud->points[i]))
|
// if (!isFinite (cloud->points[i]))
|
||||||
// continue;
|
// continue;
|
||||||
// memcpy (&rgb_data, reinterpret_cast<const char*> (&cloud->points[i]) + fields[rgb_idx].offset, sizeof (temp_viz::RGB));
|
// memcpy (&rgb_data, reinterpret_cast<const char*> (&cloud->points[i]) + fields[rgb_idx].offset, sizeof (cv::viz::RGB));
|
||||||
// unsigned char color[3];
|
// unsigned char color[3];
|
||||||
// color[0] = rgb_data.r;
|
// color[0] = rgb_data.r;
|
||||||
// color[1] = rgb_data.g;
|
// color[1] = rgb_data.g;
|
||||||
@ -1262,7 +1262,7 @@ bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool temp_viz::Viz3d::VizImpl::updatePolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::updatePolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const std::string &id)
|
||||||
{
|
{
|
||||||
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
|
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
|
||||||
CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
|
CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
|
||||||
@ -1379,7 +1379,7 @@ bool temp_viz::Viz3d::VizImpl::updatePolygonMesh (const Mesh3d& mesh, const cv::
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3f &p2, const Color& color, bool display_length, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3f &p2, const Color& color, bool display_length, const std::string &id)
|
||||||
{
|
{
|
||||||
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
|
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
@ -1409,7 +1409,7 @@ bool temp_viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool temp_viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3f &p2, const Color& color_line, const Color& color_text, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3f &p2, const Color& color_line, const Color& color_text, const std::string &id)
|
||||||
{
|
{
|
||||||
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
|
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
@ -1440,7 +1440,7 @@ bool temp_viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::VizImpl::addPolygon (const cv::Mat& cloud, const Color& color, const std::string &id)
|
bool cv::viz::Viz3d::VizImpl::addPolygon (const cv::Mat& cloud, const Color& color, const std::string &id)
|
||||||
{
|
{
|
||||||
CV_Assert(cloud.type() == CV_32FC3 && cloud.rows == 1);
|
CV_Assert(cloud.type() == CV_32FC3 && cloud.rows == 1);
|
||||||
|
|
||||||
@ -1518,7 +1518,7 @@ bool temp_viz::Viz3d::VizImpl::addPolygon (const cv::Mat& cloud, const Color& co
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget, const Affine3f &pose)
|
void cv::viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
@ -1547,7 +1547,7 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
|
|||||||
(*widget_actor_map_)[id].actor = WidgetAccessor::getProp(widget);
|
(*widget_actor_map_)[id].actor = WidgetAccessor::getProp(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
|
void cv::viz::Viz3d::VizImpl::removeWidget(const String &id)
|
||||||
{
|
{
|
||||||
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
@ -1556,7 +1556,7 @@ void temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
|
|||||||
widget_actor_map_->erase(wam_itr);
|
widget_actor_map_->erase(wam_itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Widget temp_viz::Viz3d::VizImpl::getWidget(const String &id) const
|
cv::viz::Widget cv::viz::Viz3d::VizImpl::getWidget(const String &id) const
|
||||||
{
|
{
|
||||||
WidgetActorMap::const_iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::const_iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
@ -1567,7 +1567,7 @@ temp_viz::Widget temp_viz::Viz3d::VizImpl::getWidget(const String &id) const
|
|||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
|
void cv::viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
@ -1581,7 +1581,7 @@ void temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &p
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::updateWidgetPose(const String &id, const Affine3f &pose)
|
void cv::viz::Viz3d::VizImpl::updateWidgetPose(const String &id, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
@ -1604,7 +1604,7 @@ void temp_viz::Viz3d::VizImpl::updateWidgetPose(const String &id, const Affine3f
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Affine3f temp_viz::Viz3d::VizImpl::getWidgetPose(const String &id) const
|
cv::Affine3f cv::viz::Viz3d::VizImpl::getWidgetPose(const String &id) const
|
||||||
{
|
{
|
||||||
WidgetActorMap::const_iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::const_iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
|
@ -2,30 +2,33 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
namespace temp_viz
|
namespace cv
|
||||||
{
|
{
|
||||||
struct CV_EXPORTS CloudActor
|
namespace viz
|
||||||
{
|
{
|
||||||
/** \brief The actor holding the data to render. */
|
struct CV_EXPORTS CloudActor
|
||||||
vtkSmartPointer<vtkLODActor> actor;
|
{
|
||||||
|
/** \brief The actor holding the data to render. */
|
||||||
|
vtkSmartPointer<vtkLODActor> actor;
|
||||||
|
|
||||||
/** \brief The viewpoint transformation matrix. */
|
/** \brief The viewpoint transformation matrix. */
|
||||||
vtkSmartPointer<vtkMatrix4x4> viewpoint_transformation_;
|
vtkSmartPointer<vtkMatrix4x4> viewpoint_transformation_;
|
||||||
|
|
||||||
/** \brief Internal cell array. Used for optimizing updatePointCloud. */
|
/** \brief Internal cell array. Used for optimizing updatePointCloud. */
|
||||||
vtkSmartPointer<vtkIdTypeArray> cells;
|
vtkSmartPointer<vtkIdTypeArray> cells;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO This will be used to contain both cloud and shape actors
|
|
||||||
struct CV_EXPORTS WidgetActor
|
|
||||||
{
|
|
||||||
vtkSmartPointer<vtkProp> actor;
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> viewpoint_transformation_;
|
|
||||||
vtkSmartPointer<vtkIdTypeArray> cells;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<std::string, CloudActor> CloudActorMap;
|
// TODO This will be used to contain both cloud and shape actors
|
||||||
typedef std::map<std::string, vtkSmartPointer<vtkProp> > ShapeActorMap;
|
struct CV_EXPORTS WidgetActor
|
||||||
typedef std::map<std::string, WidgetActor> WidgetActorMap;
|
{
|
||||||
|
vtkSmartPointer<vtkProp> actor;
|
||||||
|
vtkSmartPointer<vtkMatrix4x4> viewpoint_transformation_;
|
||||||
|
vtkSmartPointer<vtkIdTypeArray> cells;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<std::string, CloudActor> CloudActorMap;
|
||||||
|
typedef std::map<std::string, vtkSmartPointer<vtkProp> > ShapeActorMap;
|
||||||
|
typedef std::map<std::string, WidgetActor> WidgetActorMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// widget implementation
|
/// widget implementation
|
||||||
|
|
||||||
class temp_viz::Widget::Impl
|
class cv::viz::Widget::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkSmartPointer<vtkProp> prop;
|
vtkSmartPointer<vtkProp> prop;
|
||||||
@ -12,17 +12,17 @@ public:
|
|||||||
Impl() : prop(0) {}
|
Impl() : prop(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
temp_viz::Widget::Widget() : impl_(0)
|
cv::viz::Widget::Widget() : impl_(0)
|
||||||
{
|
{
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Widget::Widget(const Widget &other) : impl_(other.impl_)
|
cv::viz::Widget::Widget(const Widget &other) : impl_(other.impl_)
|
||||||
{
|
{
|
||||||
if (impl_) CV_XADD(&impl_->ref_counter, 1);
|
if (impl_) CV_XADD(&impl_->ref_counter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Widget& temp_viz::Widget::operator=(const Widget &other)
|
cv::viz::Widget& cv::viz::Widget::operator=(const Widget &other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
@ -33,19 +33,19 @@ temp_viz::Widget& temp_viz::Widget::operator=(const Widget &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Widget::~Widget()
|
cv::viz::Widget::~Widget()
|
||||||
{
|
{
|
||||||
release();
|
release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Widget::create()
|
void cv::viz::Widget::create()
|
||||||
{
|
{
|
||||||
if (impl_) release();
|
if (impl_) release();
|
||||||
impl_ = new Impl();
|
impl_ = new Impl();
|
||||||
impl_->ref_counter = 1;
|
impl_->ref_counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Widget::release()
|
void cv::viz::Widget::release()
|
||||||
{
|
{
|
||||||
if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1)
|
if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1)
|
||||||
{
|
{
|
||||||
@ -57,12 +57,12 @@ void temp_viz::Widget::release()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// widget accessor implementaion
|
/// widget accessor implementaion
|
||||||
|
|
||||||
vtkSmartPointer<vtkProp> temp_viz::WidgetAccessor::getProp(const Widget& widget)
|
vtkSmartPointer<vtkProp> cv::viz::WidgetAccessor::getProp(const Widget& widget)
|
||||||
{
|
{
|
||||||
return widget.impl_->prop;
|
return widget.impl_->prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> prop)
|
void cv::viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> prop)
|
||||||
{
|
{
|
||||||
widget.impl_->prop = prop;
|
widget.impl_->prop = prop;
|
||||||
}
|
}
|
||||||
@ -70,18 +70,18 @@ void temp_viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp>
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// widget3D implementation
|
/// widget3D implementation
|
||||||
|
|
||||||
struct temp_viz::Widget3D::MatrixConverter
|
struct cv::viz::Widget3D::MatrixConverter
|
||||||
{
|
{
|
||||||
static cv::Matx44f convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
|
static Matx44f convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
|
||||||
{
|
{
|
||||||
cv::Matx44f m;
|
Matx44f m;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
for (int k = 0; k < 4; k++)
|
for (int k = 0; k < 4; k++)
|
||||||
m(i, k) = vtk_matrix->GetElement (i, k);
|
m(i, k) = vtk_matrix->GetElement (i, k);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f& m)
|
static vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const Matx44f& m)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New ();
|
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New ();
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
@ -91,7 +91,7 @@ struct temp_viz::Widget3D::MatrixConverter
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
void cv::viz::Widget3D::setPose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -101,7 +101,7 @@ void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Widget3D::updatePose(const Affine3f &pose)
|
void cv::viz::Widget3D::updatePose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -121,7 +121,7 @@ void temp_viz::Widget3D::updatePose(const Affine3f &pose)
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_viz::Affine3f temp_viz::Widget3D::getPose() const
|
cv::Affine3f cv::viz::Widget3D::getPose() const
|
||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -131,7 +131,7 @@ temp_viz::Affine3f temp_viz::Widget3D::getPose() const
|
|||||||
return Affine3f(matrix_cv);
|
return Affine3f(matrix_cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Widget3D::setColor(const Color &color)
|
void cv::viz::Widget3D::setColor(const Color &color)
|
||||||
{
|
{
|
||||||
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
||||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
@ -148,7 +148,7 @@ void temp_viz::Widget3D::setColor(const Color &color)
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::Widget3D temp_viz::Widget::cast<temp_viz::Widget3D>()
|
template<> cv::viz::Widget3D cv::viz::Widget::cast<cv::viz::Widget3D>()
|
||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -161,7 +161,7 @@ template<> temp_viz::Widget3D temp_viz::Widget::cast<temp_viz::Widget3D>()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// widget2D implementation
|
/// widget2D implementation
|
||||||
|
|
||||||
void temp_viz::Widget2D::setColor(const Color &color)
|
void cv::viz::Widget2D::setColor(const Color &color)
|
||||||
{
|
{
|
||||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
@ -170,7 +170,7 @@ void temp_viz::Widget2D::setColor(const Color &color)
|
|||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> temp_viz::Widget2D temp_viz::Widget::cast<temp_viz::Widget2D>()
|
template<> cv::viz::Widget2D cv::viz::Widget::cast<cv::viz::Widget2D>()
|
||||||
{
|
{
|
||||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
CV_Assert(actor);
|
CV_Assert(actor);
|
||||||
|
Loading…
Reference in New Issue
Block a user