avoid crash in cvCalcEMD() when one of the histograms has only one non-zero element (ticket #396). Thanks to nburrus for the patch

This commit is contained in:
Vadim Pisarevsky 2010-07-29 11:00:52 +00:00
parent 0faa75da11
commit 62fa7f6620

View File

@ -297,10 +297,14 @@ CV_IMPL float cvCalcEMD2( const CvArr* signature_arr1,
float val = xp->val;
int i = xp->i;
int j = xp->j;
if( xp == state.enter_x )
continue;
int ci = state.idx1[i];
int cj = state.idx2[j];
if( xp != state.enter_x && ci >= 0 && cj >= 0 )
if( ci >= 0 && cj >= 0 )
{
total_cost += (double)val * state.cost[i][j];
if( flow )