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