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;
}
what are those
LoadLibrary
calls doing there ?(that's not the right way to do it, and they have no effect at all)
#include <kernelspecs.h>
??#include <windows.h>
nooo, throw it all out.be more precise here. there are 3 steps: compilation, linking and running the program. the lbf model isonly relevant in the last step.
also: we need the exact error msg here !
actually, ALL your includes look broken ! all you should need is:
here's error An exception was thrown at the address 0x00007FF74E1A50CF in Opencv.exe: 0xC0000005: read access violation at 0x0000000000000000.
again, the 1st thing you should do is clean up the code, use proper includes & libs.
are you sure, your model is correct ? (it should be about 50mb for the prebuilt one)
ok, but are you starting your program from there ? (run it from a cmdline, NOT from your ide)
I also want to ask: how to properly connect dll files to the project because when i try to look at the information on faceDetector the compiler writes that "Information not available, symbols for opencv_objdetect400d.dll not loaded"
i use code from there https://www.learnopencv.com/facemark-...
that means, you misconfigured your VS project, and it can't find the corresponding
.pdb
files(it's NOT about the dll's !)
again, already the way you setup the includes looks wrong, all your problems might be related, to how you use VS.
don't you know where pdb files should be?