1 #include <visp/vpDisplayGDI.h>
3 #include <visp/vpDisplayOpenCV.h>
4 #include <visp/vpDisplayX.h>
5 #include <visp/vpDetectorFace.h>
6 #include <visp/vpV4l2Grabber.h>
8 int main(
int argc,
const char* argv[])
10 #if (VISP_HAVE_OPENCV_VERSION >= 0x020200)
12 std::string opt_face_cascade_name =
"./haarcascade_frontalface_alt.xml";
16 for (
int i=0; i<argc; i++) {
17 if (std::string(argv[i]) ==
"--haar")
18 opt_face_cascade_name = std::string(argv[i+1]);
19 else if (std::string(argv[i]) ==
"--device")
20 opt_device = atoi(argv[i+1]);
21 else if (std::string(argv[i]) ==
"--help") {
22 std::cout <<
"Usage: " << argv[0] <<
" [--haar <haarcascade xml filename>] [--device <camera device>] [--help]" << std::endl;
30 #if defined(VISP_HAVE_V4L2)
32 std::ostringstream device;
33 device <<
"/dev/video" << opt_device;
37 #elif defined(VISP_HAVE_OPENCV)
38 cv::VideoCapture cap(opt_device);
40 std::cout <<
"Failed to open the camera" << std::endl;
49 #if defined(VISP_HAVE_X11)
51 #elif defined(VISP_HAVE_GDI)
53 #elif defined(VISP_HAVE_OPENCV)
64 #if defined(VISP_HAVE_V4L2)
73 bool face_found = face_detector.
detect(I);
76 std::ostringstream text;
77 text <<
"Found " << face_detector.
getNbObjects() <<
" face(s)";
80 std::vector<vpImagePoint> p = face_detector.
getPolygon(i);
const char * getMessage(void)
void acquire(vpImage< unsigned char > &I)
void setCascadeClassifierFile(const std::string &filename)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
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)
Define the X11 console to display images.
void setDevice(const std::string &devname)
error that can be emited by ViSP classes.
static double measureTimeMs()
size_t getNbObjects() const
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
bool detect(const vpImage< unsigned char > &I)
std::vector< std::vector< vpImagePoint > > & getPolygon()
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
virtual void setTitle(const char *title)=0
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
Class for the Video4Linux2 video device.
std::string & getMessage(size_t i)
unsigned int getHeight() const
Defines a rectangle in the plane.
virtual bool getClick(bool blocking=true)=0
vpRect getBBox(size_t i) const