@@ -25,30 +25,56 @@ int main()
25
25
26
26
auto framgrabber =
27
27
SL::Screen_Capture::CreateScreeCapture ([]() { return SL::Screen_Capture::GetMonitors (); })
28
-
29
- .onNewFrame ([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
30
-
31
- auto r = realcounter.fetch_add (1 );
32
- auto s = std::to_string (r) + std::string (" E" ) + std::string (" .jpg" );
33
-
34
- auto size = RowStride (img) * Height (img);
35
- // auto imgbuffer(std::make_unique<char[]>(size));
36
- // Extract(img, imgbuffer.get(), size);
37
-
38
- // ExtractAndConvertToRGBA(img, imgbuffer.get(), size);
39
-
40
- if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () -
41
- onNewFramestart).count () >= 1000 ) {
42
- std::cout << " onNewFrame fps" << onNewFramecounter << std::endl;
43
- onNewFramecounter = 0 ;
44
- onNewFramestart = std::chrono::high_resolution_clock::now ();
45
- }
46
- onNewFramecounter += 1 ;
47
- })
48
-
49
- .start_capturing ();
50
-
51
- framgrabber.setFrameChangeInterval (std::chrono::milliseconds (0 )); // 100 ms
28
+ .onFrameChanged ([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
29
+ std::cout << " height " << Height (img) << " width " << Width (img) << std::endl;
30
+ auto r = realcounter.fetch_add (1 );
31
+ auto s = std::to_string (r) + std::string (" D" ) + std::string (" .jpg" );
32
+ auto size = RowStride (img) * Height (img);
33
+
34
+ auto imgbuffer (std::make_unique<char []>(size));
35
+ // you can extract the image as is in BGRA, or Convert
36
+ // Extract(img, imgbuffer.get(), size);
37
+ ExtractAndConvertToRGBA (img, imgbuffer.get (), size);
38
+
39
+ // tje_encode_to_file(s.c_str(), Width(img), Height(img), 4, (const unsigned char*)imgbuffer.get());
40
+ })
41
+ .onNewFrame ([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {
42
+
43
+ auto r = realcounter.fetch_add (1 );
44
+ auto s = std::to_string (r) + std::string (" E" ) + std::string (" .jpg" );
45
+
46
+ auto size = RowStride (img) * Height (img);
47
+ auto imgbuffer (std::make_unique<char []>(size));
48
+ // Extract(img, imgbuffer.get(), size);
49
+
50
+ ExtractAndConvertToRGBA (img, imgbuffer.get (), size);
51
+
52
+ if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () -
53
+ onNewFramestart).count () >= 1000 ) {
54
+ std::cout << " onNewFrame fps" << onNewFramecounter << std::endl;
55
+ onNewFramecounter = 0 ;
56
+ onNewFramestart = std::chrono::high_resolution_clock::now ();
57
+ }
58
+ onNewFramecounter += 1 ;
59
+ tje_encode_to_file (s.c_str (), Width (img), Height (img), 4 , (const unsigned char *)imgbuffer.get ());
60
+ })
61
+ .onMouseChanged ([&](const SL::Screen_Capture::Image* img, int x, int y) {
62
+
63
+ auto r = realcounter.fetch_add (1 );
64
+ auto s = std::to_string (r) + std::string (" M" ) + std::string (" .png" );
65
+ if (img) {
66
+ // std::cout << "New Mouse Image x= " << x << " y= " << y << std::endl;
67
+ // lodepng::encode(s, (const unsigned char*)StartSrc(*img), Width(*img), Height(*img));
68
+ }
69
+ else {
70
+ // new coords
71
+ // std::cout << "x= " << x << " y= " << y << std::endl;
72
+ }
73
+
74
+ })
75
+ .start_capturing ();
76
+
77
+ framgrabber.setFrameChangeInterval (std::chrono::milliseconds (100 )); // 100 ms
52
78
framgrabber.setMouseChangeInterval (std::chrono::milliseconds (100 )); // 100 ms
53
79
54
80
std::this_thread::sleep_for (std::chrono::seconds (10 ));
0 commit comments