smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
638 stars 156 forks source link

Running the code #136

Closed bluetooth12 closed 2 years ago

bluetooth12 commented 2 years ago

A couple questions:

  1. Can your code capture one or all monitors connected to the computer? I am running it now and it shows me a section of my monitor (but not the entire monitor). Is that because of the tiny_jpeg files?
  2. Can your code capture the mouse in the frame? Right now the code is generating pictures of mice but not the mouse relative to the rest of the frame on the monitor.
bluetooth12 commented 2 years ago
  1. Why do you have ScreenCapture_C_API.h? Why not write in pure C++? Why do you have a bunch of wrappers?
smasherprog commented 2 years ago

The example code captures the while monitor, parts of the monitor. I try to run through a couple of scenarios. The base case https://github.com/smasherprog/screen_capture_lite/blob/47defa25fd20048874f78b230a2bed17777eade2/Example_CPP/Screen_Capture_Example.cpp#L408

Should get you the whole monitor

bluetooth12 commented 2 years ago

Yes. I commented out everything that you have in main below: std::this_thread::sleep_for(std::chrono::seconds(10)); The first image saved is indeed my full monitor (not sure about having several monitors) but I also get a bunch of parts of my monitor. What lines cause the code to save images of parts of the monitor? I want to make them stop. I'm trying to figure out what the mouse callback does. It isn't putting the mouse on the image. It looks like it is saving the mouse in a separate small mouse-only image with printing its coordinates to console.

smasherprog commented 2 years ago

Yes thats correct. The mouse image is separate. Otherwise you would need to receive and handle an entire image of everything just because the mouse moved. So your application should combine the mouse on top of the thing its capturing.

Can you post an example of what you mean when u say, you get a bunch of parts of your monitor?

bluetooth12 commented 2 years ago

I ran your code and got 95 images. Here are the first 4. The first image is the full monitor. The rest of them are pieces of my monitor.

0MONITORDIF_ 1MONITORDIF_ 2MONITORDIF_ 3MONITORDIF_

smasherprog commented 2 years ago

Perfect so thats correct. There are 3 callbacks })->onFrameChanged([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {

})->onNewFrame([&](const SL::Screen_Capture::Image& img, const SL::Screen_Capture::Monitor& monitor) {

})->onMouseChanged([&](const SL::Screen_Capture::Image* img, const SL::Screen_Capture::MousePoint &mousepoint) {

})->start_capturing();

ICaptureConfiguration::onNewFrame: This will call back when a new frame is ready on the interval specified in SCL_SetFrameChangeInterval

ICaptureConfiguration::onFrameChanged: This will call back when differences are detected between the last frame and the current one. This is usefull when you want to stream data that you are only sending what has changed, not everything!

ICaptureConfiguration::onMouseChanged: This will call back when the mouse has changed location or the mouse image has changed up to a maximum rate specified in SCL_SetMouseChangeInterval

smasherprog commented 2 years ago

onFrameChanged WIll always start with the FULL IMAGE, then call you back sending only CHANGES. So, in theory, you can just use that for your purposes

smasherprog commented 2 years ago

The idea with the pieces is that you send only those and you can stitch them together on the other side. If you know that you are going to send everything ALL the time, then just use the OnNewFrame, if you know you are going to be streaming something that doesnt change all too often, then use the OnFrameChanged..

Both can be used at the same time, these are here solely for optimizations

smasherprog commented 2 years ago

Sending a 4k res pic on at a decent framerate will generate significant network throughput even with good compression. So, be carefull

smasherprog commented 2 years ago

Gonna close this as working as expected unless you have some additional info?