Merge pull request #16604 from Volskig:mp/ocv-gapi-zero-height-mat

G-API: Zero-height mat is cause of crash

* Added check for zero-height Mat case

* Refactoring, added validate_input_arg func

* No bool function now
This commit is contained in:
Maxim Pashchenkov
2020-03-10 14:44:16 +03:00
committed by GitHub
parent 27b71d6368
commit 3befdb4ae8
4 changed files with 65 additions and 0 deletions
+36
View File
@@ -197,6 +197,42 @@ bool cv::can_describe(const GMetaArgs &metas, const GRunArgs &args)
});
}
void cv::validate_input_arg(const GRunArg& arg)
{
// FIXME: It checks only Mat argument
switch (arg.index())
{
#if !defined(GAPI_STANDALONE)
case GRunArg::index_of<cv::Mat>():
{
const auto desc = descr_of(util::get<cv::Mat>(arg));
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::Mat!"); break;
}
case GRunArg::index_of<cv::UMat>():
{
const auto desc = descr_of(util::get<cv::UMat>(arg));
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::UMat!"); break;
}
#endif // !defined(GAPI_STANDALONE)
case GRunArg::index_of<cv::gapi::own::Mat>():
{
const auto desc = descr_of(util::get<cv::gapi::own::Mat>(arg));
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of own::Mat!"); break;
}
default:
// No extra handling
break;
}
}
void cv::validate_input_args(const GRunArgs& args)
{
for (const auto& arg : args)
{
validate_input_arg(arg);
}
}
namespace cv {
std::ostream& operator<<(std::ostream& os, const cv::GMetaArg &arg)
{