diff --git a/modules/viz/doc/widget.rst b/modules/viz/doc/widget.rst index 159e4ba80631a34f61ec9c2739cca0ce0ebc780a..936cc5a9df4b843c7cda902426cf02d32ef01a3c 100644 --- a/modules/viz/doc/widget.rst +++ b/modules/viz/doc/widget.rst @@ -262,8 +262,8 @@ This 3D Widget defines a finite plane. :: class CV_EXPORTS WPlane : public Widget3D { public: - WPlane(const Vec4f& coefs, float 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, double 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: /* hidden */ }; @@ -272,13 +272,13 @@ viz::WPlane::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 size: Size 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 pt: Position of the plane. @@ -294,14 +294,14 @@ This 3D Widget defines a sphere. :: class CV_EXPORTS WSphere : public Widget3D { public: - WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) + WSphere(const cv::Point3f ¢er, double radius, int sphere_resolution = 10, const Color &color = Color::white()) }; viz::WSphere::WSphere --------------------- Constructs a WSphere. -.. ocv:function:: WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()) +.. ocv:function:: WSphere(const cv::Point3f ¢er, double radius, int sphere_resolution = 10, const Color &color = Color::white()) :param center: Center 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 { 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 ----------------------------- 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 pt2: End point of the arrow. @@ -342,14 +342,14 @@ This 3D Widget defines a circle. :: class CV_EXPORTS WCircle : public Widget3D { 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 ------------------------------- 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 radius: Radius of the circle. @@ -365,14 +365,14 @@ This 3D Widget defines a cylinder. :: class CV_EXPORTS WCylinder : public Widget3D { 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 ----------------------------------- 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 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 { public: - WCoordinateSystem(float scale = 1.0); + WCoordinateSystem(double scale = 1.0); }; viz::WCoordinateSystem::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. @@ -463,7 +463,7 @@ This 3D Widget defines a grid. :: //! Creates grid at the origin WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white()); //! 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: /* hidden */ }; @@ -478,7 +478,7 @@ Constructs a WGrid. :param spacing: Size of each column and row, respectively. :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 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 { 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); String getText() const; @@ -504,7 +504,7 @@ viz::WText3D::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 position: Position of the text. @@ -609,7 +609,7 @@ This 3D Widget represents an image in 3D space. :: //! Creates 3D image at the origin 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 - 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); }; @@ -623,7 +623,7 @@ Constructs an WImage3D. :param image: BGR or Gray-Scale 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 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: //! 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 - 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 - 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 - 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 - 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 @@ -666,7 +666,7 @@ Constructs a WCameraPosition. - **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. @@ -676,7 +676,7 @@ Constructs a WCameraPosition. - **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 scale: Scale of the frustum. @@ -684,7 +684,7 @@ Constructs a WCameraPosition. 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 scale: Scale of the frustum. @@ -698,7 +698,7 @@ Constructs a WCameraPosition. - **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 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. - .. 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 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}; //! 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 ----------------------------- 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> with T == [float | double] :param display_mode: Display mode. This can be PATH, FRAMES, and BOTH. @@ -762,16 +762,16 @@ This 3D Widget represents a trajectory. :: { public: //! Displays trajectory of the given path by frustums - WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()); + WTrajectoryFrustums(const std::vector &path, const Matx33d &K, double scale = 1.0, const Color &color = Color::white()); //! Displays trajectory of the given path by frustums - WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()); + WTrajectoryFrustums(const std::vector &path, const Vec2d &fov, double scale = 1.0, const Color &color = Color::white()); }; viz::WTrajectoryFrustums::WTrajectoryFrustums ----------------------------- Constructs a WTrajectoryFrustums. -.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.0, const Color &color = Color::white()) +.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Matx33d &K, double scale = 1.0, const Color &color = Color::white()) :param path: List of poses on a trajectory. :param K: Intrinsic matrix of the camera. @@ -780,7 +780,7 @@ Constructs a WTrajectoryFrustums. Displays frustums at each pose of the trajectory. -.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.0, const Color &color = Color::white()) +.. ocv:function:: WTrajectoryFrustums(const std::vector &path, const Vec2d &fov, double scale = 1.0, const Color &color = Color::white()) :param path: List of poses on a trajectory. :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 { public: - WTrajectorySpheres(const std::vector &path, float line_length = 0.05f, - float init_sphere_radius = 0.021, sphere_radius = 0.007, + WTrajectorySpheres(const std::vector &path, double line_length = 0.05f, + double init_sphere_radius = 0.021, sphere_radius = 0.007, Color &line_color = Color::white(), const Color &sphere_color = Color::white()); }; @@ -808,7 +808,7 @@ viz::WTrajectorySpheres::WTrajectorySpheres ------------------------------------------- Constructs a WTrajectorySpheres. -.. ocv:function:: WTrajectorySpheres(const std::vector &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 &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 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 { 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: /* hidden */ @@ -922,7 +922,7 @@ viz::WCloudNormals::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 normals: A set of normals that has to be of same type with cloud. diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index b48795290da86909a23d4b8145fbff7b4f039b6a..8fedb0c2c97616f5119b4639554fb95723683cde 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -135,44 +135,44 @@ namespace cv class CV_EXPORTS WLine : public Widget3D { 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 { public: - WPlane(const Vec4f& coefs, float 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, double 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 { public: - WSphere(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white()); + WSphere(const cv::Point3d ¢er, double radius, int sphere_resolution = 10, const Color &color = Color::white()); }; class CV_EXPORTS WArrow : public Widget3D { 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 { 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 { 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 { 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 @@ -196,7 +196,7 @@ namespace cv class CV_EXPORTS WText3D : public Widget3D { 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); String getText() const; @@ -216,7 +216,7 @@ namespace cv //! Creates 3D image at the origin 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 - 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); }; @@ -234,24 +234,24 @@ namespace cv { public: //! 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 - 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 { public: //! 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 - 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 - 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 - 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 - 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: //! Displays trajectory of the given path by frustums - WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale = 1.f, const Color &color = Color::white()); + WTrajectoryFrustums(const std::vector &path, const Matx33d &K, double scale = 1., const Color &color = Color::white()); //! Displays trajectory of the given path by frustums - WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale = 1.f, const Color &color = Color::white()); + WTrajectoryFrustums(const std::vector &path, const Vec2d &fov, double scale = 1., const Color &color = Color::white()); }; class CV_EXPORTS WTrajectorySpheres: public Widget3D { public: - WTrajectorySpheres(const std::vector &path, float line_length = 0.05f, float init_sphere_radius = 0.021f, - float sphere_radius = 0.007f, const Color &line_color = Color::white(), const Color &sphere_color = Color::white()); + WTrajectorySpheres(const std::vector &path, double line_length = 0.05, double init_sphere_radius = 0.021, + 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 { 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 diff --git a/modules/viz/src/clouds.cpp b/modules/viz/src/clouds.cpp index 3c28624f31f39c3181c174303736f9ba507836ef..15e9d4a61639123842fd2d9880aa17c03fe3cbe4 100644 --- a/modules/viz/src/clouds.cpp +++ b/modules/viz/src/clouds.cpp @@ -175,7 +175,7 @@ template<> cv::viz::WCloudCollection cv::viz::Widget::castInsertNextPoint(srow); points->InsertNextPoint(endp.val); diff --git a/modules/viz/src/shapes.cpp b/modules/viz/src/shapes.cpp index b1ef3de5e0206652048b457c83f90f2265bf8885..8afe6495716ec7693596e787743861f7c1174390 100644 --- a/modules/viz/src/shapes.cpp +++ b/modules/viz/src/shapes.cpp @@ -55,7 +55,7 @@ namespace cv /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 line = vtkSmartPointer::New(); 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 plane = vtkSmartPointer::New(); 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); Vec3d p_center; @@ -123,15 +123,15 @@ cv::viz::WPlane::WPlane(const Vec4f& coefs, float size, const Color &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 plane = vtkSmartPointer::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); plane->SetNormal(coefs[0], coefs[1], coefs[2]); 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]); vtkSmartPointer mapper = vtkSmartPointer::New(); @@ -153,7 +153,7 @@ template<> cv::viz::WPlane cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// sphere widget implementation -cv::viz::WSphere::WSphere(const Point3f ¢er, float radius, int sphere_resolution, const Color &color) +cv::viz::WSphere::WSphere(const Point3d ¢er, double radius, int sphere_resolution, const Color &color) { vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetRadius(radius); @@ -181,7 +181,7 @@ template<> cv::viz::WSphere cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 arrowSource = vtkSmartPointer::New(); arrowSource->SetShaftRadius(thickness); @@ -231,7 +231,7 @@ template<> cv::viz::WArrow cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 disk = vtkSmartPointer::New(); // Maybe the resolution should be lower e.g. 50 or 25 @@ -267,9 +267,9 @@ template<> cv::viz::WCircle cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 line = vtkSmartPointer::New(); line->SetPoint1(pt_on_axis.x, pt_on_axis.y, pt_on_axis.z); line->SetPoint2(pt2.x, pt2.y, pt2.z); @@ -298,7 +298,7 @@ template<> cv::viz::WCylinder cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 mapper = vtkSmartPointer::New(); if (wire_frame) @@ -330,7 +330,7 @@ template<> cv::viz::WCube cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// coordinate system widget implementation -cv::viz::WCoordinateSystem::WCoordinateSystem(float scale) +cv::viz::WCoordinateSystem::WCoordinateSystem(double scale) { vtkSmartPointer axes = vtkSmartPointer::New(); 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 grid = GridUtils::createGrid(dimensions, spacing); @@ -479,14 +479,14 @@ cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2f &spacing, const 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 grid = GridUtils::createGrid(dimensions, spacing); // Estimate the transform to set the normal based on the coefficients Vec3d normal(coefs[0], coefs[1], coefs[2]); 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 u = normalize(up_vector.cross(n)); Vec3d v = n.cross(u); @@ -525,7 +525,7 @@ template<> cv::viz::WGrid cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// 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 textSource = vtkSmartPointer::New(); textSource->SetText(text.c_str()); @@ -759,7 +759,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size &size) 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); @@ -857,7 +857,7 @@ namespace cv { namespace viz { namespace { 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 actor) { // 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 axes = vtkSmartPointer::New(); axes->SetOrigin(0, 0, 0); @@ -992,20 +992,20 @@ cv::viz::WCameraPosition::WCameraPosition(float scale) 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 camera = vtkSmartPointer::New(); - float f_x = K(0,0); - float f_y = K(1,1); - float c_y = K(1,2); - float aspect_ratio = f_y / f_x; + double f_x = K(0,0); + double f_y = K(1,1); + double c_y = K(1,2); + 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) - 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->SetPosition(0.0,0.0,0.0); - camera->SetViewUp(0.0,1.0,0.0); - camera->SetFocalPoint(0.0,0.0,1.0); + camera->SetPosition(0.0, 0.0, 0.0); + camera->SetViewUp(0.0, 1.0, 0.0); + camera->SetFocalPoint(0.0, 0.0, 1.0); camera->SetClippingRange(0.01, scale); double planesArray[24]; @@ -1014,8 +1014,7 @@ cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, float scale, const C vtkSmartPointer planes = vtkSmartPointer::New(); planes->SetFrustumPlanes(planesArray); - vtkSmartPointer frustumSource = - vtkSmartPointer::New(); + vtkSmartPointer frustumSource = vtkSmartPointer::New(); frustumSource->SetPlanes(planes); 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 camera = vtkSmartPointer::New(); camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view - camera->SetPosition(0.0,0.0,0.0); - camera->SetViewUp(0.0,1.0,0.0); - camera->SetFocalPoint(0.0,0.0,1.0); + camera->SetPosition(0.0, 0.0, 0.0); + camera->SetViewUp(0.0, 1.0, 0.0); + camera->SetFocalPoint(0.0, 0.0, 1.0); camera->SetClippingRange(0.01, scale); 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); } -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); - float f_y = K(1,1); - float c_y = K(1,2); + double f_y = K(1,1); + 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) - float fovy = 2.0f * atan2(c_y,f_y) * 180.0f / CV_PI; - float far_end_height = 2.0f * c_y * scale / f_y; + double fovy = 2.0 * atan2(c_y,f_y) * 180.0 / CV_PI; + double far_end_height = 2.0f * c_y * scale / f_y; vtkSmartPointer actor = vtkSmartPointer::New(); CameraPositionUtils::projectImage(fovy, far_end_height, image, scale, color, 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); - float fovy = fov[1] * 180.0f / CV_PI; - float far_end_height = 2.0 * scale * tan(fov[1] * 0.5); + double fovy = fov[1] * 180.0 / CV_PI; + double far_end_height = 2.0 * scale * tan(fov[1] * 0.5); vtkSmartPointer actor = vtkSmartPointer::New(); 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.type() == CV_32FC(16) || _path.type() == CV_64FC(16)); @@ -1259,15 +1258,15 @@ template<> cv::viz::WTrajectory cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// WTrajectoryFrustums widget implementation -cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Matx33f &K, float scale, const Color &color) +cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Matx33d &K, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); - float f_x = K(0,0); - float f_y = K(1,1); - float c_y = K(1,2); - float aspect_ratio = f_y / f_x; + double f_x = K(0,0); + double f_y = K(1,1); + double c_y = K(1,2); + 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) - 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->SetPosition(0.0,0.0,0.0); @@ -1303,14 +1302,14 @@ cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &p setColor(color); } -cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Vec2f &fov, float scale, const Color &color) +cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(const std::vector &path, const Vec2d &fov, double scale, const Color &color) { vtkSmartPointer camera = vtkSmartPointer::New(); camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view - camera->SetPosition(0.0,0.0,0.0); - camera->SetViewUp(0.0,1.0,0.0); - camera->SetFocalPoint(0.0,0.0,1.0); + camera->SetPosition(0.0, 0.0, 0.0); + camera->SetViewUp(0.0, 1.0, 0.0); + camera->SetFocalPoint(0.0, 0.0, 1.0); camera->SetClippingRange(0.01, scale); 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 &path, float line_length, float init_sphere_radius, float sphere_radius, +cv::viz::WTrajectorySpheres::WTrajectorySpheres(const std::vector &path, double line_length, double init_sphere_radius, double sphere_radius, const Color &line_color, const Color &sphere_color) { vtkSmartPointer appendFilter = vtkSmartPointer::New();