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(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && \
15 (((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_OBJDETECT)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_XOBJDETECT)))
16 #ifdef ENABLE_VISP_NAMESPACE
22 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
23 std::string opt_video =
"video.mp4";
26 for (
int i = 1; i < argc; i++) {
27 if (std::string(argv[i]) ==
"--haar" && i + 1 < argc) {
28 opt_face_cascade_name = std::string(argv[++i]);
30 else if (std::string(argv[i]) ==
"--video" && i + 1 < argc) {
31 opt_video = std::string(argv[++i]);
33 else if ((std::string(argv[i]) ==
"--help") || (std::string(argv[i]) ==
"-h")) {
34 std::cout <<
"Usage: " << argv[0]
35 <<
" [--haar <haarcascade xml filename>]"
36 <<
" [--video <input video file>]"
37 <<
" [--help] [-h]" << std::endl;
48 #if defined(VISP_HAVE_X11)
50 #elif defined(VISP_HAVE_GDI)
52 #elif defined(HAVE_OPENCV_HIGHGUI)
64 bool exit_requested =
false;
65 while (!g.
end() && !exit_requested) {
70 bool face_found = face_detector.
detect(I);
74 std::ostringstream text;
76 text <<
"Found " << face_detector.
getNbObjects() <<
" face(s)";
80 for (
size_t i = 0; i < face_detector.
getNbObjects(); i++) {
91 exit_requested =
true;
101 #if !defined(HAVE_OPENCV_HIGHGUI)
102 std::cout <<
"This tutorial needs OpenCV highgui module that is missing." << std::endl;
104 #if !defined(HAVE_OPENCV_IMGPROC)
105 std::cout <<
"This tutorial needs OpenCV imgproc module that is missing." << std::endl;
107 #if (VISP_HAVE_OPENCV_VERSION < 0x050000) && !defined(HAVE_OPENCV_OBJDETECT)
108 std::cout <<
"This tutorial needs OpenCV objdetect module that is missing." << std::endl;
110 #if ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && !defined(HAVE_OPENCV_XOBJDETECT))
111 std::cout <<
"This tutorial needs OpenCV xobjdetect module that is missing." << std::endl;
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)