Не срабатывает face_cascade.load()

попытался взять код для распознавания лица с вебкамеры. Проблема заключается в следующем: код срабатывает до момента загрузки каскадов:

(if (!face_cascade.load(face_cascade_name)) { printf("--(!)Error loading\n"); return -1; };).

Использую Visual Studio 2019. Opencv v4.5.4. В проекте указал пути к include и к ~/x64/vc15/lib

Пробовал указывать как абсолютный путь (C:/Users/.../opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml), так и относительный.

Выноска из кода:

#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>
#include "Tserial.h"

using namespace std;
using namespace cv;

/** Function Headers */
void detectAndDisplay(Mat frame);

/** Global variables */
//-- Note, either copy these two files from opencv/data/haarscascades to your current folder, or change these locations
String face_cascade_name = "haarcascade_frontalface_alt.xml";
String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
CascadeClassifier face_cascade;
CascadeClassifier eyes_cascade;
string window_name = "Capture - Face detection";


int main(int argc, const char** argv)
{
    VideoCapture capture;
    Mat frame;

    //-- 1. Load the cascades
    if (!face_cascade.load(face_cascade_name)) { printf("--(!)Error loading\n"); return -1; };
    
    if (!eyes_cascade.load(eyes_cascade_name)) { printf("--(!)Error loading\n"); return -1; };

Терминальное приложение закрывается после eyes_cascade.load().

Подскажите в чем может быть проблема, почему opencv не может загрузить каскады? Может неверно указывался путь?


Ответы (0 шт):