错误:没有匹配函数来调用'FaceDetector :: FaceDetector(std :: __ cxx11 :: string)'

时间:2017-09-29 06:00:09

标签: c++ opencv face-detection

我是C ++的新手,我收到了像

这样的错误
error: no matching function for call to 'FaceDetector::FaceDetector(std::__cxx11::string)'
     FaceDetector fd(string(DEFAULT_CASCADE_PATH));

我正在附上我的代码和错误日志如何解决这个问题,请指导我

#define DEFAULT_CASCADE_PATH "cascades/haarcascade_frontalface_default.xml"
#define ORIGINALS_LIST "obama_raw/list"
#define OUTPUT_DIR "obama_faces"
#define OUTPUT_LIST "list"
#define FACE_SIZE Size(150,150)
#include <cstdlib>
#include <fstream>
#include "cv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "FaceDetector.h"
using namespace std; 
using namespace cv;

void read_input_list(const string &list_path, vector<Mat> &images) {
    ifstream file(list_path.c_str());
    string path;
    while (getline(file, path)) {
        images.push_back(imread(path));
    }
}

int main(int argc, char** argv) {
    FaceDetector fd(string(DEFAULT_CASCADE_PATH));
    vector<Mat> raw_faces;
    ofstream out_list(format("%s/%s", OUTPUT_DIR, OUTPUT_LIST).c_str());
    read_input_list(string(ORIGINALS_LIST), raw_faces);
    int img_c = 0; //images counter

//now detect the faces in each of the raw images:
    for (vector<Mat>::const_iterator raw_img = raw_faces.begin() ; raw_img != raw_faces.end() ; raw_img++){
        vector<Rect> faces;
        //detect faces in the image (there should be only one):
        fd.findFacesInImage(*raw_img, faces);

        //cut each face and write to disk:
        for (vector<Rect>::const_iterator face = faces.begin() ; face != faces.end() ; face++){
            int edge_size = max(face->width, face->height);
            Rect square(face->x, face->y, edge_size, edge_size);
            Mat face_img = (*raw_img)(square);

            //resize:
            resize(face_img, face_img, FACE_SIZE);

            //write to disk:
            string face_path = format("%s/%d.jpg", OUTPUT_DIR, img_c++);
            imwrite(face_path,face_img);
            out_list << face_path << endl;
        }
    }
    out_list.close();
    return 0;
}

我正在附上我的错误日志。请任何人帮忙。 提前致谢

错误:https://i.stack.imgur.com/RZXXK.jpg

1 个答案:

答案 0 :(得分:0)

从GCC 5开始,默认启用新的ABI。在新的ABI中,引入了std :: __ cxx11 namesapce。

根据您的错误消息,您想要链接的程序和OpenCV库似乎是使用不同的GCC版本构建的,这使得二进制文件不兼容。

有关详细信息,请阅读以下页面: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html