Tag Archives: Computer Vision & Image Processing

Opencv problem: opencv error: assertion failed (! Empty()) in detectmultiscale

Problem description:

in the process of using OpenCV on ROS to realize face detection, the following problems are encountered:

:

OpenCV Error: Assertion failed (! Empty ()) in detectMultiScale, the file/TMP/binarydeb/ros – kinetic – opencv3-3.3.1/modules/objdetect/SRC/cascadedetect CPP, Line 1698
the terminate called after throwing an instance of ‘CV: : Exception’
I () :/TMP/binarydeb/ros – kinetic – opencv3-3.3.1/modules/objdetect/SRC/cascadedetect CPP: 1698: error: (215). empty() in function detectMultiScale

Aborted (core dumped)

OpenCV cascade detector, Cascadedetect error, XML path reading error, found in the original code face_cascade did not read. XML file. As follows:

cv::CascadeClassifier face_cascade;

solution:

Find the location of the XML file related to face recognition and add the XML file to face_cascade. As follows:

cv::CascadeClassifier face_cascade = cv::CascadeClassifier("/home/opencv/opencv-3.4.4/data/haarcascades/haarcascade_frontalface_default.xml");

after modification, code debugging passed, problem solved.

The XML file here is also optional, with haarcascade_eye.xml for eye recognition, and so on.