1 #include <visp3/gui/vpDisplayGDI.h> 3 #include <visp3/gui/vpDisplayOpenCV.h> 4 #include <visp3/gui/vpDisplayX.h> 6 #include <visp3/detection/vpDetectorFace.h> 8 #include <visp3/io/vpVideoReader.h> 10 int main(
int argc,
const char *argv[])
13 #if (VISP_HAVE_OPENCV_VERSION >= 0x020200) && defined(VISP_HAVE_OPENCV_OBJDETECT) 17 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
18 std::string opt_video =
"video.mp4";
21 for (
int i = 0; i < argc; i++) {
22 if (std::string(argv[i]) ==
"--haar")
23 opt_face_cascade_name = std::string(argv[i + 1]);
24 else if (std::string(argv[i]) ==
"--video")
25 opt_video = std::string(argv[i + 1]);
26 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
27 std::cout <<
"Usage: " << argv[0]
28 <<
" [--haar <haarcascade xml filename>] [--video <input video file>]" 41 #if defined(VISP_HAVE_X11) 43 #elif defined(VISP_HAVE_GDI) 45 #elif defined(VISP_HAVE_OPENCV) 51 vpDetectorFace face_detector;
54 face_detector.setCascadeClassifierFile(opt_face_cascade_name);
57 bool exit_requested =
false;
58 while (!g.
end() && !exit_requested) {
63 bool face_found = face_detector.detect(I);
67 std::ostringstream text;
69 text <<
"Found " << face_detector.getNbObjects() <<
" face(s)";
73 for (
size_t i = 0; i < face_detector.getNbObjects(); i++) {
74 vpRect bbox = face_detector.getBBox(i);
77 "Message: \"" + face_detector.getMessage(i) +
"\"",
vpColor::red);
84 exit_requested =
true;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
error that can be emited by ViSP classes.
const char * getMessage() const
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
void open(vpImage< vpRGBa > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void acquire(vpImage< vpRGBa > &I)
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
unsigned int getHeight() const
void setFileName(const std::string &filename)
Defines a rectangle in the plane.
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)