【问题标题】:How to add data in vector to cv::Mat?如何将向量中的数据添加到 cv::Mat?
【发布时间】:2013-11-29 22:24:59
【问题描述】:

我想使用 cv::Mat 将 Data 训练到 SVM,但是当我使用 hog.compute 时,输出是一个 Vector,所以我必须先将它添加到 Mat。

例如,如果我有

vector  test ;
test.push_back(5);
test.push_back(47);

vector test2;
test.push_back(5098);
test.push_back(50);

Mat m[2][2];

那么如何将 test 和 test2 数据添加到 m 中呢?我想要一个看起来像 {{5,47},{5098,50}}

的结果

我尝试使用 m[1][1].push_back(test);但它不起作用。

【问题讨论】:

    标签: c++ opencv vector svm


    【解决方案1】:

    假设你有

    vector<float> test;
    vector<float> test2;
    

    你想要类似的东西

    Mat m1(test);
    m1.push_back(Mat(test2));
    

    【讨论】:

    • 如果我没有像 Mat m1 那样定义矩阵大小;我使用 m1.push_back(Mat(test)); m1.push_back(垫(test2)); . 矩阵大小是否变为 m[2][2] 并得到我想要的结果?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多