switched completer API to doubles, updated docs

This commit is contained in:
Anatoly Baksheev 2014-01-07 21:27:11 +04:00
parent d264465422
commit 56819eaf19
4 changed files with 119 additions and 120 deletions

View File

@ -262,8 +262,8 @@ This 3D Widget defines a finite plane. ::
class CV_EXPORTS WPlane : public Widget3D class CV_EXPORTS WPlane : public Widget3D
{ {
public: public:
WPlane(const Vec4f& coefs, float size = 1.0, const Color &color = Color::white()); WPlane(const Vec4d& coefs, double size = 1.0, const Color &color = Color::white());
WPlane(const Vec4f& coefs, const Point3f& pt, float size = 1.0, const Color &color = Color::white()); WPlane(const Vec4d& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
private: private:
/* hidden */ /* hidden */
}; };
@ -272,13 +272,13 @@ viz::WPlane::WPlane
------------------- -------------------
Constructs a WPlane. Constructs a WPlane.
.. ocv:function:: WPlane(const Vec4f& coefs, float size = 1.0, const Color &color = Color::white()) .. ocv:function:: WPlane(const Vec4d& coefs, double size = 1.0, const Color &color = Color::white())
:param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0.
:param size: Size of the plane. :param size: Size of the plane.
:param color: :ocv:class:`Color` of the plane. :param color: :ocv:class:`Color` of the plane.
.. ocv:function:: WPlane(const Vec4f& coefs, const Point3f& pt, float size = 1.0, const Color &color = Color::white()) .. ocv:function:: WPlane(const Vec4d& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white())
:param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param coefs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0.
:param pt: Position of the plane. :param pt: Position of the plane.
@ -294,14 +294,14 @@ This 3D Widget defines a sphere. ::
class CV_EXPORTS WSphere : public Widget3D class CV_EXPORTS WSphere : public Widget3D
{ {
public: public:
WSphere(const cv::Point3f &center, float radius, int sphere_resolution = 10, const Color &color = Color::white()) WSphere(const cv::Point3f &center, double radius, int sphere_resolution = 10, const Color &color = Color::white())
}; };
viz::WSphere::WSphere viz::WSphere::WSphere
--------------------- ---------------------
Constructs a WSphere. Constructs a WSphere.
.. ocv:function:: WSphere(const cv::Point3f &center, float radius, int sphere_resolution = 10, const Color &color = Color::white()) .. ocv:function:: WSphere(const cv::Point3f &center, double radius, int sphere_resolution = 10, const Color &color = Color::white())
:param center: Center of the sphere. :param center: Center of the sphere.
:param radius: Radius of the sphere. :param radius: Radius of the sphere.
@ -317,14 +317,14 @@ This 3D Widget defines an arrow. ::
class CV_EXPORTS WArrow : public Widget3D class CV_EXPORTS WArrow : public Widget3D
{ {
public: public:
WArrow(const Point3f& pt1, const Point3f& pt2, float thickness = 0.03, const Color &color = Color::white()); WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white());
}; };
viz::WArrow::WArrow viz::WArrow::WArrow
----------------------------- -----------------------------
Constructs an WArrow. Constructs an WArrow.
.. ocv:function:: WArrow(const Point3f& pt1, const Point3f& pt2, float thickness = 0.03, const Color &color = Color::white()) .. ocv:function:: WArrow(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white())
:param pt1: Start point of the arrow. :param pt1: Start point of the arrow.
:param pt2: End point of the arrow. :param pt2: End point of the arrow.
@ -342,14 +342,14 @@ This 3D Widget defines a circle. ::
class CV_EXPORTS WCircle : public Widget3D class CV_EXPORTS WCircle : public Widget3D
{ {
public: public:
WCircle(const Point3f& pt, float radius, float thickness = 0.01, const Color &color = Color::white()); WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
}; };
viz::WCircle::WCircle viz::WCircle::WCircle
------------------------------- -------------------------------
Constructs a WCircle. Constructs a WCircle.
.. ocv:function:: WCircle(const Point3f& pt, float radius, float thickness = 0.01, const Color &color = Color::white()) .. ocv:function:: WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white())
:param pt: Center of the circle. :param pt: Center of the circle.
:param radius: Radius of the circle. :param radius: Radius of the circle.
@ -365,14 +365,14 @@ This 3D Widget defines a cylinder. ::
class CV_EXPORTS WCylinder : public Widget3D class CV_EXPORTS WCylinder : public Widget3D
{ {
public: public:
WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, float radius, int numsides = 30, const Color &color = Color::white()); WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
}; };
viz::WCylinder::WCylinder viz::WCylinder::WCylinder
----------------------------------- -----------------------------------
Constructs a WCylinder. Constructs a WCylinder.
.. ocv:function:: WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, float radius, int numsides = 30, const Color &color = Color::white()) .. ocv:function:: WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white())
:param pt_on_axis: A point on the axis of the cylinder. :param pt_on_axis: A point on the axis of the cylinder.
:param axis_direction: Direction of the axis of the cylinder. :param axis_direction: Direction of the axis of the cylinder.
@ -416,14 +416,14 @@ This 3D Widget represents a coordinate system. ::
class CV_EXPORTS WCoordinateSystem : public Widget3D class CV_EXPORTS WCoordinateSystem : public Widget3D
{ {
public: public:
WCoordinateSystem(float scale = 1.0); WCoordinateSystem(double scale = 1.0);
}; };
viz::WCoordinateSystem::WCoordinateSystem viz::WCoordinateSystem::WCoordinateSystem
--------------------------------------------------- ---------------------------------------------------
Constructs a WCoordinateSystem. Constructs a WCoordinateSystem.
.. ocv:function:: WCoordinateSystem(float scale = 1.0) .. ocv:function:: WCoordinateSystem(double scale = 1.0)
:param scale: Determines the size of the axes. :param scale: Determines the size of the axes.
@ -463,7 +463,7 @@ This 3D Widget defines a grid. ::
//! Creates grid at the origin //! Creates grid at the origin
WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
//! Creates grid based on the plane equation //! Creates grid based on the plane equation
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); WGrid(const Vec4d &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
private: private:
/* hidden */ /* hidden */
}; };
@ -478,7 +478,7 @@ Constructs a WGrid.
:param spacing: Size of each column and row, respectively. :param spacing: Size of each column and row, respectively.
:param color: :ocv:class:`Color` of the grid. :param color: :ocv:class:`Color` of the grid.
.. ocv:function: WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()) .. ocv:function: WGrid(const Vec4d &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white())
:param coeffs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0. :param coeffs: Plane coefficients as in (A,B,C,D) where Ax + By + Cz + D = 0.
:param dimensions: Number of columns and rows, respectively. :param dimensions: Number of columns and rows, respectively.
@ -494,7 +494,7 @@ This 3D Widget represents 3D text. The text always faces the camera. ::
class CV_EXPORTS WText3D : public Widget3D class CV_EXPORTS WText3D : public Widget3D
{ {
public: public:
WText3D(const String &text, const Point3f &position, float text_scale = 1.0, bool face_camera = true, const Color &color = Color::white()); WText3D(const String &text, const Point3f &position, double text_scale = 1.0, bool face_camera = true, const Color &color = Color::white());
void setText(const String &text); void setText(const String &text);
String getText() const; String getText() const;
@ -504,7 +504,7 @@ viz::WText3D::WText3D
------------------------------- -------------------------------
Constructs a WText3D. Constructs a WText3D.
.. ocv:function:: WText3D(const String &text, const Point3f &position, float text_scale = 1.0, bool face_camera = true, const Color &color = Color::white()) .. ocv:function:: WText3D(const String &text, const Point3f &position, double text_scale = 1.0, bool face_camera = true, const Color &color = Color::white())
:param text: Text content of the widget. :param text: Text content of the widget.
:param position: Position of the text. :param position: Position of the text.
@ -609,7 +609,7 @@ This 3D Widget represents an image in 3D space. ::
//! Creates 3D image at the origin //! Creates 3D image at the origin
WImage3D(const Mat &image, const Size &size); WImage3D(const Mat &image, const Size &size);
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation //! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); WImage3D(const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector, const Mat &image, const Size &size);
void setImage(const Mat &image); void setImage(const Mat &image);
}; };
@ -623,7 +623,7 @@ Constructs an WImage3D.
:param image: BGR or Gray-Scale image. :param image: BGR or Gray-Scale image.
:param size: Size of the image. :param size: Size of the image.
.. ocv:function:: WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) .. ocv:function:: WImage3D(const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector, const Mat &image, const Size &size)
:param position: Position of the image. :param position: Position of the image.
:param normal: Normal of the plane that represents the image. :param normal: Normal of the plane that represents the image.
@ -649,15 +649,15 @@ This 3D Widget represents camera position in a scene by its axes or viewing frus
{ {
public: public:
//! Creates camera coordinate frame (axes) at the origin //! Creates camera coordinate frame (axes) at the origin
WCameraPosition(float scale = 1.0); WCameraPosition(double scale = 1.0);
//! Creates frustum based on the intrinsic marix K at the origin //! Creates frustum based on the intrinsic marix K at the origin
WCameraPosition(const Matx33f &K, float scale = 1.0, const Color &color = Color::white()); WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum based on the field of view at the origin //! Creates frustum based on the field of view at the origin
WCameraPosition(const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()); WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum and display given image at the far plane //! Creates frustum and display given image at the far plane
WCameraPosition(const Matx33f &K, const Mat &img, float scale = 1.0, const Color &color = Color::white()); WCameraPosition(const Matx33d &K, const Mat &img, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum and display given image at the far plane //! Creates frustum and display given image at the far plane
WCameraPosition(const Vec2f &fov, const Mat &img, float scale = 1.0, const Color &color = Color::white()); WCameraPosition(const Vec2d &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
}; };
viz::WCameraPosition::WCameraPosition viz::WCameraPosition::WCameraPosition
@ -666,7 +666,7 @@ Constructs a WCameraPosition.
- **Display camera coordinate frame.** - **Display camera coordinate frame.**
.. ocv:function:: WCameraPosition(float scale = 1.0) .. ocv:function:: WCameraPosition(double scale = 1.0)
Creates camera coordinate frame at the origin. Creates camera coordinate frame at the origin.
@ -676,7 +676,7 @@ Constructs a WCameraPosition.
- **Display the viewing frustum.** - **Display the viewing frustum.**
.. ocv:function:: WCameraPosition(const Matx33f &K, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white())
:param K: Intrinsic matrix of the camera. :param K: Intrinsic matrix of the camera.
:param scale: Scale of the frustum. :param scale: Scale of the frustum.
@ -684,7 +684,7 @@ Constructs a WCameraPosition.
Creates viewing frustum of the camera based on its intrinsic matrix K. Creates viewing frustum of the camera based on its intrinsic matrix K.
.. ocv:function:: WCameraPosition(const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white())
:param fov: Field of view of the camera (horizontal, vertical). :param fov: Field of view of the camera (horizontal, vertical).
:param scale: Scale of the frustum. :param scale: Scale of the frustum.
@ -698,7 +698,7 @@ Constructs a WCameraPosition.
- **Display image on the far plane of the viewing frustum.** - **Display image on the far plane of the viewing frustum.**
.. ocv:function:: WCameraPosition(const Matx33f &K, const Mat &img, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WCameraPosition(const Matx33d &K, const Mat &img, double scale = 1.0, const Color &color = Color::white())
:param K: Intrinsic matrix of the camera. :param K: Intrinsic matrix of the camera.
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. :param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
@ -707,7 +707,7 @@ Constructs a WCameraPosition.
Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane. Creates viewing frustum of the camera based on its intrinsic matrix K, and displays image on the far end plane.
.. ocv:function:: WCameraPosition(const Vec2f &fov, const Mat &img, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WCameraPosition(const Vec2d &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white())
:param fov: Field of view of the camera (horizontal, vertical). :param fov: Field of view of the camera (horizontal, vertical).
:param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum. :param img: BGR or Gray-Scale image that is going to be displayed on the far plane of the frustum.
@ -732,14 +732,14 @@ This 3D Widget represents a trajectory. ::
enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH}; enum {FRAMES = 1, PATH = 2, BOTH = FRAMES + PATH};
//! Displays trajectory of the given path either by coordinate frames or polyline //! Displays trajectory of the given path either by coordinate frames or polyline
WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, float scale = 1.f, const Color &color = Color::white(),; WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.f, const Color &color = Color::white(),;
}; };
viz::WTrajectory::WTrajectory viz::WTrajectory::WTrajectory
----------------------------- -----------------------------
Constructs a WTrajectory. Constructs a WTrajectory.
.. ocv:function:: WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, float scale = 1.f, const Color &color = Color::white()) .. ocv:function:: WTrajectory(InputArray path, int display_mode = WTrajectory::PATH, double scale = 1.f, const Color &color = Color::white())
:param path: List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double] :param path: List of poses on a trajectory. Takes std::vector<Affine<T>> with T == [float | double]
:param display_mode: Display mode. This can be PATH, FRAMES, and BOTH. :param display_mode: Display mode. This can be PATH, FRAMES, and BOTH.
@ -762,16 +762,16 @@ This 3D Widget represents a trajectory. ::
{ {
public: public:
//! Displays trajectory of the given path by frustums //! Displays trajectory of the given path by frustums
WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()); WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
//! Displays trajectory of the given path by frustums //! Displays trajectory of the given path by frustums
WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()); WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
}; };
viz::WTrajectoryFrustums::WTrajectoryFrustums viz::WTrajectoryFrustums::WTrajectoryFrustums
----------------------------- -----------------------------
Constructs a WTrajectoryFrustums. Constructs a WTrajectoryFrustums.
.. ocv:function:: WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33d &K, double scale = 1.0, const Color &color = Color::white())
:param path: List of poses on a trajectory. :param path: List of poses on a trajectory.
:param K: Intrinsic matrix of the camera. :param K: Intrinsic matrix of the camera.
@ -780,7 +780,7 @@ Constructs a WTrajectoryFrustums.
Displays frustums at each pose of the trajectory. Displays frustums at each pose of the trajectory.
.. ocv:function:: WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()) .. ocv:function:: WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2d &fov, double scale = 1.0, const Color &color = Color::white())
:param path: List of poses on a trajectory. :param path: List of poses on a trajectory.
:param fov: Field of view of the camera (horizontal, vertical). :param fov: Field of view of the camera (horizontal, vertical).
@ -799,8 +799,8 @@ represent the direction from previous position to the current. ::
class CV_EXPORTS WTrajectorySpheres : public Widget3D class CV_EXPORTS WTrajectorySpheres : public Widget3D
{ {
public: public:
WTrajectorySpheres(const std::vector<Affine3d> &path, float line_length = 0.05f, WTrajectorySpheres(const std::vector<Affine3d> &path, double line_length = 0.05f,
float init_sphere_radius = 0.021, sphere_radius = 0.007, double init_sphere_radius = 0.021, sphere_radius = 0.007,
Color &line_color = Color::white(), const Color &sphere_color = Color::white()); Color &line_color = Color::white(), const Color &sphere_color = Color::white());
}; };
@ -808,7 +808,7 @@ viz::WTrajectorySpheres::WTrajectorySpheres
------------------------------------------- -------------------------------------------
Constructs a WTrajectorySpheres. Constructs a WTrajectorySpheres.
.. ocv:function:: WTrajectorySpheres(const std::vector<Affine3d> &path, float line_length = 0.05f, float init_sphere_radius = 0.021, float sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()) .. ocv:function:: WTrajectorySpheres(const std::vector<Affine3d> &path, double line_length = 0.05f, double init_sphere_radius = 0.021, double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white())
:param path: List of poses on a trajectory. :param path: List of poses on a trajectory.
:param line_length: Length of the lines. :param line_length: Length of the lines.
@ -912,7 +912,7 @@ This 3D Widget represents normals of a point cloud. ::
class CV_EXPORTS WCloudNormals : public Widget3D class CV_EXPORTS WCloudNormals : public Widget3D
{ {
public: public:
WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()); WCloudNormals(InputArray cloud, InputArray normals, int level = 100, double scale = 0.02f, const Color &color = Color::white());
private: private:
/* hidden */ /* hidden */
@ -922,7 +922,7 @@ viz::WCloudNormals::WCloudNormals
--------------------------------- ---------------------------------
Constructs a WCloudNormals. Constructs a WCloudNormals.
.. ocv:function:: WCloudNormals(InputArray cloud, InputArray normals, int level = 100, float scale = 0.02f, const Color &color = Color::white()) .. ocv:function:: WCloudNormals(InputArray cloud, InputArray normals, int level = 100, double scale = 0.02f, const Color &color = Color::white())
:param cloud: Point set which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. :param cloud: Point set which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``.
:param normals: A set of normals that has to be of same type with cloud. :param normals: A set of normals that has to be of same type with cloud.

View File

@ -135,44 +135,44 @@ namespace cv
class CV_EXPORTS WLine : public Widget3D class CV_EXPORTS WLine : public Widget3D
{ {
public: public:
WLine(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); WLine(const Point3d &pt1, const Point3d &pt2, const Color &color = Color::white());
}; };
class CV_EXPORTS WPlane : public Widget3D class CV_EXPORTS WPlane : public Widget3D
{ {
public: public:
WPlane(const Vec4f& coefs, float size = 1.f, const Color &color = Color::white()); WPlane(const Vec4d& coefs, double size = 1.f, const Color &color = Color::white());
WPlane(const Vec4f& coefs, const Point3f& pt, float size = 1.f, const Color &color = Color::white()); WPlane(const Vec4d& coefs, const Point3d& pt, double size = 1.f, const Color &color = Color::white());
}; };
class CV_EXPORTS WSphere : public Widget3D class CV_EXPORTS WSphere : public Widget3D
{ {
public: public:
WSphere(const cv::Point3f &center, float radius, int sphere_resolution = 10, const Color &color = Color::white()); WSphere(const cv::Point3d &center, double radius, int sphere_resolution = 10, const Color &color = Color::white());
}; };
class CV_EXPORTS WArrow : public Widget3D class CV_EXPORTS WArrow : public Widget3D
{ {
public: public:
WArrow(const Point3f& pt1, const Point3f& pt2, float thickness = 0.03f, const Color &color = Color::white()); WArrow(const Point3d& pt1, const Point3d& pt2, double thickness = 0.03, const Color &color = Color::white());
}; };
class CV_EXPORTS WCircle : public Widget3D class CV_EXPORTS WCircle : public Widget3D
{ {
public: public:
WCircle(const Point3f& pt, float radius, float thickness = 0.01f, const Color &color = Color::white()); WCircle(const Point3d& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
}; };
class CV_EXPORTS WCylinder : public Widget3D class CV_EXPORTS WCylinder : public Widget3D
{ {
public: public:
WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, float radius, int numsides = 30, const Color &color = Color::white()); WCylinder(const Point3d& pt_on_axis, const Point3d& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
}; };
class CV_EXPORTS WCube : public Widget3D class CV_EXPORTS WCube : public Widget3D
{ {
public: public:
WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white()); WCube(const Point3d& pt_min, const Point3d& pt_max, bool wire_frame = true, const Color &color = Color::white());
}; };
class CV_EXPORTS WPolyLine : public Widget3D class CV_EXPORTS WPolyLine : public Widget3D
@ -196,7 +196,7 @@ namespace cv
class CV_EXPORTS WText3D : public Widget3D class CV_EXPORTS WText3D : public Widget3D
{ {
public: public:
WText3D(const String &text, const Point3f &position, float text_scale = 1.f, bool face_camera = true, const Color &color = Color::white()); WText3D(const String &text, const Point3d &position, double text_scale = 1., bool face_camera = true, const Color &color = Color::white());
void setText(const String &text); void setText(const String &text);
String getText() const; String getText() const;
@ -216,7 +216,7 @@ namespace cv
//! Creates 3D image at the origin //! Creates 3D image at the origin
WImage3D(const Mat &image, const Size &size); WImage3D(const Mat &image, const Size &size);
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation //! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size); WImage3D(const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector, const Mat &image, const Size &size);
void setImage(const Mat &image); void setImage(const Mat &image);
}; };
@ -234,24 +234,24 @@ namespace cv
{ {
public: public:
//! Creates grid at the origin //! Creates grid at the origin
WGrid(const Vec2i &dimensions, const Vec2f &spacing, const Color &color = Color::white()); WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
//! Creates grid based on the plane equation //! Creates grid based on the plane equation
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2f &spacing, const Color &color = Color::white()); WGrid(const Vec4d &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
}; };
class CV_EXPORTS WCameraPosition : public Widget3D class CV_EXPORTS WCameraPosition : public Widget3D
{ {
public: public:
//! Creates camera coordinate frame (axes) at the origin //! Creates camera coordinate frame (axes) at the origin
WCameraPosition(float scale = 1.f); WCameraPosition(double scale = 1.0);
//! Creates frustum based on the intrinsic marix K at the origin //! Creates frustum based on the intrinsic marix K at the origin
WCameraPosition(const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); WCameraPosition(const Matx33d &K, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum based on the field of view at the origin //! Creates frustum based on the field of view at the origin
WCameraPosition(const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); WCameraPosition(const Vec2d &fov, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum and display given image at the far plane //! Creates frustum and display given image at the far plane
WCameraPosition(const Matx33f &K, const Mat &img, float scale = 1.f, const Color &color = Color::white()); WCameraPosition(const Matx33d &K, const Mat &img, double scale = 1.0, const Color &color = Color::white());
//! Creates frustum and display given image at the far plane //! Creates frustum and display given image at the far plane
WCameraPosition(const Vec2f &fov, const Mat &img, float scale = 1.f, const Color &color = Color::white()); WCameraPosition(const Vec2d &fov, const Mat &img, double scale = 1.0, const Color &color = Color::white());
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -270,16 +270,16 @@ namespace cv
{ {
public: public:
//! Displays trajectory of the given path by frustums //! Displays trajectory of the given path by frustums
WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33d &K, double scale = 1., const Color &color = Color::white());
//! Displays trajectory of the given path by frustums //! Displays trajectory of the given path by frustums
WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2d &fov, double scale = 1., const Color &color = Color::white());
}; };
class CV_EXPORTS WTrajectorySpheres: public Widget3D class CV_EXPORTS WTrajectorySpheres: public Widget3D
{ {
public: public:
WTrajectorySpheres(const std::vector<Affine3d> &path, float line_length = 0.05f, float init_sphere_radius = 0.021f, WTrajectorySpheres(const std::vector<Affine3d> &path, double line_length = 0.05, double init_sphere_radius = 0.021,
float sphere_radius = 0.007f, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()); double sphere_radius = 0.007, const Color &line_color = Color::white(), const Color &sphere_color = Color::white());
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -308,7 +308,7 @@ namespace cv
class CV_EXPORTS WCloudNormals : public Widget3D class CV_EXPORTS WCloudNormals : public Widget3D
{ {
public: public:
WCloudNormals(InputArray cloud, InputArray normals, int level = 64, float scale = 0.1f, const Color &color = Color::white()); WCloudNormals(InputArray cloud, InputArray normals, int level = 64, double scale = 0.1, const Color &color = Color::white());
}; };
class CV_EXPORTS WMesh : public Widget3D class CV_EXPORTS WMesh : public Widget3D

View File

@ -175,7 +175,7 @@ template<> cv::viz::WCloudCollection cv::viz::Widget::cast<cv::viz::WCloudCollec
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// Cloud Normals Widget implementation /// Cloud Normals Widget implementation
cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, int level, float scale, const Color &color) cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, int level, double scale, const Color &color)
{ {
Mat cloud = _cloud.getMat(); Mat cloud = _cloud.getMat();
Mat normals = _normals.getMat(); Mat normals = _normals.getMat();
@ -207,7 +207,7 @@ cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, in
for (; srow < send; srow += xstep * s_chs, nrow += xstep * n_chs) for (; srow < send; srow += xstep * s_chs, nrow += xstep * n_chs)
if (!isNan(srow) && !isNan(nrow)) if (!isNan(srow) && !isNan(nrow))
{ {
Vec3f endp = Vec3f(srow) + Vec3f(nrow) * scale; Vec3f endp = Vec3f(srow) + Vec3f(nrow) * (float)scale;
points->InsertNextPoint(srow); points->InsertNextPoint(srow);
points->InsertNextPoint(endp.val); points->InsertNextPoint(endp.val);

View File

@ -55,7 +55,7 @@ namespace cv
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// line widget implementation /// line widget implementation
cv::viz::WLine::WLine(const Point3f &pt1, const Point3f &pt2, const Color &color) cv::viz::WLine::WLine(const Point3d &pt1, const Point3d &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);
@ -103,11 +103,11 @@ namespace cv { namespace viz { namespace
}; };
}}} }}}
cv::viz::WPlane::WPlane(const Vec4f& coefs, float size, const Color &color) cv::viz::WPlane::WPlane(const Vec4d& 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(Vec3f(coefs.val)); double norm = cv::norm(Vec3d(coefs.val));
plane->Push(-coefs[3] / norm); plane->Push(-coefs[3] / norm);
Vec3d p_center; Vec3d p_center;
@ -123,15 +123,15 @@ cv::viz::WPlane::WPlane(const Vec4f& coefs, float size, const Color &color)
setColor(color); setColor(color);
} }
cv::viz::WPlane::WPlane(const Vec4f& coefs, const Point3f& pt, float size, const Color &color) cv::viz::WPlane::WPlane(const Vec4d& coefs, const Point3d& pt, double size, const Color &color)
{ {
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New(); vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
Point3f coefs3(coefs[0], coefs[1], coefs[2]); Point3d 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];
Vec3f p_center = pt - coefs3 * t * norm_sqr; Vec3d 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<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
@ -153,7 +153,7 @@ template<> cv::viz::WPlane cv::viz::Widget::cast<cv::viz::WPlane>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// sphere widget implementation /// sphere widget implementation
cv::viz::WSphere::WSphere(const Point3f &center, float radius, int sphere_resolution, const Color &color) cv::viz::WSphere::WSphere(const Point3d &center, double 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);
@ -181,7 +181,7 @@ template<> cv::viz::WSphere cv::viz::Widget::cast<cv::viz::WSphere>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// arrow widget implementation /// arrow widget implementation
cv::viz::WArrow::WArrow(const Point3f& pt1, const Point3f& pt2, float thickness, const Color &color) cv::viz::WArrow::WArrow(const Point3d& pt1, const Point3d& pt2, double thickness, const Color &color)
{ {
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New(); vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
arrowSource->SetShaftRadius(thickness); arrowSource->SetShaftRadius(thickness);
@ -231,7 +231,7 @@ template<> cv::viz::WArrow cv::viz::Widget::cast<cv::viz::WArrow>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// circle widget implementation /// circle widget implementation
cv::viz::WCircle::WCircle(const Point3f& pt, float radius, float thickness, const Color& color) cv::viz::WCircle::WCircle(const Point3d& 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
@ -267,9 +267,9 @@ template<> cv::viz::WCircle cv::viz::Widget::cast<cv::viz::WCircle>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation /// cylinder widget implementation
cv::viz::WCylinder::WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, float radius, int numsides, const Color &color) cv::viz::WCylinder::WCylinder(const Point3d& pt_on_axis, const Point3d& axis_direction, double radius, int numsides, const Color &color)
{ {
const Point3f pt2 = pt_on_axis + axis_direction; const Point3d 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);
@ -298,7 +298,7 @@ template<> cv::viz::WCylinder cv::viz::Widget::cast<cv::viz::WCylinder>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation /// cylinder widget implementation
cv::viz::WCube::WCube(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color) cv::viz::WCube::WCube(const Point3d& pt_min, const Point3d& pt_max, bool wire_frame, const Color &color)
{ {
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
if (wire_frame) if (wire_frame)
@ -330,7 +330,7 @@ template<> cv::viz::WCube cv::viz::Widget::cast<cv::viz::WCube>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// coordinate system widget implementation /// coordinate system widget implementation
cv::viz::WCoordinateSystem::WCoordinateSystem(float scale) cv::viz::WCoordinateSystem::WCoordinateSystem(double scale)
{ {
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New(); vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New();
axes->SetOrigin(0, 0, 0); axes->SetOrigin(0, 0, 0);
@ -461,7 +461,7 @@ namespace cv { namespace viz { namespace
}; };
}}} }}}
cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2f &spacing, const Color &color) cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color)
{ {
vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing); vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing);
@ -479,14 +479,14 @@ cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2f &spacing, const Color
setColor(color); setColor(color);
} }
cv::viz::WGrid::WGrid(const Vec4f &coefs, const Vec2i &dimensions, const Vec2f &spacing, const Color &color) cv::viz::WGrid::WGrid(const Vec4d &coefs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color)
{ {
vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing); vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing);
// Estimate the transform to set the normal based on the coefficients // Estimate the transform to set the normal based on the coefficients
Vec3d normal(coefs[0], coefs[1], coefs[2]); Vec3d normal(coefs[0], coefs[1], coefs[2]);
Vec3d up_vector(0.0, 1.0, 0.0); // Just set as default Vec3d up_vector(0.0, 1.0, 0.0); // Just set as default
double push_distance = -coefs[3]/cv::norm(Vec3f(coefs.val)); double push_distance = -coefs[3]/cv::norm(Vec3d(coefs.val));
Vec3d n = normalize(normal); Vec3d n = normalize(normal);
Vec3d u = normalize(up_vector.cross(n)); Vec3d u = normalize(up_vector.cross(n));
Vec3d v = n.cross(u); Vec3d v = n.cross(u);
@ -525,7 +525,7 @@ template<> cv::viz::WGrid cv::viz::Widget::cast<cv::viz::WGrid>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// text3D widget implementation /// text3D widget implementation
cv::viz::WText3D::WText3D(const String &text, const Point3f &position, float text_scale, bool face_camera, const Color &color) cv::viz::WText3D::WText3D(const String &text, const Point3d &position, double text_scale, bool face_camera, 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());
@ -759,7 +759,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size &size)
WidgetAccessor::setProp(*this, actor); WidgetAccessor::setProp(*this, actor);
} }
cv::viz::WImage3D::WImage3D(const Vec3f &position, const Vec3f &normal, const Vec3f &up_vector, const Mat &image, const Size &size) cv::viz::WImage3D::WImage3D(const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector, const Mat &image, const Size &size)
{ {
CV_Assert(!image.empty() && image.depth() == CV_8U); CV_Assert(!image.empty() && image.depth() == CV_8U);
@ -857,7 +857,7 @@ namespace cv { namespace viz { namespace
{ {
struct CameraPositionUtils struct CameraPositionUtils
{ {
static void projectImage(float fovy, float far_end_height, const Mat &image, static void projectImage(double fovy, double far_end_height, const Mat &image,
double scale, const Color &color, vtkSmartPointer<vtkActor> actor) double scale, const Color &color, vtkSmartPointer<vtkActor> actor)
{ {
// Create a camera // Create a camera
@ -950,7 +950,7 @@ namespace cv { namespace viz { namespace
}; };
}}} }}}
cv::viz::WCameraPosition::WCameraPosition(float scale) cv::viz::WCameraPosition::WCameraPosition(double scale)
{ {
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New(); vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New();
axes->SetOrigin(0, 0, 0); axes->SetOrigin(0, 0, 0);
@ -992,20 +992,20 @@ cv::viz::WCameraPosition::WCameraPosition(float scale)
WidgetAccessor::setProp(*this, actor); WidgetAccessor::setProp(*this, actor);
} }
cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, float scale, const Color &color) cv::viz::WCameraPosition::WCameraPosition(const Matx33d &K, double scale, const Color &color)
{ {
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New(); vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
float f_x = K(0,0); double f_x = K(0,0);
float f_y = K(1,1); double f_y = K(1,1);
float c_y = K(1,2); double c_y = K(1,2);
float aspect_ratio = f_y / f_x; double aspect_ratio = f_y / f_x;
// Assuming that this is an ideal camera (c_y and c_x are at the center of the image) // Assuming that this is an ideal camera (c_y and c_x are at the center of the image)
float fovy = 2.0f * atan2(c_y,f_y) * 180 / CV_PI; double fovy = 2.0 * atan2(c_y,f_y) * 180 / CV_PI;
camera->SetViewAngle(fovy); camera->SetViewAngle(fovy);
camera->SetPosition(0.0,0.0,0.0); camera->SetPosition(0.0, 0.0, 0.0);
camera->SetViewUp(0.0,1.0,0.0); camera->SetViewUp(0.0, 1.0, 0.0);
camera->SetFocalPoint(0.0,0.0,1.0); camera->SetFocalPoint(0.0, 0.0, 1.0);
camera->SetClippingRange(0.01, scale); camera->SetClippingRange(0.01, scale);
double planesArray[24]; double planesArray[24];
@ -1014,8 +1014,7 @@ cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, float scale, const C
vtkSmartPointer<vtkPlanes> planes = vtkSmartPointer<vtkPlanes>::New(); vtkSmartPointer<vtkPlanes> planes = vtkSmartPointer<vtkPlanes>::New();
planes->SetFrustumPlanes(planesArray); planes->SetFrustumPlanes(planesArray);
vtkSmartPointer<vtkFrustumSource> frustumSource = vtkSmartPointer<vtkFrustumSource> frustumSource = vtkSmartPointer<vtkFrustumSource>::New();
vtkSmartPointer<vtkFrustumSource>::New();
frustumSource->SetPlanes(planes); frustumSource->SetPlanes(planes);
frustumSource->Update(); frustumSource->Update();
@ -1034,14 +1033,14 @@ cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, float scale, const C
} }
cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, float scale, const Color &color) cv::viz::WCameraPosition::WCameraPosition(const Vec2d &fov, double scale, const Color &color)
{ {
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New(); vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view
camera->SetPosition(0.0,0.0,0.0); camera->SetPosition(0.0, 0.0, 0.0);
camera->SetViewUp(0.0,1.0,0.0); camera->SetViewUp(0.0, 1.0, 0.0);
camera->SetFocalPoint(0.0,0.0,1.0); camera->SetFocalPoint(0.0, 0.0, 1.0);
camera->SetClippingRange(0.01, scale); camera->SetClippingRange(0.01, scale);
double aspect_ratio = tan(fov[0] * 0.5) / tan(fov[1] * 0.5); double aspect_ratio = tan(fov[0] * 0.5) / tan(fov[1] * 0.5);
@ -1072,25 +1071,25 @@ cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, float scale, const C
setColor(color); setColor(color);
} }
cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, const Mat &image, float scale, const Color &color) cv::viz::WCameraPosition::WCameraPosition(const Matx33d &K, const Mat &image, double scale, const Color &color)
{ {
CV_Assert(!image.empty() && image.depth() == CV_8U); CV_Assert(!image.empty() && image.depth() == CV_8U);
float f_y = K(1,1); double f_y = K(1,1);
float c_y = K(1,2); double c_y = K(1,2);
// Assuming that this is an ideal camera (c_y and c_x are at the center of the image) // Assuming that this is an ideal camera (c_y and c_x are at the center of the image)
float fovy = 2.0f * atan2(c_y,f_y) * 180.0f / CV_PI; double fovy = 2.0 * atan2(c_y,f_y) * 180.0 / CV_PI;
float far_end_height = 2.0f * c_y * scale / f_y; double far_end_height = 2.0f * c_y * scale / f_y;
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
CameraPositionUtils::projectImage(fovy, far_end_height, image, scale, color, actor); CameraPositionUtils::projectImage(fovy, far_end_height, image, scale, color, actor);
WidgetAccessor::setProp(*this, actor); WidgetAccessor::setProp(*this, actor);
} }
cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, const Mat &image, float scale, const Color &color) cv::viz::WCameraPosition::WCameraPosition(const Vec2d &fov, const Mat &image, double scale, const Color &color)
{ {
CV_Assert(!image.empty() && image.depth() == CV_8U); CV_Assert(!image.empty() && image.depth() == CV_8U);
float fovy = fov[1] * 180.0f / CV_PI; double fovy = fov[1] * 180.0 / CV_PI;
float far_end_height = 2.0 * scale * tan(fov[1] * 0.5); double far_end_height = 2.0 * scale * tan(fov[1] * 0.5);
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
CameraPositionUtils::projectImage(fovy, far_end_height, image, scale, color, actor); CameraPositionUtils::projectImage(fovy, far_end_height, image, scale, color, actor);
@ -1141,7 +1140,7 @@ namespace cv { namespace viz { namespace
}; };
}}} }}}
cv::viz::WTrajectory::WTrajectory(InputArray _path, int display_mode, float scale, const Color &color) cv::viz::WTrajectory::WTrajectory(InputArray _path, int display_mode, double scale, const Color &color)
{ {
CV_Assert(_path.kind() == _InputArray::STD_VECTOR || _path.kind() == _InputArray::MAT); CV_Assert(_path.kind() == _InputArray::STD_VECTOR || _path.kind() == _InputArray::MAT);
CV_Assert(_path.type() == CV_32FC(16) || _path.type() == CV_64FC(16)); CV_Assert(_path.type() == CV_32FC(16) || _path.type() == CV_64FC(16));
@ -1259,15 +1258,15 @@ template<> cv::viz::WTrajectory cv::viz::Widget::cast<cv::viz::WTrajectory>()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// WTrajectoryFrustums widget implementation /// WTrajectoryFrustums widget implementation
cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33f &K, float scale, const Color &color) cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3d> &path, const Matx33d &K, double scale, const Color &color)
{ {
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New(); vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
float f_x = K(0,0); double f_x = K(0,0);
float f_y = K(1,1); double f_y = K(1,1);
float c_y = K(1,2); double c_y = K(1,2);
float aspect_ratio = f_y / f_x; double aspect_ratio = f_y / f_x;
// Assuming that this is an ideal camera (c_y and c_x are at the center of the image) // Assuming that this is an ideal camera (c_y and c_x are at the center of the image)
float fovy = 2.0f * atan2(c_y,f_y) * 180 / CV_PI; double fovy = 2.0 * atan2(c_y,f_y) * 180 / CV_PI;
camera->SetViewAngle(fovy); camera->SetViewAngle(fovy);
camera->SetPosition(0.0,0.0,0.0); camera->SetPosition(0.0,0.0,0.0);
@ -1303,14 +1302,14 @@ cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3d> &p
setColor(color); setColor(color);
} }
cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2f &fov, float scale, const Color &color) cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector<Affine3d> &path, const Vec2d &fov, double scale, const Color &color)
{ {
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New(); vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view
camera->SetPosition(0.0,0.0,0.0); camera->SetPosition(0.0, 0.0, 0.0);
camera->SetViewUp(0.0,1.0,0.0); camera->SetViewUp(0.0, 1.0, 0.0);
camera->SetFocalPoint(0.0,0.0,1.0); camera->SetFocalPoint(0.0, 0.0, 1.0);
camera->SetClippingRange(0.01, scale); camera->SetClippingRange(0.01, scale);
double aspect_ratio = tan(fov[0] * 0.5) / tan(fov[1] * 0.5); double aspect_ratio = tan(fov[0] * 0.5) / tan(fov[1] * 0.5);
@ -1352,7 +1351,7 @@ template<> cv::viz::WTrajectoryFrustums cv::viz::Widget::cast<cv::viz::WTrajecto
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// WTrajectorySpheres widget implementation /// WTrajectorySpheres widget implementation
cv::viz::WTrajectorySpheres::WTrajectorySpheres(const std::vector<Affine3d> &path, float line_length, float init_sphere_radius, float sphere_radius, cv::viz::WTrajectorySpheres::WTrajectorySpheres(const std::vector<Affine3d> &path, double line_length, double init_sphere_radius, double sphere_radius,
const Color &line_color, const Color &sphere_color) const Color &line_color, const Color &sphere_color)
{ {
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New(); vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();