From 705464258e49377ab094b203cd350f8b5b570b9e Mon Sep 17 00:00:00 2001 From: Simon Que Date: Fri, 20 Apr 2018 08:31:47 -0400 Subject: [PATCH] Merge pull request #11353 from eecsninja:3.4 * 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 | 2 +- modules/core/src/persistence_base64.cpp | 9 ++++++--- modules/videoio/src/cap_gstreamer.cpp | 3 ++- modules/viz/src/types.cpp | 6 ++---- modules/viz/src/vizcore.cpp | 6 +++--- modules/viz/src/vtk/vtkCloudMatSource.cpp | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/core/include/opencv2/core/affine.hpp b/modules/core/include/opencv2/core/affine.hpp index 66853a7..7e2ed30 100644 --- a/modules/core/include/opencv2/core/affine.hpp +++ b/modules/core/include/opencv2/core/affine.hpp @@ -445,7 +445,7 @@ void cv::Affine3::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 inline diff --git a/modules/core/src/persistence_base64.cpp b/modules/core/src/persistence_base64.cpp index 878cc95..8d6e6cc 100644 --- a/modules/core/src/persistence_base64.cpp +++ b/modules/core/src/persistence_base64.cpp @@ -638,7 +638,8 @@ private: pack.func = to_binary; break; case 'r': - default: { CV_Assert(!"type not support"); break; } + default: + CV_Error(cv::Error::StsError, "type is not supported"); }; offset = static_cast(cvAlign(static_cast(offset), static_cast(size))); @@ -797,7 +798,8 @@ private: pack.func = binary_to; 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(cvAlign(static_cast(offset), static_cast(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); diff --git a/modules/videoio/src/cap_gstreamer.cpp b/modules/videoio/src/cap_gstreamer.cpp index 83d5dc2..3be2a10 100644 --- a/modules/videoio/src/cap_gstreamer.cpp +++ b/modules/videoio/src/cap_gstreamer.cpp @@ -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 } diff --git a/modules/viz/src/types.cpp b/modules/viz/src/types.cpp index 16d3d93..65571a1 100644 --- a/modules/viz/src/types.cpp +++ b/modules/viz/src/types.cpp @@ -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 polydata = reader->GetOutput(); diff --git a/modules/viz/src/vizcore.cpp b/modules/viz/src/vizcore.cpp index 3efc3a9..a0ca498 100644 --- a/modules/viz/src/vizcore.cpp +++ b/modules/viz/src/vizcore.cpp @@ -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"); } /////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/viz/src/vtk/vtkCloudMatSource.cpp b/modules/viz/src/vtk/vtkCloudMatSource.cpp index e0e7a82..5f1cecb 100644 --- a/modules/viz/src/vtk/vtkCloudMatSource.cpp +++ b/modules/viz/src/vtk/vtkCloudMatSource.cpp @@ -128,7 +128,7 @@ int cv::viz::vtkCloudMatSource::SetColorCloudNormals(InputArray _cloud, InputArr else if (n.depth() == CV_64F && c.depth() == CV_64F) filterNanNormalsCopy(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(tc, cl, total); else - CV_Assert(!"Unsupported tcoords/cloud type"); + CV_Error(Error::StsError, "Unsupported tcoords/cloud type"); return total; } -- 2.7.4