filestorage_patch.diff

patch for filestorage.cpp - Giuseppe Passino, 2010-03-17 12:25 pm

Download (2.2 kB)

 
apps/traincascade/imagestorage.cpp (working copy)
33 33
        pos = _filename.rfind('/');
34 34
        dlmrt = '/';
35 35
    }
36
    dirname = _filename.substr(0, pos) + dlmrt;
36
    if(pos == String::npos)
37
        dirname = "";
38
    else
39
        dirname = _filename.substr(0, pos) + dlmrt;
37 40
    while( !file.eof() )
38 41
    {
39 42
        std::getline(file, str);
......
132 135
    if( !file )
133 136
        return false;
134 137
    short tmp = 0;  
135
    fread( &count, sizeof( count ), 1, file );
136
    fread( &vecSize, sizeof( vecSize ), 1, file );
137
    fread( &tmp, sizeof( tmp ), 1, file );
138
    fread( &tmp, sizeof( tmp ), 1, file );
138
    int rfields = fread( &count, sizeof( count ), 1, file );
139
    if(rfields != 1){
140
        CV_Error_(CV_StsParseError, ("wrong file format for %s\n", _filename.c_str()));
141
    }
142
    rfields = fread( &vecSize, sizeof( vecSize ), 1, file );
143
    if(rfields != 1){
144
        CV_Error_(CV_StsParseError, ("wrong file format for %s\n", _filename.c_str()));
145
    }
146
    rfields = fread( &tmp, sizeof( tmp ), 1, file );
147
    if(rfields != 1){
148
        CV_Error_(CV_StsParseError, ("wrong file format for %s\n", _filename.c_str()));
149
    }
150
    rfields = fread( &tmp, sizeof( tmp ), 1, file );
151
    if(rfields != 1){
152
        CV_Error_(CV_StsParseError, ("wrong file format for %s\n", _filename.c_str()));
153
    }
139 154
    base = sizeof( count ) + sizeof( vecSize ) + 2*sizeof( tmp );
140 155
    if( feof( file ) )
141 156
        return false;
......
149 164
{
150 165
    CV_Assert( _img.rows * _img.cols == vecSize );
151 166
    uchar tmp = 0;
152
    fread( &tmp, sizeof( tmp ), 1, file );
153
    fread( vec, sizeof( vec[0] ), vecSize, file );
167
    int rfields = fread( &tmp, sizeof( tmp ), 1, file );
168
    if(rfields != 1){
169
        CV_Error(CV_StsParseError, "wrong file format for positive examples file\n");
170
    }
171
    rfields = fread( vec, sizeof( vec[0] ), vecSize, file );
172
    if(rfields != vecSize){
173
        CV_Error(CV_StsParseError, "wrong file format for positive examples file\n");
174
    }
154 175

  
155 176
    if( feof( file ) || last++ >= count )
156 177
        return false;