switched source to InputArrays
authorAnatoly Baksheev <no@email>
Wed, 1 Jan 2014 14:21:23 +0000 (18:21 +0400)
committerAnatoly Baksheev <no@email>
Sun, 19 Jan 2014 14:38:45 +0000 (18:38 +0400)
modules/viz/src/clouds.cpp
modules/viz/src/vizcore.cpp
modules/viz/src/vtk/vtkCloudMatSource.cpp
modules/viz/src/vtk/vtkCloudMatSource.h

index ce9acd3..4746bc2 100644 (file)
@@ -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<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::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<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
     cloud_source->SetCloud(cloud);
 
index 29f6be2..5029756 100644 (file)
@@ -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<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New();
     source->SetColorCloudNormals(cloud, colors, normals);
 
index 476e0d5..46603a7 100644 (file)
@@ -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<float>(cloud) : filterNanCopy<double>(cloud);
+    Mat cloud = _cloud.getMat();
+
+    int total = _cloud.depth() == CV_32F ? filterNanCopy<float>(cloud) : filterNanCopy<double>(cloud);
 
     vertices = vtkSmartPointer<vtkCellArray>::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<float>(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<float, float>(colors, cloud, total);
+        filterNanNormalsCopy<float, float>(normals, cloud, total);
     else if (normals.depth() == CV_32F && cloud.depth() == CV_64F)
-        filterNanNormalsCopy<float, double>(colors, cloud, total);
+        filterNanNormalsCopy<float, double>(normals, cloud, total);
     else if (normals.depth() == CV_64F && cloud.depth() == CV_32F)
-        filterNanNormalsCopy<double, float>(colors, cloud, total);
+        filterNanNormalsCopy<double, float>(normals, cloud, total);
     else if (normals.depth() == CV_64F && cloud.depth() == CV_64F)
-        filterNanNormalsCopy<double, double>(colors, cloud, total);
+        filterNanNormalsCopy<double, double>(normals, cloud, total);
     else
         CV_Assert(!"Unsupported normals type");
 
index 023e723..a1d854c 100644 (file)
@@ -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();