diff --git a/modules/viz/src/clouds.cpp b/modules/viz/src/clouds.cpp index ce9acd346..4746bc2e5 100644 --- a/modules/viz/src/clouds.cpp +++ b/modules/viz/src/clouds.cpp @@ -56,12 +56,9 @@ namespace cv /////////////////////////////////////////////////////////////////////////////////////////////// /// Point Cloud Widget implementation -cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors) +cv::viz::WCloud::WCloud(InputArray cloud, InputArray colors) { - CV_Assert(!_cloud.empty() && !_colors.empty()); - - Mat cloud = _cloud.getMat(); - Mat colors = _colors.getMat(); + CV_Assert(!cloud.empty() && !colors.empty()); vtkSmartPointer cloud_source = vtkSmartPointer::New(); cloud_source->SetColorCloud(cloud, colors); @@ -81,10 +78,8 @@ cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors) WidgetAccessor::setProp(*this, actor); } -cv::viz::WCloud::WCloud(InputArray _cloud, const Color &color) +cv::viz::WCloud::WCloud(InputArray cloud, const Color &color) { - Mat cloud = _cloud.getMat(); - vtkSmartPointer cloud_source = vtkSmartPointer::New(); cloud_source->SetCloud(cloud); diff --git a/modules/viz/src/vizcore.cpp b/modules/viz/src/vizcore.cpp index 29f6be288..5029756c2 100644 --- a/modules/viz/src/vizcore.cpp +++ b/modules/viz/src/vizcore.cpp @@ -164,15 +164,11 @@ void cv::viz::unregisterAllWindows() { VizStorage::unregisterAll(); } /////////////////////////////////////////////////////////////////////////////////////////////// /// Read/write clouds. Supported formats: ply, stl, xyz, obj -void cv::viz::writeCloud(const String& file, InputArray _cloud, InputArray _colors, InputArray _normals, bool binary) +void cv::viz::writeCloud(const String& file, InputArray cloud, InputArray colors, InputArray normals, bool binary) { CV_Assert(file.size() > 4 && "Extention is required"); String extention = file.substr(file.size()-4); - Mat cloud = _cloud.getMat(); - Mat colors = _colors.getMat(); - Mat normals = _normals.getMat(); - vtkSmartPointer source = vtkSmartPointer::New(); source->SetColorCloudNormals(cloud, colors, normals); diff --git a/modules/viz/src/vtk/vtkCloudMatSource.cpp b/modules/viz/src/vtk/vtkCloudMatSource.cpp index 476e0d5ed..46603a7b9 100644 --- a/modules/viz/src/vtk/vtkCloudMatSource.cpp +++ b/modules/viz/src/vtk/vtkCloudMatSource.cpp @@ -71,12 +71,14 @@ namespace cv { namespace viz cv::viz::vtkCloudMatSource::vtkCloudMatSource() { SetNumberOfInputPorts(0); } cv::viz::vtkCloudMatSource::~vtkCloudMatSource() {} -int cv::viz::vtkCloudMatSource::SetCloud(const Mat& cloud) +int cv::viz::vtkCloudMatSource::SetCloud(InputArray _cloud) { - CV_Assert(cloud.depth() == CV_32F || cloud.depth() == CV_64F); - CV_Assert(cloud.channels() == 3 || cloud.channels() == 4); + CV_Assert(_cloud.depth() == CV_32F || _cloud.depth() == CV_64F); + CV_Assert(_cloud.channels() == 3 || _cloud.channels() == 4); - int total = cloud.depth() == CV_32F ? filterNanCopy(cloud) : filterNanCopy(cloud); + Mat cloud = _cloud.getMat(); + + int total = _cloud.depth() == CV_32F ? filterNanCopy(cloud) : filterNanCopy(cloud); vertices = vtkSmartPointer::New(); vertices->Allocate(vertices->EstimateSize(1, total)); @@ -87,15 +89,18 @@ int cv::viz::vtkCloudMatSource::SetCloud(const Mat& cloud) return total; } -int cv::viz::vtkCloudMatSource::SetColorCloud(const Mat &cloud, const Mat &colors) +int cv::viz::vtkCloudMatSource::SetColorCloud(InputArray _cloud, InputArray _colors) { - int total = SetCloud(cloud); + int total = SetCloud(_cloud); - if (colors.empty()) + if (_colors.empty()) return total; - CV_Assert(colors.depth() == CV_8U && colors.channels() <= 4 && colors.channels() != 2); - CV_Assert(colors.size() == cloud.size()); + CV_Assert(_colors.depth() == CV_8U && _colors.channels() <= 4 && _colors.channels() != 2); + CV_Assert(_colors.size() == _cloud.size()); + + Mat cloud = _cloud.getMat(); + Mat colors = _colors.getMat(); if (cloud.depth() == CV_32F) filterNanColorsCopy(colors, cloud, total); @@ -105,25 +110,28 @@ int cv::viz::vtkCloudMatSource::SetColorCloud(const Mat &cloud, const Mat &color return total; } -int cv::viz::vtkCloudMatSource::SetColorCloudNormals(const Mat &cloud, const Mat &colors, const Mat &normals) +int cv::viz::vtkCloudMatSource::SetColorCloudNormals(InputArray _cloud, InputArray _colors, InputArray _normals) { - int total = SetColorCloud(cloud, colors); + int total = SetColorCloud(_cloud, _colors); - if (normals.empty()) + if (_normals.empty()) return total; - CV_Assert(normals.depth() == CV_32F || normals.depth() == CV_64F); - CV_Assert(normals.channels() == 3 || normals.channels() == 4); - CV_Assert(normals.size() == cloud.size()); + CV_Assert(_normals.depth() == CV_32F || _normals.depth() == CV_64F); + CV_Assert(_normals.channels() == 3 || _normals.channels() == 4); + CV_Assert(_normals.size() == _cloud.size()); + + Mat cloud = _cloud.getMat(); + Mat normals = _normals.getMat(); if (normals.depth() == CV_32F && cloud.depth() == CV_32F) - filterNanNormalsCopy(colors, cloud, total); + filterNanNormalsCopy(normals, cloud, total); else if (normals.depth() == CV_32F && cloud.depth() == CV_64F) - filterNanNormalsCopy(colors, cloud, total); + filterNanNormalsCopy(normals, cloud, total); else if (normals.depth() == CV_64F && cloud.depth() == CV_32F) - filterNanNormalsCopy(colors, cloud, total); + filterNanNormalsCopy(normals, cloud, total); else if (normals.depth() == CV_64F && cloud.depth() == CV_64F) - filterNanNormalsCopy(colors, cloud, total); + filterNanNormalsCopy(normals, cloud, total); else CV_Assert(!"Unsupported normals type"); diff --git a/modules/viz/src/vtk/vtkCloudMatSource.h b/modules/viz/src/vtk/vtkCloudMatSource.h index 023e72324..a1d854c32 100644 --- a/modules/viz/src/vtk/vtkCloudMatSource.h +++ b/modules/viz/src/vtk/vtkCloudMatSource.h @@ -61,9 +61,9 @@ namespace cv static vtkCloudMatSource *New(); vtkTypeMacro(vtkCloudMatSource,vtkPolyDataAlgorithm); - virtual int SetCloud(const Mat& cloud); - virtual int SetColorCloud(const Mat &cloud, const Mat &colors = cv::Mat()); - virtual int SetColorCloudNormals(const Mat &cloud, const Mat &colors = cv::Mat(), const Mat &normals = cv::Mat()); + virtual int SetCloud(InputArray cloud); + virtual int SetColorCloud(InputArray cloud, InputArray colors = noArray()); + virtual int SetColorCloudNormals(InputArray cloud, InputArray colors = noArray(), InputArray normals = noArray()); protected: vtkCloudMatSource();