35 #include <visp3/core/vpConfig.h>
37 #if defined(HAVE_OPENCV_OBJDETECT)
41 #include <visp3/core/vpImageConvert.h>
42 #include <visp3/detection/vpDetectorFace.h>
44 bool vpSortLargestFace(cv::Rect rect1, cv::Rect rect2) {
return (rect1.area() > rect2.area()); }
103 bool detected =
false;
109 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
112 m_face_cascade.detectMultiScale(frame_gray,
m_faces, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
120 for (
size_t i = 0; i <
m_faces.size(); i++) {
121 std::ostringstream message;
122 message <<
"Face " << i;
127 std::vector<vpImagePoint> polygon;
130 double w =
m_faces[i].size().width;
131 double h =
m_faces[i].size().height;
144 #elif !defined(VISP_BUILD_SHARED_LIBS)
146 void dummy_vpDetectorFace() { };
std::vector< std::string > m_message
Message attached to each object.
std::vector< std::vector< vpImagePoint > > m_polygon
For each object, defines the polygon that contains the object.
size_t m_nb_objects
Number of detected objects.
cv::Mat m_frame_gray
OpenCV image used as input for the face detection.
void setCascadeClassifierFile(const std::string &filename)
bool detect(const vpImage< unsigned char > &I) VP_OVERRIDE
std::vector< cv::Rect > m_faces
Bounding box of each detected face.
cv::CascadeClassifier m_face_cascade
Haar cascade classifier file name.
error that can be emitted by ViSP classes.
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...