1 #include <visp3/core/vpConfig.h>
3 #include <visp3/gui/vpDisplayGDI.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/gui/vpDisplayX.h>
7 #include <visp3/detection/vpDetectorFace.h>
9 #include <visp3/io/vpVideoReader.h>
11 int main(
int argc,
const char *argv[])
14 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_OBJDETECT)
15 #ifdef ENABLE_VISP_NAMESPACE
21 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
22 std::string opt_video =
"video.mp4";
25 for (
int i = 0; i < argc; i++) {
26 if (std::string(argv[i]) ==
"--haar")
27 opt_face_cascade_name = std::string(argv[i + 1]);
28 else if (std::string(argv[i]) ==
"--video")
29 opt_video = std::string(argv[i + 1]);
30 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
31 std::cout <<
"Usage: " << argv[0] <<
" [--haar <haarcascade xml filename>] [--video <input video file>]"
32 <<
" [--help] [-h]" << std::endl;
43 #if defined(VISP_HAVE_X11)
45 #elif defined(VISP_HAVE_GDI)
47 #elif defined(HAVE_OPENCV_HIGHGUI)
59 bool exit_requested =
false;
60 while (!g.
end() && !exit_requested) {
65 bool face_found = face_detector.
detect(I);
69 std::ostringstream text;
71 text <<
"Found " << face_detector.
getNbObjects() <<
" face(s)";
75 for (
size_t i = 0; i < face_detector.
getNbObjects(); i++) {
86 exit_requested =
true;
static const vpColor green
vpRect getBBox(size_t i) const
size_t getNbObjects() const
std::vector< std::string > & getMessage()
void setCascadeClassifierFile(const std::string &filename)
bool detect(const vpImage< unsigned char > &I) VP_OVERRIDE
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &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)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
const char * getMessage() const
unsigned int getHeight() const
Defines a rectangle in the plane.
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)