Reputation: 370
I got this error while using random forest inside OpenCV:
OpenCV Error: Bad argument (5273-th value of 220-th (ordered) variable (=-1.70141e+38) is too large) in CvDTreeTrainData::set_data, file /home/XXX/Downloads/opencv-2.4.6.1/modules/ml/src/tree.cpp, line 551
terminate called after throwing an instance of 'cv::Exception'
what(): /home/XXX/Downloads/opencv-2.4.6.1/modules/ml/src/tree.cpp:551: error: (-5) 5273-th value of 220-th (ordered) variable (=-1.70141e+38) is too large in function CvDTreeTrainData::set_data
Aborted (core dumped)
It is strange because the printed number is not out of the float range (-3.4E+38 to +3.4E+38)
I found out where is printed in the source of opencv, but I'm not able to understand what's the problem:
the file is tree.cpp
for( i = 0; i < sample_count; i++ )
{
float val = ord_nan;
int si = sidx ? sidx[i] : i;
if( !mask || !mask[(size_t)si*m_step] )
{
if( idata )
val = (float)idata[(size_t)si*step];
else
val = fdata[(size_t)si*step];
if( fabs(val) >= ord_nan )
{
sprintf( err, "%d-th value of %d-th (ordered) "
"variable (=%g) is too large", i, vi, val );
CV_ERROR( CV_StsBadArg, err );
}
num_valid++;
}
if (is_buf_16u)
udst[i] = (unsigned short)i; // TODO: memory corruption may be here
else
idst[i] = i;
_fdst[i] = val;
}
Can anyone give me an hint?
Upvotes: 0
Views: 1164
Reputation: 1831
If you check line 551 in the tree.cpp file you can see that fabs(val) >= ord_nan
is required where ord_nan = FLT_MAX*0.5f
. So it is fails when val == -1.70141e+38
since it is bigger than this limit.
Upvotes: 1