繁体   English   中英

错误:没有用于调用“FaceDetector::FaceDetector(std::__cxx11::string)”的匹配函数

[英]error: no matching function for call to 'FaceDetector::FaceDetector(std::__cxx11::string)'

我是 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

从 GCC 5 开始,默认启用新的 ABI。 在那个新的 ABI 中,引入了 std::__cxx11 命名空间。

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

有关更多信息,您可以阅读以下页面: https : //gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM