Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv LoadModel() read access violation

Hi, I try to load trained model "lbfmodel.yaml" by loadModel(). –°ompilator gives read access error. "lbfmodel.yaml" located in project root folder

Here is a code:

include <windows.h>

include "opencv.hpp"

include "face/include/opencv2/face.hpp"

include "drawLandmarks.hpp"

include "facemark.hpp"

include "facemarkLBF.hpp"

include <kernelspecs.h>

using namespace cv; using namespace cv::face;

include <iostream>

using namespace std;

int main(int argc, char** argv) {

LoadLibrary("opencv_highgui400d.dll");
LoadLibrary("opencv_core400d.dll");
LoadLibrary("opencv_videoio400d.dll");
LoadLibrary("opencv_imgproc400d.dll");
LoadLibrary("opencv_objdetect400d.dll");

cv::CascadeClassifier faceDetector("haarcascade_frontalface_alt2.xml");

Ptr<Facemark> facemark = FacemarkLBF::create();

facemark->loadModel("lbfmodel.yaml");

VideoCapture cam(0);

Mat frame, gray;

while (cam.read(frame))
{
    vector<Rect> faces;

    cvtColor(frame, gray, COLOR_BGR2GRAY);

    faceDetector.detectMultiScale(gray, faces);

    vector< vector<Point2f> > landmarks;

    bool success = facemark->fit(frame, faces, landmarks);

    if (success)
    {
        for (int i = 0; i < landmarks.size(); i++)
        {
            drawLandmarks(frame, landmarks[i]);
        }
    }

    imshow("Facial Landmark Detection", frame);
    if (waitKey(1) == 27) break;
}
return 0;

}

click to hide/show revision 2
None

updated 2018-10-11 06:26:41 -0500

berak gravatar image

opencv LoadModel() read access violation

Hi, I try to load trained model "lbfmodel.yaml" by loadModel(). –°ompilator gives read access error. "lbfmodel.yaml" located in project root folder

Here is a code:

include <windows.h>

include "opencv.hpp"

include "face/include/opencv2/face.hpp"

include "drawLandmarks.hpp"

include "facemark.hpp"

include "facemarkLBF.hpp"

include <kernelspecs.h>

#include <windows.h>

#include "opencv.hpp"
#include "face/include/opencv2/face.hpp"
#include "drawLandmarks.hpp"
#include "facemark.hpp"
#include "facemarkLBF.hpp"
#include <kernelspecs.h>
using namespace cv;
using namespace cv::face;

include <iostream>

cv::face; #include <iostream> using namespace std;

std; int main(int argc, char** argv) {

{

    LoadLibrary("opencv_highgui400d.dll");
 LoadLibrary("opencv_core400d.dll");
 LoadLibrary("opencv_videoio400d.dll");
 LoadLibrary("opencv_imgproc400d.dll");
 LoadLibrary("opencv_objdetect400d.dll");

 cv::CascadeClassifier faceDetector("haarcascade_frontalface_alt2.xml");

 Ptr<Facemark> facemark = FacemarkLBF::create();

 facemark->loadModel("lbfmodel.yaml");

 VideoCapture cam(0);

 Mat frame, gray;

 while (cam.read(frame))
 {
     vector<Rect> faces;

     cvtColor(frame, gray, COLOR_BGR2GRAY);

     faceDetector.detectMultiScale(gray, faces);

     vector< vector<Point2f> > landmarks;

     bool success = facemark->fit(frame, faces, landmarks);

     if (success)
     {
         for (int i = 0; i < landmarks.size(); i++)
         {
             drawLandmarks(frame, landmarks[i]);
         }
     }

     imshow("Facial Landmark Detection", frame);
     if (waitKey(1) == 27) break;
 }
 return 0;
}

}