Commit 79bcae4e authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed background image reader (thanks to albertzeyer for the patch - ticket #651)

parent d7c0c72b
...@@ -1227,9 +1227,11 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize ...@@ -1227,9 +1227,11 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize
while( !feof( input ) ) while( !feof( input ) )
{ {
*imgfilename = '\0'; *imgfilename = '\0';
if( !fscanf( input, "%s", imgfilename )) if( !fgets( imgfilename, PATH_MAX - (imgfilename - full) - 1, input ))
break; break;
len = (int)strlen( imgfilename ); len = (int)strlen( imgfilename );
if( len > 0 && imgfilename[len-1] == '\n' )
imgfilename[len-1] = 0, len--;
if( len > 0 ) if( len > 0 )
{ {
if( (*imgfilename) == '#' ) continue; /* comment */ if( (*imgfilename) == '#' ) continue; /* comment */
...@@ -1254,9 +1256,11 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize ...@@ -1254,9 +1256,11 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize
while( !feof( input ) ) while( !feof( input ) )
{ {
*imgfilename = '\0'; *imgfilename = '\0';
if( !fscanf( input, "%s", imgfilename )) if( !fgets( imgfilename, PATH_MAX - (imgfilename - full) - 1, input ))
break; break;
len = (int)strlen( imgfilename ); len = (int)strlen( imgfilename );
if( len > 0 && imgfilename[len-1] == '\n' )
imgfilename[len-1] = 0, len--;
if( len > 0 ) if( len > 0 )
{ {
if( (*imgfilename) == '#' ) continue; /* comment */ if( (*imgfilename) == '#' ) continue; /* comment */
...@@ -1351,11 +1355,11 @@ void icvGetNextFromBackgroundData( CvBackgroundData* data, ...@@ -1351,11 +1355,11 @@ void icvGetNextFromBackgroundData( CvBackgroundData* data,
//#endif /* CV_VERBOSE */ //#endif /* CV_VERBOSE */
img = cvLoadImage( data->filename[data->last++], 0 ); img = cvLoadImage( data->filename[data->last++], 0 );
if( !img ) data->last %= data->count;
if( !img )
continue; continue;
data->round += data->last / data->count; data->round += data->last / data->count;
data->round = data->round % (data->winsize.width * data->winsize.height); data->round = data->round % (data->winsize.width * data->winsize.height);
data->last %= data->count;
offset.x = round % data->winsize.width; offset.x = round % data->winsize.width;
offset.y = round / data->winsize.width; offset.y = round / data->winsize.width;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment