diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index 9a0b15260..2da99fae2 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -38,6 +38,9 @@ namespace temp_viz { public: LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white()); + + void setLineWidth(float line_width); + float getLineWidth(); }; diff --git a/modules/viz/src/simple_widgets.cpp b/modules/viz/src/simple_widgets.cpp index 0fedd8c4c..f059974ce 100644 --- a/modules/viz/src/simple_widgets.cpp +++ b/modules/viz/src/simple_widgets.cpp @@ -16,3 +16,15 @@ temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const C setColor(color); } + +void temp_viz::LineWidget::setLineWidth(float line_width) +{ + vtkSmartPointer actor = WidgetAccessor::getActor(*this); + actor->GetProperty()->SetLineWidth(line_width); +} + +float temp_viz::LineWidget::getLineWidth() +{ + vtkSmartPointer actor = WidgetAccessor::getActor(*this); + return actor->GetProperty()->GetLineWidth(); +} \ No newline at end of file diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp index 8c7ecb17c..856c105ed 100644 --- a/modules/viz/test/test_viz3d.cpp +++ b/modules/viz/test/test_viz3d.cpp @@ -115,6 +115,7 @@ TEST(Viz_viz3d, accuracy) v.setShapePose("sphere1", cloudPosition); v.setShapePose("arrow1", cloudPosition); lw2.setColor(temp_viz::Color(col_blue, col_green, col_red)); + lw.setLineWidth(lw.getLineWidth()+pos_x * 10); angle_x += 0.1f; angle_y -= 0.1f;