provide better error messages

This commit is contained in:
Sergei Nosov 2016-07-12 18:03:28 +03:00
parent c48e237dd0
commit dce310e03c
2 changed files with 10 additions and 6 deletions

View File

@ -3157,10 +3157,12 @@ same object.
@param signature1 First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ floating-point matrix. @param signature1 First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ floating-point matrix.
Each row stores the point weight followed by the point coordinates. The matrix is allowed to have Each row stores the point weight followed by the point coordinates. The matrix is allowed to have
a single column (weights only) if the user-defined cost matrix is used. a single column (weights only) if the user-defined cost matrix is used. The weights must be
non-negative and have at least one non-zero value.
@param signature2 Second signature of the same format as signature1 , though the number of rows @param signature2 Second signature of the same format as signature1 , though the number of rows
may be different. The total weights may be different. In this case an extra "dummy" point is added may be different. The total weights may be different. In this case an extra "dummy" point is added
to either signature1 or signature2 . to either signature1 or signature2. The weights must be non-negative and have at least one non-zero
value.
@param distType Used metric. See cv::DistanceTypes. @param distType Used metric. See cv::DistanceTypes.
@param cost User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix @param cost User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix
is used, lower boundary lowerBound cannot be calculated because it needs a metric function. is used, lower boundary lowerBound cannot be calculated because it needs a metric function.

View File

@ -387,7 +387,7 @@ static int icvInitEMD( const float* signature1, int size1,
} }
else if( weight < 0 ) else if( weight < 0 )
CV_Error(CV_StsOutOfRange, ""); CV_Error(CV_StsBadArg, "signature1 must not contain negative weights");
} }
for( i = 0; i < size2; i++ ) for( i = 0; i < size2; i++ )
@ -401,11 +401,13 @@ static int icvInitEMD( const float* signature1, int size1,
state->idx2[dsize++] = i; state->idx2[dsize++] = i;
} }
else if( weight < 0 ) else if( weight < 0 )
CV_Error(CV_StsOutOfRange, ""); CV_Error(CV_StsBadArg, "signature2 must not contain negative weights");
} }
if( ssize == 0 || dsize == 0 ) if( ssize == 0 )
CV_Error(CV_StsOutOfRange, ""); CV_Error(CV_StsBadArg, "signature1 must contain at least one non-zero value");
if( dsize == 0 )
CV_Error(CV_StsBadArg, "signature2 must contain at least one non-zero value");
/* if supply different than the demand, add a zero-cost dummy cluster */ /* if supply different than the demand, add a zero-cost dummy cluster */
diff = s_sum - d_sum; diff = s_sum - d_sum;