Merge pull request #11353 from eecsninja:3.4
authorSimon Que <simonque@gmail.com>
Fri, 20 Apr 2018 12:31:47 +0000 (08:31 -0400)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Fri, 20 Apr 2018 12:31:47 +0000 (15:31 +0300)
* Fix CV_Asserts with negation of strings

{!"string"} causes some compilers to throw a warning.

The value of the string is not that important -- it's only for printing
the assertion message.

Replace these calls with:

  CV_Error(Error::StsError, "string")

to suppress the warning.

* remove unnecessary 'break' after CV_Error()

modules/core/include/opencv2/core/affine.hpp
modules/core/src/persistence_base64.cpp
modules/videoio/src/cap_gstreamer.cpp
modules/viz/src/types.cpp
modules/viz/src/vizcore.cpp
modules/viz/src/vtk/vtkCloudMatSource.cpp

index 66853a7..7e2ed30 100644 (file)
@@ -445,7 +445,7 @@ void cv::Affine3<T>::rotation(const cv::Mat& data)
         rotation(_rvec);
     }
     else
-        CV_Assert(!"Input matrix can only be 3x3, 1x3 or 3x1");
+        CV_Error(Error::StsError, "Input matrix can only be 3x3, 1x3 or 3x1");
 }
 
 template<typename T> inline
index 878cc95..8d6e6cc 100644 (file)
@@ -638,7 +638,8 @@ private:
                     pack.func = to_binary<double>;
                     break;
                 case 'r':
-                default: { CV_Assert(!"type not support"); break; }
+                default:
+                    CV_Error(cv::Error::StsError, "type is not supported");
                 };
 
                 offset = static_cast<size_t>(cvAlign(static_cast<int>(offset), static_cast<int>(size)));
@@ -797,7 +798,8 @@ private:
                     pack.func = binary_to<double>;
                     break;
                 case 'r':
-                default:  { CV_Assert(!"type not support"); break; }
+                default:
+                    CV_Error(cv::Error::StsError, "type is not supported");
                 }; // need a better way for outputting error.
 
                 offset = static_cast<size_t>(cvAlign(static_cast<int>(offset), static_cast<int>(size)));
@@ -815,7 +817,8 @@ private:
                 case 'f': { pack.cv_type = CV_32F; break; }
                 case 'd': { pack.cv_type = CV_64F; break; }
                 case 'r':
-                default:  { CV_Assert(!"type is not support"); break; }
+                default:
+                    CV_Error(cv::Error::StsError, "type is not supported");
                 } // need a better way for outputting error.
 
                 binary_to_funcs.push_back(pack);
index 83d5dc2..3be2a10 100644 (file)
@@ -1614,7 +1614,8 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
         caps = gst_caps_fixate(caps);
 #endif
 #else
-        CV_Assert(!"Gstreamer 0.10.29 or newer is required for grayscale input");
+        CV_Error(Error::StsError,
+                 "Gstreamer 0.10.29 or newer is required for grayscale input");
 #endif
     }
 
index 16d3d93..65571a1 100644 (file)
@@ -63,8 +63,7 @@ cv::viz::Mesh cv::viz::Mesh::load(const String& file, int type)
     switch (type) {
       case LOAD_AUTO:
       {
-        CV_Assert(!"cv::viz::Mesh::LOAD_AUTO: Not implemented yet");
-        break;
+        CV_Error(Error::StsError, "cv::viz::Mesh::LOAD_AUTO: Not implemented yet");
       }
       case LOAD_PLY:
       {
@@ -83,8 +82,7 @@ cv::viz::Mesh cv::viz::Mesh::load(const String& file, int type)
         break;
       }
       default:
-        CV_Assert(!"cv::viz::Mesh::load: Unknown file type");
-        break;
+        CV_Error(Error::StsError, "cv::viz::Mesh::load: Unknown file type");
     }
 
     vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();
index 3efc3a9..a0ca498 100644 (file)
@@ -194,7 +194,7 @@ void cv::viz::writeCloud(const String& file, InputArray cloud, InputArray colors
         vtkOBJWriter::SafeDownCast(writer)->SetFileName(file.c_str());
     }
     else
-        CV_Assert(!"Unsupported format");
+        CV_Error(Error::StsError, "Unsupported format");
 
     writer->SetInputConnection(source->GetOutputPort());
     writer->Write();
@@ -228,7 +228,7 @@ cv::Mat cv::viz::readCloud(const String& file, OutputArray colors, OutputArray n
         vtkSTLReader::SafeDownCast(reader)->SetFileName(file.c_str());
     }
     else
-        CV_Assert(!"Unsupported format");
+        CV_Error(Error::StsError, "Unsupported format");
 
     cv::Mat cloud;
 
@@ -325,7 +325,7 @@ void cv::viz::writeTrajectory(InputArray _traj, const String& files_format, int
         return;
     }
 
-    CV_Assert(!"Unsupported array kind");
+    CV_Error(Error::StsError, "Unsupported array kind");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
index e0e7a82..5f1cecb 100644 (file)
@@ -128,7 +128,7 @@ int cv::viz::vtkCloudMatSource::SetColorCloudNormals(InputArray _cloud, InputArr
     else if (n.depth() == CV_64F && c.depth() == CV_64F)
         filterNanNormalsCopy<double, double>(n, c, total);
     else
-        CV_Assert(!"Unsupported normals/cloud type");
+        CV_Error(Error::StsError, "Unsupported normals/cloud type");
 
     return total;
 }
@@ -155,7 +155,7 @@ int cv::viz::vtkCloudMatSource::SetColorCloudNormalsTCoords(InputArray _cloud, I
     else if (tc.depth() == CV_64F && cl.depth() == CV_64F)
         filterNanTCoordsCopy<double, double>(tc, cl, total);
     else
-        CV_Assert(!"Unsupported tcoords/cloud type");
+        CV_Error(Error::StsError, "Unsupported tcoords/cloud type");
 
     return total;
 }