CascadeTraining.exe发生缓冲区溢出错误

时间:2014-09-12 09:04:01

标签: c++ opencv

我正在训练cascadeclassifier并且发生了一个奇怪的问题。它发生在以下代码中的tempStage->write( fs, Mat() );

        CvCascadeBoost* tempStage = new CvCascadeBoost;
        // save current stage
        char buf[10];
        sprintf(buf, "%s%d", "stage", i );
        filename = dirName + buf + ".xml";
        FileStorage fs( filename, FileStorage::WRITE );
        if ( !fs.isOpened() )
        {
            cout << "Current stage can not be written, because file " << filename
                    << " can not be opened." << endl;
            return false;
        }
        fs << FileStorage::getDefaultObjectName(filename) << "{";
        tempStage->write( fs, Mat() );
        fs << "}";

OpenCV错误是

OpenCV Error: Unspecified error (No element name has been given) in unknown func
tion, file D:\Lib\OpenCV_Lib_2.4.6\include\opencv2/core/ope
rations.hpp, line 2908

可能有什么不对?当我检查fs时,它有很多无法读取内存消息,如附图所示。

由于

enter image description here

1 个答案:

答案 0 :(得分:0)

CvCascadeBoost::write的签名是:

void CvCascadeBoost::write( FileStorage &fs, const Mat& featureMap ) const

你传递了一个空矩阵,这应该是错误的。