2#include <visp3/core/vpConfig.h>
3#include <visp3/gui/vpDisplayFactory.h>
5#include <visp3/detection/vpDetectorFace.h>
7#include <visp3/io/vpVideoReader.h>
9int main(
int argc,
const char *argv[])
12#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && \
13 (((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_OBJDETECT)) || \
14 ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_XOBJDETECT)))
15#ifdef ENABLE_VISP_NAMESPACE
19#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
20 std::shared_ptr<vpDisplay> display;
26 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
27 std::string opt_video =
"video.mp4";
30 for (
int i = 1;
i < argc;
i++) {
31 if (std::string(argv[i]) ==
"--haar" && i + 1 < argc) {
32 opt_face_cascade_name = std::string(argv[++i]);
34 else if (std::string(argv[i]) ==
"--video" && i + 1 < argc) {
35 opt_video = std::string(argv[++i]);
37 else if ((std::string(argv[i]) ==
"--help") || (std::string(argv[i]) ==
"-h")) {
38 std::cout <<
"Usage: " << argv[0]
39 <<
" [--haar <haarcascade xml filename>]"
40 <<
" [--video <input video file>]"
41 <<
" [--help] [-h]" << std::endl;
52#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
66 bool exit_requested =
false;
67 while (!g.
end() && !exit_requested) {
72 bool face_found = face_detector.
detect(I);
76 std::ostringstream text;
78 text <<
"Found " << face_detector.
getNbObjects() <<
" face(s)";
93 exit_requested =
true;
99 std::cout <<
e.getMessage() << std::endl;
101#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
102 if (display !=
nullptr) {
108#if !defined(HAVE_OPENCV_HIGHGUI)
109 std::cout <<
"This tutorial needs OpenCV highgui module that is missing." << std::endl;
111#if !defined(HAVE_OPENCV_IMGPROC)
112 std::cout <<
"This tutorial needs OpenCV imgproc module that is missing." << std::endl;
114#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x050000) && !defined(HAVE_OPENCV_OBJDETECT)
115 std::cout <<
"This tutorial needs OpenCV objdetect module that is missing." << std::endl;
117#if defined(VISP_HAVE_OPENCV) && ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && !defined(HAVE_OPENCV_XOBJDETECT))
118 std::cout <<
"This tutorial needs OpenCV xobjdetect module that is missing." << std::endl;
static const vpColor green
vpRect getBBox(size_t i) const
std::vector< std::string > & getMessage()
size_t getNbObjects() const
void setCascadeClassifierFile(const std::string &filename)
bool detect(const vpImage< unsigned char > &I) VP_OVERRIDE
Class that defines generic functionalities for display.
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.
Definition of the vpImage class member functions.
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 open(vpImage< vpRGBa > &I) VP_OVERRIDE
void setFileName(const std::string &filename)
void acquire(vpImage< vpRGBa > &I) VP_OVERRIDE
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.