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

Function main

examples/ffmpeg_screen_grab_ex.cpp:15–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace dlib;
14
15int main()
16try
17{
18 const auto demuxers = ffmpeg::list_demuxers();
19 const bool screen_grab_available = std::find(begin(demuxers), end(demuxers), "x11grab") != demuxers.end();
20
21 if (screen_grab_available)
22 {
23 ffmpeg::demuxer::args args;
24 args.filepath = "";
25 args.input_format = "x11grab";
26
27 ffmpeg::demuxer cap(args);
28 if (!cap.is_open() || !cap.video_enabled())
29 {
30 printf("Failed to open demuxer for screen grab\n");
31 return EXIT_FAILURE;
32 }
33
34 image_window win;
35
36 ffmpeg::frame frame;
37 array2d<rgb_pixel> img;
38
39 while (cap.read(frame))
40 {
41 convert(frame, img);
42 win.set_image(img);
43 }
44 }
45 else
46 {
47 printf("Sorry your installation of ffmpeg doesn't support screen grab\n");
48 }
49
50 return EXIT_SUCCESS;
51}
52catch (const std::exception& e)
53{
54 printf("%s\n", e.what());
55 return EXIT_FAILURE;
56}

Callers

nothing calls this directly

Calls 7

convertFunction · 0.50
endMethod · 0.45
is_openMethod · 0.45
video_enabledMethod · 0.45
readMethod · 0.45
set_imageMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected