Merge pull request #6891 from snosov1:fix-5311

This commit is contained in:
Maksim Shabunin 2016-07-14 11:25:58 +00:00
commit 79f8e516b8
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.
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
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 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.

View File

@ -387,7 +387,7 @@ static int icvInitEMD( const float* signature1, int size1,
}
else if( weight < 0 )
CV_Error(CV_StsOutOfRange, "");
CV_Error(CV_StsBadArg, "signature1 must not contain negative weights");
}
for( i = 0; i < size2; i++ )
@ -401,11 +401,13 @@ static int icvInitEMD( const float* signature1, int size1,
state->idx2[dsize++] = i;
}
else if( weight < 0 )
CV_Error(CV_StsOutOfRange, "");
CV_Error(CV_StsBadArg, "signature2 must not contain negative weights");
}
if( ssize == 0 || dsize == 0 )
CV_Error(CV_StsOutOfRange, "");
if( ssize == 0 )
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 */
diff = s_sum - d_sum;