MCPcopy Create free account
hub / github.com/davisking/dlib / main

Function main

examples/ffmpeg_webcam_face_pose_ex.cpp:41–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39using namespace dlib::ffmpeg;
40
41int main(int argc, const char** argv)
42{
43 try
44 {
45 command_line_parser parser;
46 parser.add_option("height", "height of frames", 1);
47 parser.add_option("width", "width of frames", 1);
48 parser.add_option("framerate", "webcam desired framerate", 1);
49 parser.set_group_name("Help Options");
50 parser.add_option("h", "alias of --help");
51 parser.add_option("help", "display this message and exit");
52
53 parser.parse(argc, argv);
54 const char* one_time_opts[] = {"height", "width", "framerate"};
55 parser.check_one_time_options(one_time_opts);
56
57 if (parser.option("h") || parser.option("help"))
58 {
59 parser.print_options();
60 cout << "Please use `v4l2-ctl --list-formats-ext` to view all supported hardware formats\n";
61 return 0;
62 }
63
64 demuxer cap{[&]
65 {
66 ffmpeg::demuxer::args args;
67 args.filepath = "/dev/video0";
68 args.height = get_option(parser, "height", 0);
69 args.width = get_option(parser, "width", 0);
70 args.framerate = get_option(parser, "framerate", 0);
71 return args;
72 }()};
73
74 if (!cap.is_open())
75 {
76 cerr << "Unable to connect to camera" << endl;
77 return 1;
78 }
79
80 cout << "height : " << cap.height() << '\n';
81 cout << "width : " << cap.width() << '\n';
82 cout << "fps : " << cap.fps() << '\n';
83
84 image_window win;
85
86 // Load face detection and pose estimation models.
87 frontal_face_detector detector = get_frontal_face_detector();
88 shape_predictor pose_model;
89 deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model;
90
91 array2d<rgb_pixel> img;
92
93 // Grab and process frames until the main window is closed by the user.
94 while(cap.read(img) && !win.is_closed())
95 {
96 // Detect faces
97 std::vector<rectangle> faces = detector(img);
98 // Find the pose of each face.

Callers

nothing calls this directly

Calls 15

get_optionFunction · 0.85
render_face_detectionsFunction · 0.85
parseMethod · 0.80
print_optionsMethod · 0.80
clear_overlayMethod · 0.80
deserializeFunction · 0.70
is_openMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
fpsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected