fixed "Invalid background description file" bug, #1676

This commit is contained in:
Vadim Pisarevsky 2012-03-26 09:48:43 +00:00
parent afd9523ff2
commit f341ce2665

View File

@ -52,6 +52,7 @@
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
#include <climits> #include <climits>
#include <ctype.h>
#include "highgui.h" #include "highgui.h"
@ -1230,8 +1231,8 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize
if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input )) if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input ))
break; break;
len = (int)strlen( imgfilename ); len = (int)strlen( imgfilename );
if( len > 0 && imgfilename[len-1] == '\n' ) for( ; len > 0 && isspace(imgfilename[len-1]); len-- )
imgfilename[len-1] = 0, len--; imgfilename[len-1] = '\0';
if( len > 0 ) if( len > 0 )
{ {
if( (*imgfilename) == '#' ) continue; /* comment */ if( (*imgfilename) == '#' ) continue; /* comment */