0

i've tried to use Landmark module in openCV. The provided code is taken from here https://learnopencv.com/facemark-facial-landmark-detection-using-opencv/ .

Code:

#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
#include "opencv2/drawLandmarks.hpp"

using namespace std;
using namespace cv;
using namespace cv::face;

int main(int argc, char** argv)
{
    // Load Face Detector
    CascadeClassifier faceDetector("C:/Users/pavel/source/repos/opencv/opencv/sources/data/haarcascades/haarcascade_frontalface_alt2.xml");

    // Create an instance of Facemark
    Ptr<Facemark> facemark = FacemarkLBF::create();

    // Load landmark detector
    facemark->loadModel("C:/Users/pavel/source/repos/facemark/facemark/lbfmodel.yaml");

    // Set up webcam for video capture
    VideoCapture cam(0);

    // Variable to store a video frame and its grayscale 
    Mat frame, gray;

    // Read a frame
    while (cam.read(frame))
    {
        // Find face
        vector<Rect> faces;
        // Convert frame to grayscale because
        // faceDetector requires grayscale image.
        cvtColor(frame, gray, COLOR_BGR2GRAY);

        // Detect faces
        faceDetector.detectMultiScale(gray, faces);

        // Variable for landmarks. 
        // Landmarks for one face is a vector of points
        // There can be more than one face in the image. Hence, we 
        // use a vector of vector of points. 
        vector< vector<Point2f> > landmarks;

        // Run landmark detector
        bool success = facemark->fit(frame, faces, landmarks);

        if (success)
        {
            // If successful, render the landmarks on the face
            for (int i = 0; i < landmarks.size(); i++)
            {
                drawLandmarks(frame, landmarks[i]);
            }
        }

        // Display results 
        imshow("Facial Landmark Detection", frame);
        // Exit loop if ESC is pressed
        if (waitKey(1) == 27) break;

    }
    return 0;
}

In project - Included directories: opencv\opencv\build\include Library catalogs: opencv\opencv\build\x64\vc15\lib In linker - additional dependencies:opencv_world454.lib

Error:

1>facemark.obj : error LNK2001: unresolved external symbol "public: __cdecl cv::face::FacemarkLBF::Params::Params(void)" (??0Params@FacemarkLBF@face@cv@@QEAA@XZ).
1>facemark.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::face::FacemarkLBF> __cdecl cv::face::FacemarkLBF::create(struct cv::face::FacemarkLBF::Params const &)" (?create@FacemarkLBF@face@cv@@SA?AU?$Ptr@VFacemarkLBF@face@cv@@@3@AEBUParams@123@@Z).
1>C:\Users\pavel\source\repos\facemark\x64\Release\facemark.exe : fatal error LNK1120: unresolved external elements: 2

Please, help me understand what is the problem.

Legera
  • 1

0 Answers0