diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index 474c1bb81..56ecde784 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -81,7 +81,7 @@ namespace cv class CV_EXPORTS ArrowWidget : public Widget3D { public: - ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color = Color::white()); + ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness = 0.03, const Color &color = Color::white()); }; class CV_EXPORTS CircleWidget : public Widget3D diff --git a/modules/viz/src/shape_widgets.cpp b/modules/viz/src/shape_widgets.cpp index e2cb9a560..2272e17f8 100644 --- a/modules/viz/src/shape_widgets.cpp +++ b/modules/viz/src/shape_widgets.cpp @@ -128,9 +128,13 @@ template<> cv::viz::SphereWidget cv::viz::Widget::cast() /////////////////////////////////////////////////////////////////////////////////////////////// /// arrow widget implementation -cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color) +cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, double thickness, const Color &color) { vtkSmartPointer arrowSource = vtkSmartPointer::New (); + arrowSource->SetShaftRadius(thickness); + // The thickness and radius of the tip are adjusted based on the thickness of the arrow + arrowSource->SetTipRadius(thickness * 3.0); + arrowSource->SetTipLength(thickness * 10.0); float startPoint[3], endPoint[3]; startPoint[0] = pt1.x; diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp index f2ba913d0..687d9f19d 100644 --- a/modules/viz/test/test_viz3d.cpp +++ b/modules/viz/test/test_viz3d.cpp @@ -90,7 +90,7 @@ TEST(Viz_viz3d, accuracy) viz::LineWidget lw(Point3f(0, 0, 0), Point3f(4.f, 4.f,4.f), viz::Color::green()); viz::PlaneWidget pw(Vec4f(0.0,1.0,2.0,3.0), 5.0); viz::SphereWidget sw(Point3f(0, 0, 0), 0.5); - viz::ArrowWidget aw(Point3f(0, 0, 0), Point3f(1, 1, 1), viz::Color::red()); + viz::ArrowWidget aw(Point3f(0, 0, 0), Point3f(1, 1, 1), 0.01, viz::Color::red()); viz::CircleWidget cw(Point3f(0, 0, 0), 0.5, 0.01, viz::Color::green()); viz::CylinderWidget cyw(Point3f(0, 0, 0), Point3f(-1, -1, -1), 0.5, 30, viz::Color::green()); viz::CubeWidget cuw(Point3f(-2, -2, -2), Point3f(-1, -1, -1));