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 defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020200) 17 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
18 std::string opt_video =
"video.mpeg";
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") {
27 std::cout <<
"Usage: " << argv[0]
28 <<
" [--haar <haarcascade xml filename>] [--video <input " 29 "video file>] [--help]" 41 #if defined(VISP_HAVE_X11) 43 #elif defined(VISP_HAVE_GDI) 45 #elif defined(VISP_HAVE_OPENCV) 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++) {
84 exit_requested =
true;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setCascadeClassifierFile(const std::string &filename)
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.
size_t getNbObjects() const
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
void open(vpImage< vpRGBa > &I)
bool detect(const vpImage< unsigned char > &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)
const char * getMessage(void) const
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)
void setFileName(const char *filename)
unsigned int getHeight() const
Defines a rectangle in the plane.
std::vector< std::string > & getMessage()
vpRect getBBox(size_t i) const
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)