C++ 使用visual studio在opencv中运行人脸检测时出现错误LNK2019
我试着用一个代码从图像中检测人脸。我从网上尝试了以下示例代码C++ 使用visual studio在opencv中运行人脸检测时出现错误LNK2019,c++,opencv,visual-studio-2013,face-detection,C++,Opencv,Visual Studio 2013,Face Detection,我试着用一个代码从图像中检测人脸。我从网上尝试了以下示例代码 #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include <stdio.h> using namespace std; using n
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main(int argc, const char** argv)
{
//create the cascade classifier object used for the face detection
CascadeClassifier face_cascade;
//use the haarcascade_frontalface_alt.xml library
face_cascade.load("haarcascade_frontalface_alt.xml");
//setup video capture device and link it to the first capture device
VideoCapture captureDevice;
captureDevice.open(0);
//setup image files used in the capture process
Mat captureFrame;
Mat grayscaleFrame;
//create a window to present the results
namedWindow("outputCapture", 1);
//create a loop to capture and find faces
while (true)
{
//capture a new image frame
captureDevice >> captureFrame;
//convert captured image to gray scale and equalize
cvtColor(captureFrame, grayscaleFrame, CV_BGR2GRAY);
equalizeHist(grayscaleFrame, grayscaleFrame);
//create a vector array to store the face found
std::vector<Rect> faces;
//find faces and store them in the vector array
face_cascade.detectMultiScale(grayscaleFrame, faces, 1.1, 3, CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_SCALE_IMAGE, Size(30, 30));
//draw a rectangle for all found faces in the vector array on the original image
for (int i = 0; i < faces.size(); i++)
{
Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
Point pt2(faces[i].x, faces[i].y);
rectangle(captureFrame, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8, 0);
}
//print the output
imshow("outputCapture", captureFrame);
//pause for 33ms
waitKey(33);
}
return 0;
}
目前我遇到以下错误:
错误1错误LNK2019:未解析的外部符号公共:_cdecl cv::CascadeClassifier::CascadeClassifiervoid??0CascadeClassifier@cv@@QEAA@XZ在函数main中引用
需要帮助解决此问题。cv::CascadeClassifier::CascadeClassifiervoid构造函数调用似乎不存在。请在此处查看openCV文档-
似乎是一个连接问题。检查您是否有类似的问题
@ha9u63ar我只在iostream上试过,得到了上面的错误。我获取代码的网络示例中有stdio.h,因此仅使用它进行了尝试。不起作用[这是代码]链接正确吗?链接器选项是什么?也许这就是对你的问题@Sergey有效的答案!非常感谢..+1-代码将//创建用于人脸检测的级联分类器对象级联分类器face\u cascadehaarcascade\u frontalface\u alt.xml;