将vector <rect> OpenCV转换为vector <vector <float>&gt;在C ++中

时间:2017-06-29 13:39:47

标签: c++ opencv computer-vision

我正在尝试将vector Rect数据类型转换为vector vector float以对向量使用非最大抑制。矢量包含面的矩形点。我想应用nms,如下所示:Non Maximum Suppression

尝试编译时出现以下错误:

**

undefined reference to `nms(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, float const&)'
collect2: error: ld returned 1 exit status

**

我不知道为什么它会给nms函数2x vector vector float? 谢谢你的帮助!

   vector<Rect> apply_pre_filters(vector<Rect>faces_vector){


    // Non Max Suppression
    float threshold = 0.5;
    vector<vector<float>> faces_vector_float_container;
    cout << "original vector size" << faces_vector.size() << endl;

    for (int i=0; i < faces_vector.size(); i++) {
        vector<int> faces_vector_int = {faces_vector[i].tl().x,faces_vector[i].tl().y,faces_vector[i].br().x, faces_vector[i].br().y};
        vector<float> faces_vector_float(faces_vector_int.begin(), faces_vector_int.end());

        faces_vector_float_container.push_back(faces_vector_float);
    }

    cout << "modified vector size" << faces_vector_float_container.size() << endl;
    vector<Rect> filtered_faces_vector = nms(faces_vector_float_container, threshold);

    // Change Faces detected flag
    if(faces_vector.size() > 0){
        faces_detected = true;
    }else{
        faces_detected = false;
    }

    return faces_vector;
}

1 个答案:

答案 0 :(得分:0)

我将nms个文件添加到CMakeFileList.txt SOURCE_FILES()中。它似乎现在有效。