OpenCV错误:在矢量之间移动数据时断言失败



我正在使用卡尔曼滤波器进行一些图像跟踪,有时我需要对数据进行重新排序,以确保不同向量的索引相同。我通过快速逻辑检查来确保当前帧的位置在上一帧的公差范围内。如果是这种情况,我将数据移动到第二个向量以匹配新索引,然后稍后将完全重新排序的向量移回原始向量。如下:

void vector_order(vector<Rect> found_filtered)
{
    int j, i;   
    vector<KalmanFilter> organise_KF(10);
    vector<kal_ret> organise_kal(10);
    vector<FilterHistory> organise_MAV(10);
    for (i=0; i<found_filtered.size(); i++)
    {
        for (j=0; j<track_ret.size(); j++)  //compare tracks for kalman filter
        {
            if (found_filtered[i].x >= track_ret[j].measPt.x-12 || found_filtered[i].x <= track_ret[j].measPt.x+12 )
            {
                if (found_filtered[i].y >= track_ret[j].measPt.y-30 || found_filtered[i].y <= track_ret[j].measPt.y+30 )
                {
                    organise_kal[i] = track_ret[j];
                    organise_KF[i] = KF[j];
                    break;
                }
            }
        }//if there is no match that index will stay empty to be filled by the filter return 
        for (j=0; j<filter_ret.size(); j++)  //compare tracks for moving average filter
        {
            if (found_filtered[i].x >= filter_ret[j].current.x-12 || found_filtered[i].x <= filter_ret[j].current.x+12 )
            {
                if (found_filtered[i].y >= filter_ret[j].current.y-30 || found_filtered[i].y <= filter_ret[j].current.y+30 )
                {
                    organise_MAV[i] = filter_ret[j];
                }
            }//if there is no match that index will stay empty to be filled by the filter return
        }
    }
    for (i=0; i<10; i++)
    {
        track_ret[i] = organise_kal[i];
        filter_ret[i] = organise_MAV[i];
        KF[i] = organise_KF[i];
    }
}

问题是,一旦系统第二次使用数据,就会抛出以下错误:

OpenCV Error: Assertion failed (dims <= 2 && (unsigned)i0 < (unsigned)(size.p[0])*size.p[1]) && elemSize() == (((((DataType<_Tp>::type) & ((512 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> ((DataType<_Tp>::type) & ((1 << 3) - 1))*2) & 3 ))) in unknown function, file C:opencvbuildincludeopencv2/core/mat.hpp, line 569

我是编码新手。有没有更好的方法来重新排序数据,或者我只是错过了一个简单的步骤?

我意识到了这个问题。我没有在新矢量中初始化卡尔曼滤波器,所以当系统使用新滤波器时,没有矩阵数据或缩放集。现在一切都好多了。感谢您查看

相关内容

  • 没有找到相关文章

最新更新