I'm trying to do face detection using this code :
const char *faceCascadeFilename = "lbpcascade_frontalface.xml"; // LBP face detector.
const char *windowName = "WebcamFaceRec"; // Name shown in the GUI window.
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include "detectObject.h"
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main()
{
CascadeClassifier faceCascade;
CascadeClassifier eyeCascade1;
CascadeClassifier eyeCascade2;
Rect faceRect;
VideoCapture videoCapture ("m.mp4");
cout << "Face Detection ." << endl;
cout << "Realtime face detection using LBP " << endl;
cout << "Compiled with OpenCV version " << CV_VERSION << endl << endl;
// Load the face and 1 or 2 eye detection XML classifiers.
initDetectors(faceCascade);
while (1)
{
Mat frame;
videoCapture>> frame;
detectLargestObject(frame, faceCascade, faceRect);
if (faceRect.width > 0)
{
cout << "Face Detection ." << endl;
}
imshow("video", frame);
// Press 'c' to escape
if (waitKey(30) == 'c') break;
}
waitKey(0);
return 0;
}
When I run the code this error displayed and I don't know why :
error LNK2019: unresolved external symbol "void detectLargestObject(class cv::Mat const &,class cv::CascadeClassifier &,class cv::Rect_<int> &,int)
this is the function for detection that I'm calling :
void detectLargestObject(const Mat &img, CascadeClassifier &cascade, Rect &largestObject, int scaledWidth)
{
int flags = CASCADE_FIND_BIGGEST_OBJECT;
Size minFeatureSize = Size(20, 20);
float searchScaleFactor = 1.1f;
int minNeighbors = 4;
vector<Rect> objects;
detectObjectsCustom(img, cascade, objects, scaledWidth, flags, minFeatureSize, searchScaleFactor, minNeighbors);
if (objects.size() > 0) {
// Return the only detected object.
largestObject = (Rect)objects.at(0);
}
else {
largestObject = Rect(-1,-1,-1,-1);
}
}