C++ error in haartraining attempts
Hi -
I'm receiving the following error from terminal during training phase. This is a line of code from within one of the OpenCV C++ includes it seems which is very odd since these lines are not edited in anyway during the process.
Error:
OpenCV Error: Assertion failed (elements_read == 1) in icvGetHaarTraininDataFromVecCallback, file /opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/opencv-2.4.6.1/apps/haartraining/cvhaartraining.cpp, line 1859 libc++abi.dylib: terminate called throwing an exception Abort trap: 6 -MacBook-Pro:newpos …$
Code:
Perhaps you might know what is wrong in the code? I have no idea…
int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata ) { uchar tmp = 0; int r = 0; int c = 0;
assert( img->rows * img->cols == ((CvVecFile*) userdata)->vecsize );
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, ((CvVecFile*) userdata)->input );
CV_Assert(elements_read == 1);
elements_read = fread( ((CvVecFile*) userdata)->vector, sizeof( short ),
((CvVecFile*) userdata)->vecsize, ((CvVecFile*) userdata)->input );
CV_Assert(elements_read == (size_t)((CvVecFile*) userdata)->vecsize);
if( feof( ((CvVecFile*) userdata)->input ) ||
(((CvVecFile*) userdata)->last)++ >= ((CvVecFile*) userdata)->count )
{
return 0;
}
for( r = 0; r < img->rows; r++ )
{
for( c = 0; c < img->cols; c++ )
{
CV_MAT_ELEM( *img, uchar, r, c ) =
(uchar) ( ((CvVecFile*) userdata)->vector[r * img->cols + c] );
}
}
return 1;
}
Regards,