From 0bdbc745c444e488021c356ff6197bc6d538e517 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 13 Apr 2021 11:09:14 +0000 Subject: [PATCH] ml: update checks --- modules/ml/src/rtrees.cpp | 2 +- modules/ml/src/tree.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp index 46af37ce11..56be5c0e22 100644 --- a/modules/ml/src/rtrees.cpp +++ b/modules/ml/src/rtrees.cpp @@ -479,7 +479,7 @@ public: float predict( InputArray samples, OutputArray results, int flags ) const CV_OVERRIDE { CV_TRACE_FUNCTION(); - CV_Assert( samples.cols() == getVarCount() && samples.type() == CV_32F ); + CV_CheckEQ(samples.cols(), getVarCount(), ""); return impl.predict(samples, results, flags); } diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp index 1f82ff5081..5dae889013 100644 --- a/modules/ml/src/tree.cpp +++ b/modules/ml/src/tree.cpp @@ -1701,6 +1701,9 @@ void DTreesImpl::readParams( const FileNode& fn ) /*int cat_var_count = (int)fn["cat_var_count"]; int ord_var_count = (int)fn["ord_var_count"];*/ + if (varAll <= 0) + CV_Error(Error::StsParseError, "The field \"var_all\" of DTree classifier is missing or non-positive"); + FileNode tparams_node = fn["training_params"]; TreeParams params0 = TreeParams();