矢量下标超出范围 Opencv

vector subscript out of range Opencv

本文关键字:范围 Opencv 下标      更新时间:2023-10-16

我正在尝试将 elbp 函数(即 MAT)的输出插入新向量,但得到: 向量下标超出范围错误?有什么建议吗?

vector <Mat> RefPyramids;
vector <Mat> LBPRefPyramids;
buildPyramid(PyramidDummy, RefPyramids, 3);
for (int PyramidIndex = 0; PyramidIndex <= 4; PyramidIndex++ )
{   
    Mat PramidLoopMat = RefPyramids[PyramidIndex];
    Mat LBPLoopMat;
    lbp::ELBP(PramidLoopMat, LBPLoopMat,  radius, neighbors);
    LBPRefPyramids[PyramidIndex] = LBPLoopMat;
}

你说(在评论中)RefPyramids的大小为 4。 但是您的代码违反了:

        for (int PyramidIndex = 0; PyramidIndex <= 4; PyramidIndex++ )
        {   
            Mat PramidLoopMat = RefPyramids[PyramidIndex];

看,你正在迭代 [0,1,2,3,4]。 那<=应该是<.