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()
This commit is contained in:
Simon Que 2018-04-20 08:31:47 -04:00 committed by Alexander Alekhin
parent 2b4b946689
commit 705464258e
6 changed files with 16 additions and 14 deletions

View 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

View 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);

View 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
}

View 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();

View 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");
}
///////////////////////////////////////////////////////////////////////////////////////////////

View 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;
}