diff --git a/modules/viz/src/clouds.cpp b/modules/viz/src/clouds.cpp index e7759e323..9ea1d76fe 100644 --- a/modules/viz/src/clouds.cpp +++ b/modules/viz/src/clouds.cpp @@ -112,15 +112,8 @@ void cv::viz::WCloudCollection::addCloud(InputArray cloud, InputArray colors, co vtkSmartPointer source = vtkSmartPointer::New(); source->SetColorCloud(cloud, colors); - vtkSmartPointer transform = vtkSmartPointer::New(); - transform->SetMatrix(pose.matrix.val); + vtkSmartPointer polydata = VtkUtils::TransformPolydata(source->GetOutputPort(), pose); - vtkSmartPointer transform_filter = vtkSmartPointer::New(); - transform_filter->SetInputConnection(source->GetOutputPort()); - transform_filter->SetTransform(transform); - transform_filter->Update(); - - vtkSmartPointer polydata = transform_filter->GetOutput(); vtkSmartPointer actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this)); CV_Assert("Incompatible widget type." && actor); diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp index 98de7b7f6..df46f7048 100644 --- a/modules/viz/src/precomp.hpp +++ b/modules/viz/src/precomp.hpp @@ -256,17 +256,22 @@ namespace cv return normals_generator->GetOutput(); } - static vtkSmartPointer TransformPolydata(vtkSmartPointer polydata, const Affine3d& pose) + static vtkSmartPointer TransformPolydata(vtkSmartPointer algorithm_output_port, const Affine3d& pose) { vtkSmartPointer transform = vtkSmartPointer::New(); transform->SetMatrix(vtkmatrix(pose.matrix)); vtkSmartPointer transform_filter = vtkSmartPointer::New(); transform_filter->SetTransform(transform); - transform_filter->SetInputConnection(polydata->GetProducerPort()); + transform_filter->SetInputConnection(algorithm_output_port); transform_filter->Update(); return transform_filter->GetOutput(); } + + static vtkSmartPointer TransformPolydata(vtkSmartPointer polydata, const Affine3d& pose) + { + return TransformPolydata(polydata->GetProducerPort(), pose); + } }; } }