1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

core: add solveLP type checks for output

to forbid Mat1f

Checks are not reliable: empty uninitialized `cv::Mat` has `CV_8UC1` type
This commit is contained in:
Alexander Alekhin
2018-09-01 14:31:15 +00:00
parent f9c8bb40b1
commit 70a27c7dd6
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -98,6 +98,10 @@ int solveLP(const Mat& Func, const Mat& Constr, Mat& z){
CV_Assert(Constr.type()==CV_64FC1 || Constr.type()==CV_32FC1);
CV_Assert((Func.rows==1 && (Constr.cols-Func.cols==1))||
(Func.cols==1 && (Constr.cols-Func.rows==1)));
if (!z.empty())
CV_CheckTypeEQ(z.type(), CV_64FC1, "");
else
CV_CheckType(z.type(), z.type() == CV_64FC1 || z.type() == CV_8UC1/*empty cv::Mat*/, "");
//copy arguments for we will shall modify them
Mat_<double> bigC=Mat_<double>(1,(Func.rows==1?Func.cols:Func.rows)+1),